Documentation
¶
Overview ¶
Package verify runs the Appendix E verification pipeline against a parsed proof bundle and produces a Report of graded step results.
Every step below corresponds to a numbered section of Appendix E ("Cryptographic Proof Verification Reference", normative) of `truestamp-v2/whitepaper/whitepaper.typ`, and the reference verifier `whitepaper/verify_proof.exs` is the behavioral oracle: step order, status choices and row wording follow it, so that the two produce reports whose statuses match per E.25 on every bundle.
Offline operation is first class: every step from E.6 through E.16, the witness step E.17a and the submission window E.20 run with no network access. The network-dependent steps (E.18, E.19's binding lookup, E.21, the key event's chain confirmations, and the E.17 keyring fetch) run only when the caller allows them and report `skip` on any failure to reach a source; a skipped check never fails a proof.
Index ¶
- Constants
- Variables
- func CategoryLabel(cat string) string
- func Present(r *Report)
- func PresentRejection(w io.Writer, err error)
- func PresentTo(w io.Writer, r *Report)
- func Render(r *Report, color bool) string
- type CommitmentSummary
- type JSONReport
- type Options
- type Rejection
- type RemoteOptions
- type RemoteRejectionError
- type Report
- func Run(filename string, opts Options) (*Report, error)
- func RunBundle(bundle *proof.Bundle, displayName string, opts Options) (*Report, error)
- func RunFromBytes(data []byte, displayName string, opts Options) (*Report, error)
- func RunRemote(filename string, opts RemoteOptions) (*Report, error)
- func RunRemoteBytesCtx(ctx context.Context, data []byte, displayName string, opts RemoteOptions) (*Report, error)
- func RunRemoteCtx(ctx context.Context, filename string, opts RemoteOptions) (*Report, error)
- type Status
- type Step
- type StepCounts
- type Temporal
- type Verifier
Constants ¶
const ( CatDataIntegrity = "data_integrity" CatCryptographic = "cryptographic" CatStructural = "structural" CatTiming = "timing" CatBlockchain = "blockchain" )
Category identifiers, in the wire spelling the server uses.
Variables ¶
var CategoryOrder = []string{CatDataIntegrity, CatCryptographic, CatStructural, CatTiming, CatBlockchain}
CategoryOrder is Appendix E.22's fixed category display order.
Functions ¶
func CategoryLabel ¶ added in v0.13.0
CategoryLabel returns the display title of a category.
func Present ¶
func Present(r *Report)
Present renders a Report to stdout in the reference verifier's shape: a short bundle header, then the five categories in Appendix E.22's display order, each row as a badge, its group and its message, then the counts, whether a file hash was provided, and the verdict.
func PresentRejection ¶ added in v0.13.0
PresentRejection renders an Appendix E.6 hard rejection: no report exists, only the E.23 identifier and one line of advice.
Types ¶
type CommitmentSummary ¶ added in v0.13.0
CommitmentSummary describes one commitment entry for the report header.
type JSONReport ¶ added in v0.13.0
type JSONReport struct {
Verifier Verifier `json:"verifier"`
// Passed is the verdict: no step failed. False for a rejection.
Passed bool `json:"passed"`
// Rejection is set, and every other result field is zero, when the
// bundle was refused before any step ran (E.6).
Rejection *Rejection `json:"rejection,omitempty"`
ID string `json:"id,omitempty"`
Source string `json:"source,omitempty"`
// Steps is the complete step record in Appendix E.22's category order,
// each category's rows in emission order.
Steps []Step `json:"steps"`
Temporal *Temporal `json:"temporal,omitempty"`
PassCount int `json:"pass_count"`
FailedCount int `json:"failed_count"`
WarnCount int `json:"warn_count"`
SkipCount int `json:"skip_count"`
InfoCount int `json:"info_count"`
// HashProvided is the normalized expected hash when one reached a
// comparison, else null. ExpectedHashProvided and HashMatched are the
// two facts Appendix E.7 requires to be reportable separately.
HashProvided *string `json:"hash_provided"`
ExpectedHashProvided bool `json:"expected_hash_provided"`
HashMatched bool `json:"hash_matched"`
ProofVersion int `json:"proof_version"`
SkippedExternal bool `json:"skipped_external"`
GeneratedAt string `json:"generated_at,omitempty"`
// SignaturesChecked is false when --skip-signatures left E.16
// unperformed; `passed` alone cannot say so.
SignaturesChecked bool `json:"signatures_checked"`
// Remote is true when the steps were reported by the Truestamp server.
Remote bool `json:"remote,omitempty"`
}
JSONReport is the machine-readable form of a report. Its field names are the server's (/proof/verify), so a CLI report and an API report are directly comparable, plus `verifier` naming this implementation and `rejection` for an Appendix E.6 hard rejection.
func BuildJSONRejection ¶ added in v0.13.0
func BuildJSONRejection(err error) *JSONReport
BuildJSONRejection creates the machine-readable form of a hard rejection.
func BuildJSONReport ¶ added in v0.13.0
func BuildJSONReport(r *Report) *JSONReport
BuildJSONReport creates the machine-readable form of a report.
type Options ¶
type Options struct {
// ExpectedHash is the hash of the file the caller holds, compared
// against subject.claims.hash for an item subject (E.7). Trimmed and
// lowercased before use.
ExpectedHash string
// ExpectedSubjectType, when non-empty, asserts the bundle's signed
// `type`. A mismatch is the hard rejection `subject_type_mismatch`.
ExpectedSubjectType string
// SkipExternal runs offline: no Horizon, Blockstream, NIST or keyring
// lookups. Every network-dependent step reports skip.
SkipExternal bool
// SkipSignatures leaves E.16's Ed25519 check and the keyring
// cross-check unperformed; the report discloses it.
SkipSignatures bool
// KeyringFile pins a local copy of /.well-known/keyring.json for E.17.
// It takes precedence over KeyringURL and needs no network.
KeyringFile string
// KeyringURL is fetched for E.17 when no file is pinned and the run is
// online. Empty means no keyring is fetched.
KeyringURL string
}
Options holds the caller's choices for a verification run.
type Rejection ¶ added in v0.13.0
type Rejection struct {
Code string `json:"code"`
Detail string `json:"detail"`
Advice string `json:"advice"`
}
Rejection carries an Appendix E.23 rejection identifier.
type RemoteOptions ¶
type RemoteOptions struct {
APIURL string
Team string // team ID, sent as the tenant header
ExpectedHash string
SkipExternal bool
// ExpectedSubjectType is asserted locally against the bundle's signed
// `type` before anything is posted, as the hard rejection
// `subject_type_mismatch`, and forwarded to the server when it holds.
ExpectedSubjectType string
}
RemoteOptions holds configuration for server-side verification. The credential is applied by the process-wide auth.Authorizer; only the tenant scoping is carried here.
The server's verifier is NOT part of the independence argument (Appendix E.2) and this CLI's own verifier never depends on it; --remote is an explicit "ask Truestamp too".
type RemoteRejectionError ¶ added in v0.13.0
RemoteRejectionError is a structured rejection returned by /proof/verify (HTTP 400 with meta.code invalid_proof), carrying the Appendix E.23 identifier in Reason.
func (*RemoteRejectionError) Error ¶ added in v0.13.0
func (e *RemoteRejectionError) Error() string
type Report ¶
type Report struct {
Filename string
FileSize int64
Format string // "json" or "cbor"
// Bundle facts for the header. VersionLiteral is the `version` value
// as carried, so a wrong one is shown as it is rather than as 0.
ProofVersion int
VersionLiteral string
SubjectType string
SubjectID string
BlockID string
GeneratedAt string
WitnessesCarried []string
Commitments []CommitmentSummary
KeyEventCarried bool
// KeyringSource says where the E.17 keyring came from: "pinned <file>",
// "fetched <url>", or "" when none was in hand.
KeyringSource string
Steps []Step
Temporal Temporal
// ExpectedHash is the caller's normalized expected hash, "" when none
// was supplied. Appendix E.7 requires "supplied" to be reportable
// separately from "matched".
ExpectedHash string
SkippedExternal bool
Remote bool
}
Report holds the complete verification results.
func RunFromBytes ¶
RunFromBytes executes the full verification pipeline on raw proof bytes.
func RunRemote ¶
func RunRemote(filename string, opts RemoteOptions) (*Report, error)
RunRemote calls RunRemoteCtx with context.Background.
func RunRemoteBytesCtx ¶ added in v0.13.0
func RunRemoteBytesCtx(ctx context.Context, data []byte, displayName string, opts RemoteOptions) (*Report, error)
RunRemoteBytesCtx is RunRemoteCtx over bytes already in hand.
func RunRemoteCtx ¶ added in v0.9.0
RunRemoteCtx sends the proof to the Truestamp API for server-side verification and returns a Report compatible with the local output.
func (*Report) Counts ¶
func (r *Report) Counts() StepCounts
Counts computes all step status counts in a single pass.
func (*Report) FailedCount ¶
FailedCount returns the number of failed steps.
func (*Report) HashMatched ¶
HashMatched reports whether the supplied expected hash matched `subject.claims.hash`. A fail anywhere in the group is decisive against a match, so a remote row that reports a match this verifier refutes can never publish hash_matched: true.
func (*Report) HashProvided ¶
HashProvided reports whether the caller supplied an expected hash that reached a comparison against `subject.claims.hash`.
func (*Report) Passed ¶
Passed returns true if no step has StatusFail. This is Appendix E.22's verdict rule and the predicate behind the process exit code.
func (*Report) SignaturesSkipped ¶ added in v0.12.0
SignaturesSkipped reports whether this run left Appendix E.16's Ed25519 check unperformed (the --skip-signatures path emits the group's only skip). E.25 does not list E.16 among the steps a verifier MAY skip and still call a run verified, so surfaces that state an outcome disclose it.
func (*Report) StepsByCategory ¶ added in v0.13.0
StepsByCategory returns the steps grouped in Appendix E.22's category display order, each category's rows in emission order.
type Status ¶
type Status int
Status represents the outcome of a verification step (Appendix E.22). Only `fail` fails a proof: a warn is something worth knowing that is not a defect, a skip is a check that did not run, an info is a recorded value carrying no judgement.
func StatusFromString ¶
StatusFromString parses a status string. Returns an error for unknown values, and StatusFail alongside it so a caller that ignores the error still fails closed.
func (Status) Badge ¶ added in v0.13.0
Badge returns the bracketed badge the reference verifier prints.
func (Status) MarshalJSON ¶
MarshalJSON encodes a Status as a JSON string.
func (*Status) UnmarshalJSON ¶
UnmarshalJSON decodes a JSON string into a Status. A string outside the five-value vocabulary is an error, not a value: E.22's verdict rule ("a proof passes when no step is fail") only holds when every status is known, so a status this verifier cannot read is handled by Step.UnmarshalJSON, which grades it fail and discloses it.
type Step ¶
type Step struct {
Group string `json:"group"`
Status Status `json:"status"`
Category string `json:"category"`
Message string `json:"message"`
}
Step is a single verification result.
func (*Step) UnmarshalJSON ¶ added in v0.12.0
UnmarshalJSON decodes a step supplied by a remote verifier, failing closed on any status this verifier cannot read as one of Appendix E.22's five: an absent status key or an unknown word is graded fail and says so in its own message, so a server-reported outcome can never be scored as a pass by accident.
type StepCounts ¶
StepCounts holds all step status counts computed in a single pass.
type Temporal ¶ added in v0.13.0
type Temporal struct {
SubmittedAt string `json:"submitted_at,omitempty"`
CommittedAt string `json:"committed_at,omitempty"`
StellarCommit string `json:"stellar_commit,omitempty"`
BitcoinCommit string `json:"bitcoin_commit,omitempty"`
}
Temporal carries the submission window's recorded instants, in the server's field names so a CLI report and an API report are directly comparable. Every value is ISO 8601 at whole-second precision.