evidence

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 15 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.

Documentation

Overview

Package evidence defines the Inkless evidence package v1 (evidence.zip): its types, canonicalisation, event hash chain, key list and builder. See docs/evidence-format.md.

Index

Constants

View Source
const (
	FileManifest  = "manifest.json"
	FileOriginal  = "original.pdf"
	FileFinal     = "final.pdf"
	FileEvidence  = "evidence.json"
	FileJWS       = "evidence.jws"
	FileTimestamp = "evidence.tsr"
	FileKeyList   = "keys/keys.json"
	FileSealChain = "keys/seal-chain.pem"
)

Entry names of a package.

View Source
const (
	// GenesisPrevHash is the PrevHash of the first event: 64 hex zeros.
	GenesisPrevHash = "0000000000000000000000000000000000000000000000000000000000000000"
	// ChallengeEmail is the Challenge.Method of an email code challenge.
	ChallengeEmail = "email_code"
	// ChallengePassed is the Challenge.Result of a challenge the signer passed.
	ChallengePassed = "passed"
	// EventSignerSigned is the Type of the event recording a signature; its
	// Data is a SignedData.
	EventSignerSigned = "signer.signed"
)
View Source
const (
	KeyActive      = "active"
	KeyRetired     = "retired"
	KeyCompromised = "compromised"
)

Values of Key.Status.

View Source
const Format = "inkless-evidence/1"

Format identifies the evidence package format; it is the value of Evidence.Format and Manifest.Format.

View Source
const KeyListFormat = "inkless-keys/1"

KeyListFormat is the value of KeyList.Format.

Variables

View Source
var DefaultLimits = Limits{MaxFiles: 16, MaxFileSize: 64 << 20, MaxTotalSize: 192 << 20}

DefaultLimits are the limits used by the verifier when none are set: 16 entries, 64 MiB per entry and 192 MiB in total.

RequiredFiles lists every file of a v1 package other than the manifest.

Functions

func Canonical

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

Canonical returns the RFC 8785 (JCS) form of v's JSON encoding.

func CheckChain

func CheckChain(rawEvidence []byte) error

CheckChain verifies the hash chain over the events array of a raw evidence.json document: sequence numbers, prev_hash links and each hash. It does not check the document signature.

func EventHash

func EventHash(rawEvent []byte) (string, error)

EventHash returns the hash of one event given as a JSON object: SHA-256 of the JCS form of the object without its "hash" member.

func ReadZip

func ReadZip(data []byte, l Limits) (map[string][]byte, error)

ReadZip reads a package into memory, enforcing limits and rejecting unsafe, duplicate or directory entries.

func SHA256Hex

func SHA256Hex(b []byte) string

SHA256Hex returns the lowercase hex SHA-256 of b.

func Thumbprint

func Thumbprint(pub crypto.PublicKey) (string, error)

Thumbprint returns the RFC 7638 SHA-256 JWK thumbprint of pub, base64url. Verifiers pin the key-list root by this value.

Types

type Application

type Application struct {
	Name string `json:"name"`
}

Application identifies the application that created the request.

type Challenge

type Challenge struct {
	// Method is ChallengeEmail.
	Method string `json:"method"`
	// Result is ChallengePassed when the signer passed.
	Result string `json:"result"`
	// Attempts is the number of tries the signer made.
	Attempts int `json:"attempts"`
}

Challenge records the signer authentication challenge.

type Consent struct {
	Version string `json:"version"`
	// Text is the full text as shown.
	Text string `json:"text"`
}

Consent is the consent text shown to signers.

type ConsentRecord

type ConsentRecord struct {
	Version  string `json:"version"`
	Accepted bool   `json:"accepted"`
}

ConsentRecord records the consent a signer gave.

type Document

type Document struct {
	// SHA256 is D0: the lowercase hex SHA-256 of original.pdf.
	SHA256 string `json:"sha256"`
	// Size is the length of original.pdf in bytes.
	Size  int64 `json:"size"`
	Pages int   `json:"pages"`
	// OriginalRevisionLength is the number of leading bytes of final.pdf that
	// equal original.pdf.
	OriginalRevisionLength int64 `json:"original_revision_length"`
	// FinalSHA256 is D1: the lowercase hex SHA-256 of final.pdf.
	FinalSHA256 string `json:"final_sha256"`
	// FinalSize is the length of final.pdf in bytes.
	FinalSize int64 `json:"final_size"`
}

Document holds the digests that bind the evidence to the PDFs.

type Event

