sealchain

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2026 License: AGPL-3.0 Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

sealchain

sealchain is a Go library for append-only, tamper-evident audit logs backed by SHA-256 hash chains and Ed25519 signatures.

Why sealchain

  • Dual-mechanism integrity — a SHA-256 hash chain proves ordering and continuity within a log; Ed25519 signatures prove actor authenticity. Each mechanism catches what the other cannot.
  • Domain extensibility — define your own event types and payload fields. sealchain has no opinion about what you log.
  • JSONL on disk — one JSON object per line. Human-readable, greppable, no database required.

Quick Start

go get github.com/parallelhours/sealchain@latest
package main

import (
    "crypto/ed25519"
    "crypto/rand"
    "encoding/binary"
    "fmt"
    "log"

    "github.com/mr-tron/base58"
    sealchain "github.com/parallelhours/sealchain"
)

// Define your own event types.
const EventDocumentStored sealchain.EventType = "DOCUMENT_STORED"

// actor implements sealchain.Signer using Ed25519.
type actor struct {
    did     string
    privKey ed25519.PrivateKey
}

func (a *actor) Sign(msg []byte) ([]byte, error) {
    return ed25519.Sign(a.privKey, msg), nil
}

func newActor() (*actor, error) {
    pub, priv, err := ed25519.GenerateKey(rand.Reader)
    if err != nil {
        return nil, err
    }
    buf := make([]byte, binary.MaxVarintLen64+len(pub))
    n := binary.PutUvarint(buf, 0xed)
    copy(buf[n:], pub)
    did := "did:key:z" + base58.Encode(buf[:n+len(pub)])
    return &actor{did: did, privKey: priv}, nil
}

func main() {
    a, err := newActor()
    if err != nil {
        log.Fatal(err)
    }

    l := sealchain.NewLog("/var/log/myapp/audit.log")

    err = l.Append(sealchain.Entry{
        Event:  EventDocumentStored,
        Domain: sealchain.DomainEntry{"document": "report-q1.pdf", "user": "alice"},
    }, a.did, a)
    if err != nil {
        log.Fatal(err)
    }

    if err := l.Verify(); err != nil {
        log.Fatal("log integrity check failed:", err)
    }
    fmt.Println("log verified OK")
}

sealcheck CLI

Verify an audit log file from the command line — no code required:

go install github.com/parallelhours/sealchain/cmd/sealcheck@latest
sealcheck verify /var/log/myapp/audit.log
# OK: 42 entries verified

Exit codes: 0 = valid, 1 = tampered or corrupt, 2 = usage error.

Documentation

  • Core Concepts — hash chains, genesis sentinel, signature scope, and security guarantees
  • Integration Guide — embedding sealchain in your Go project
  • Licensing — AGPL v3 and commercial license options

License

sealchain is dual-licensed:

  • AGPL v3 — free for open source use. If you distribute or run a service that includes sealchain, your project must also be licensed under AGPL v3. See LICENSE.
  • Commercial license — for closed-source products or SaaS deployments without copyleft obligations. Contact support@parallelhours.io.

See docs/licensing.md for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalForSign

func MarshalForSign(v any) ([]byte, error)

Types

type Domain

type Domain interface {
	Fields() map[string]any
}

type DomainEntry

type DomainEntry map[string]any

func (DomainEntry) Fields

func (d DomainEntry) Fields() map[string]any

type Entry

type Entry struct {
	Foundation Foundation `json:"foundation"`
	Domain     Domain     `json:"domain,omitempty"`
	Event      EventType  `json:"event"`
}

func (Entry) MarshalJSON

func (e Entry) MarshalJSON() ([]byte, error)

MarshalJSON implements custom JSON marshaling to ensure stable field ordering for the Domain field, which is critical for signature verification.

func (*Entry) UnmarshalJSON

func (e *Entry) UnmarshalJSON(data []byte) error

type EventType

type EventType string

type Foundation

type Foundation struct {
	Seq       uint64 `json:"seq"`
	PrevHash  string `json:"prev_hash"`
	ActorDID  string `json:"actor_did"`
	Timestamp string `json:"timestamp"`
	Signature string `json:"signature"`
}

type Log

type Log struct {
	// contains filtered or unexported fields
}

func NewLog

func NewLog(path string) *Log

func (*Log) Append

func (l *Log) Append(e Entry, did string, s Signer) error

func (*Log) Entries

func (l *Log) Entries() ([]Entry, error)

func (*Log) Verify

func (l *Log) Verify() error

type Signer

type Signer interface {
	Sign(message []byte) ([]byte, error)
}

Directories

Path Synopsis
cmd
sealcheck command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL