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
- Variables
- func Canonical(v any) ([]byte, error)
- func CheckChain(rawEvidence []byte) error
- func EventHash(rawEvent []byte) (string, error)
- func ReadZip(data []byte, l Limits) (map[string][]byte, error)
- func SHA256Hex(b []byte) string
- func Thumbprint(pub crypto.PublicKey) (string, error)
- type Application
- type Challenge
- type Consent
- type ConsentRecord
- type Document
- type Event
- type Evidence
- type Key
- type KeyList
- type Limits
- type Manifest
- type Request
- type SignedData
- type Signer
Constants ¶
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.
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" )
const ( KeyActive = "active" KeyRetired = "retired" KeyCompromised = "compromised" )
Values of Key.Status.
const Format = "inkless-evidence/1"
Format identifies the evidence package format; it is the value of Evidence.Format and Manifest.Format.
const KeyListFormat = "inkless-keys/1"
KeyListFormat is the value of KeyList.Format.
Variables ¶
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.
var RequiredFiles = []string{FileOriginal, FileFinal, FileEvidence, FileJWS, FileTimestamp, FileKeyList, FileSealChain}
RequiredFiles lists every file of a v1 package other than the manifest.
Functions ¶
func CheckChain ¶
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 ¶
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.
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 ¶
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 ¶
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.
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 ¶
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.
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.