type Event struct {
	// Seq starts at 1 and increases by 1 with no gaps.
	Seq  int64     `json:"seq"`
	Type string    `json:"type"`
	At   time.Time `json:"at"`
	// Signer is the Signer.Ref the event concerns, if any.
	Signer string `json:"signer,omitempty"`
	// Data is the event-specific JSON; see SignedData for signer.signed.
	Data json.RawMessage `json:"data,omitempty"`
	// PrevHash is the Hash of the previous event, or GenesisPrevHash.
	PrevHash string `json:"prev_hash"`
	// Hash is the lowercase hex SHA-256 over the canonical event without this
	// member; see EventHash.
	Hash string `json:"hash,omitempty"`
}

Event is one entry of the hash-chained event log.

type Evidence

type Evidence struct {
	Format      string      `json:"format"`
	CreatedAt   time.Time   `json:"created_at"`
	Application Application `json:"application"`
	Request     Request     `json:"request"`
	Document    Document    `json:"document"`
	Signers     []Signer    `json:"signers"`
	Consent     Consent     `json:"consent"`
	Events      []Event     `json:"events"`
}

Evidence is the content of evidence.json: what was recorded about a signing request. It states what the application and signers did; it does not prove who a person is.

type Key

type Key struct {
	// KID is the key id carried in the evidence.jws header.
	KID string `json:"kid"`
	// Alg is the JWS algorithm; verifiers accept only "ES256".
	Alg       string          `json:"alg"`
	PublicKey jose.JSONWebKey `json:"jwk"`
	// NotBefore and NotAfter bound when the key may sign; a nil NotAfter has
	// no end.
	NotBefore time.Time  `json:"not_before"`
	NotAfter  *time.Time `json:"not_after,omitempty"`
	// Status is one of KeyActive, KeyRetired or KeyCompromised.
	Status string `json:"status"`
	// CompromisedAt is when the key stopped being trustworthy; signatures
	// from then on are rejected by ValidAt.
	CompromisedAt *time.Time `json:"compromised_at,omitempty"`
}

Key is one evidence signing key and its validity.

func (*Key) ValidAt

func (k *Key) ValidAt(t time.Time) error

ValidAt reports whether the key could produce a trustworthy signature at t.

type KeyList

type KeyList struct {
	Format   string    `json:"format"`
	IssuedAt time.Time `json:"issued_at"`
	Keys     []Key     `json:"keys"`
}

KeyList is the payload of the signed key list served at /.well-known/inkless/keys.json and copied into each package.

func ParseKeyList

func ParseKeyList(data []byte) (*KeyList, string, error)

ParseKeyList verifies a signed key list against the key in its own header and returns the list with that key's thumbprint. The caller decides whether the thumbprint is trusted.

func (*KeyList) Find

func (kl *KeyList) Find(kid string) *Key

Find returns the key with the given id, or nil if there is none.

type Limits

type Limits struct {
	// MaxFiles is the maximum number of entries.
	MaxFiles int
	// MaxFileSize is the maximum decompressed size of one entry in bytes.
	MaxFileSize int64
	// MaxTotalSize is the maximum decompressed size of all entries in bytes.
	MaxTotalSize int64
}

Limits bound the resources ReadZip spends on a package.

type Manifest

type Manifest struct {
	Format    string `json:"format"`
	RequestID string `json:"request_id"`
	// Files maps each entry name except the manifest to the lowercase hex
	// SHA-256 of its bytes.
	Files map[string]string `json:"files"`
}

Manifest is manifest.json. It is not signed: it detects accidental damage and lists the contents.

type Request

type Request struct {
	ID string `json:"id"`
	// ExternalRef is the application's own reference; empty when not given.
	ExternalRef string `json:"external_ref"`
	// Routing is "parallel" or "sequential".
	Routing   string    `json:"routing"`
	Assurance string    `json:"assurance"`
	ExpiresAt time.Time `json:"expires_at"`
}

Request describes the signing request.

type SignedData

type SignedData struct {
	// DocumentSHA256 is the D0 the signer signed; it must equal
	// Document.SHA256.
	DocumentSHA256 string        `json:"document_sha256"`
	Consent        ConsentRecord `json:"consent"`
	Challenge      Challenge     `json:"challenge"`
	// Assertion is the application's assertion about the signer, stored as
	// received.
	Assertion json.RawMessage `json:"assertion"`
	IP        string          `json:"ip"`
	UserAgent string          `json:"user_agent"`
}

SignedData is the data of a signer.signed event.

type Signer

type Signer struct {
	Ref   string `json:"ref"`
	Name  string `json:"name"`
	Email string `json:"email"`
	Order int    `json:"order"`
}

Signer is a person asked to sign, as given by the application.

Jump to

Keyboard shortcuts

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