verifier

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 28 Imported by: 0 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 verifier is the CLI's verifier of SPEC.md section 10 (The verification algorithm), built from SPEC.md and its conformance vectors (section 13.2 (The vectors)), each file naming the sections of SPEC.md it implements.

It holds steps 0 to 6 of SPEC.md section 10.2 (Steps), the gate. Steps 0 to 3 decide whether a run gives a report at all: CONFIGURATION, which fixes E_v, the network pins and the keyring that governs key binding before the file is read; READ (J1); PARSE (J2 to J6); and ENVELOPE, the envelope of section 3.1. A failure at any of them is a bare rejection, a *Rejection; a run that passes them is a *Run with one pass row of each step, part null. Steps 4 to 6 add one row each: ENVIRONMENT, the marker of section 6.4 against E_v; KEY_BINDING, K against the keyring that governs, all 32 octets compared (section 6.1); and SIGNATURE, V under K over proof_hash by the strict rule of section 6.2. A failure at any of them ends the run with the attribution none; a run that passes them carries its attribution and trust_root (section 10.5). Past the gate it holds step 7, SHAPE: format, version, the schema of spec/schema.json, through the package's own interpreter of SPEC.md section 9's keyword subset, and the three checks the schema cannot make, the witnesses of an item, the TIME and NISTTIME round trips and the constructions digest; a failure ends the run, and a pass gives the run its type and subject id. Then step 8, POLICY: every network member of the proof against the run's network pins, one row each; a failure there does not end the run. Then step 9, DERIVE: every record hash of the subject, the block nodes and the epochs recomputed and compared, each key event a block node carries checked as the table of section 3.3 requires, every inclusion proof walked from its recomputed leaf, its tree_size held to its record's committed leaf_count, and the other links of section 10.3, LINK_WITNESS, LINK_HEAD, LINK_KEY_EVENT and LINK_CHAIN_ORDER, through one engine that gives the step's rows and the run's trace (SPEC.md section 10.6); a failure there does not end the run either, and LINK_KEY_EVENT's info row under an attribution other than truestamp is no failure. When DERIVE ends, the run takes its external gate, open only when the caller did not ask for an offline run and no row has failed. Then step 10, CHAIN, and step 11, SOURCES: under a closed gate, each commitment entry, genesis.bitcoin and entropy object gets its row skip offline or skip prior_failure, and KEY_EVENT_COMMITMENT ends CHAIN. Under an open gate CHAIN reads each Stellar and Bitcoin commitment entry and each genesis.bitcoin by its rule of section 10.4, through source_outcomes.go's frame, made once for each source of its network and combined under the network's source policy, keeps each passing row's candidate for WINDOW and ends with KEY_EVENT_COMMITMENT; SOURCES reads each entropy object whose entropy_hash matched at DERIVE by its source's rule of section 10.4, from the sources of the run's entropy pin, through the same frame, and keeps each passing row's candidate for WINDOW. Then step 12, WINDOW, which draws the submitted-before and submitted-after edges from those candidates and gives its rows of section 11.3, and which a closed gate leaves not established; step 13, EXPECTED_HASH; and step 14, VERDICT, the label and the run's code of section 10.5. A run that passes steps 0 to 3 then gives its report, with exactly the members of section 10.5, and a bare rejection gives only {code, message, sub_reason}.

  • config.go: a run's Config, what step 0 fixes (section 10.2);
  • options.go: the options of `truestamp verify` that set a Config, which only the run's own options may set (sections 6.4 and 8.3);
  • gate.go: the steps (section 10.2, the gate);
  • keyring_read.go: the online keyring read of step 0, of the keyring that governs an external verifier's online run by default (section 8.3);
  • sources.go: the rest of step 0 for the sources: each network's source policy, held to its number of sources in every run, and in an online run which Stellar and Bitcoin sources serve each network pin, in what order, and each source's identity, confirmed both ways before the file is read (sections 9 and 10.2, step 0), through the readers of internal/verifier/source;
  • shape.go: step 7, SHAPE, whose check 5 parses each time through time.go, the classes TIME and NISTTIME (section 2.4);
  • policy.go: step 8, POLICY;
  • derive.go: step 9, DERIVE, and its one engine (section 10.6), whose checks are derive_check.go's: the record hashes of derive_records.go (step 9 (a) to (c)), the key events of derive_key_events.go and the links of derive_links.go (section 10.3);
  • external.go: the external gate, and steps 10 and 11, CHAIN and SOURCES, under a closed gate (sections 10.2, 10.3 and 10.4);
  • chain.go: CHAIN under an open gate, KEY_EVENT_COMMITMENT's statuses from its inputs, and the ChainReader its reads go through (sections 10.3 and 10.4); chain_stellar.go: the rule of a Stellar commitment entry, and chain_bitcoin.go: the rule of a Bitcoin commitment entry and of genesis.bitcoin (sections 10.4 and 11.1);
  • entropy.go: SOURCES under an open gate, the rule of each entropy object, NIST's, Stellar's and Bitcoin's (sections 10.4 and 11.2);
  • source_outcomes.go: the frame a CHAIN or SOURCES row read under an open gate runs through: each source's outcome, their combination under the source policy, and the row's values (section 10.4);
  • window.go: step 12, WINDOW, its rows and its two edge objects (sections 11.1 to 11.3 and 11.5);
  • expected_hash.go: step 13, EXPECTED_HASH;
  • verdict.go: step 14, VERDICT's label and the run's code (section 10.5);
  • report.go: the report of section 10.5, with exactly its members, both edges null when the label is failed (section 10.2, step 14);
  • outcome.go: Verify, every step over one document, as `truestamp verify` runs them, and how the run ended, which decides its exit code (section 12.2), a fault caught in a step included (section 10.5); fault_tag.go, built only with the tag truestamp_fault, raises a fault in a test binary;
  • schema.go: the checker of spec/schema.json, SHAPE's check 3, which refuses a schema outside SPEC.md section 9's subset when it loads;
  • inspect.go: Inspect, what `truestamp inspect` reads of a proof without verifying it: steps 1 to 3 and SHAPE, proof_hash, K's key id, and each member the proof carries by its value class, a CHECKED value beside what DERIVE's traced checks recompute for it and a time only as declared (sections 3.7, 10.2, 10.6, 11 and 11.5);
  • layout.go: where the proof holds its block nodes, commitment entries, entropy objects and genesis.bitcoin objects, and the value at a pointer into it (sections 3.3 to 3.6);
  • run.go, row.go, rejection.go and pointer.go: the run's state, its rows, the bare rejection and JSON Pointers into the proof (sections 10.2 and 10.5).

The keyring, its load checks and its digest are internal/verifier/keyring, and the checks of a key's bytes and strict Ed25519 are internal/verifier/ed25519.

An online run's sources are the compiled-in defaults of its pinned networks (none for regtest), the Horizon, Esplora and Bitcoin Core servers the operator pins, and the several sources the operator configures for a network, in an order, under a source policy (SPEC.md section 9); the document never chooses one, nor a policy. Each source's identity read goes through Config.ReadIdentity, and one with no usable answer is recorded unreachable, so nothing else is read from it; every other read of a source goes through Config.ReadChain. NIST's Randomness Beacon is one source, at its compiled-in address, with no identity read, and no configuration names another. That address and the address of Truestamp's keyring are string variables only so that the cmd package's test binary can set them at link time; no option reaches either.

The CLI is an external verifier (SPEC.md section 8.3). Online, under E_v prod and with no supplied keyring, the keyring read from www.truestamp.com governs; such a read, and the read of a keyring from the origin an explicit --base-url names, go through Config.ReadKeyring, and a read that does not give a keyring passing the load checks binds no key, whatever the compiled pin holds. Offline, under prod, the compiled pin governs.

Index

Constants

View Source
const (
	DeclaredTIME     = "TIME"
	DeclaredNISTTIME = "NISTTIME"
	// DeclaredUnixSeconds is a Bitcoin entropy object's time, an INT
	// counting seconds.
	DeclaredUnixSeconds = "INT"
)

The classes of a time a proof carries (SPEC.md sections 2.4 and 3.5).

View Source
const (
	FlagEnvironment = "environment"
	FlagKeyring     = "keyring"
	FlagNoKeyring   = "no-keyring"
	FlagBaseURL     = "base-url"
	FlagHorizon     = "horizon"
	FlagEsplora     = "esplora"
	FlagBitcoinCore = "bitcoin-core"
)

The flags of `truestamp verify` that set a run's keyring, environment and sources, and the root flag whose explicit use moves the keyring read.

View Source
const (
	WindowEstablished    = "established"
	WindowNotEstablished = "not_established"
)

The values of a report's window (SPEC.md section 10.5).

View Source
const (
	AttributionTruestamp    = "truestamp"
	AttributionUnattributed = "unattributed"
	AttributionNone         = "none"
)

The attributions of SPEC.md section 10.5 that name no keyring; a supplied keyring's is "keyring:" and its digest.

View Source
const (
	ConstructionsFull      = "full"
	ConstructionsReference = "reference"
	ConstructionsNone      = "none"
)

The modes of the constructions member (SPEC.md section 7.2), as check 6 tells them by the member's JSON type.

View Source
const (
	// ProductionPassphrase is the network passphrase of Stellar's
	// production network, public.
	ProductionPassphrase = "Public Global Stellar Network ; September 2015"
	// ProductionGenesisHash is the hash of the block at height 0 of
	// Bitcoin's production network, mainnet.
	ProductionGenesisHash = "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
)

The production values of the identity checks (SPEC.md section 10.2, step 0). No test network's value is pinned.

View Source
const (
	PinCommitment = "commitment"
	PinEntropy    = "entropy"
)

The two kinds of network pin (SPEC.md section 9).

View Source
const (
	ChainBitcoin = "bitcoin"
	ChainStellar = "stellar"
)

The chains a source serves.

View Source
const (
	LabelFailed               = "failed"
	LabelUnattributed         = "unattributed"
	LabelSuppliedKeyring      = "supplied-keyring"
	LabelInternallyConsistent = "internally-consistent"
	LabelVerified             = "verified"
)

The labels of SPEC.md section 10.5.

View Source
const Alg = "truestamp-ed25519-sha256-jcs"

Alg is the literal signature.alg must equal (SPEC.md section 3.1). It is compared, and never selects behavior.

View Source
const CurrentKeyringURL = "https://www.truestamp.com/.well-known/keyring.json"

CurrentKeyringURL is where an external verifier reads Truestamp's keyring online (SPEC.md section 8.3).

View Source
const Format = "truestamp-proof"

Format is the literal P's format must equal (SPEC.md section 3.2).

View Source
const KeyringReadDeadline = 9 * time.Second

KeyringReadDeadline bounds each online keyring read, the whole read, as the Truestamp application bounds each of its verification reads.

View Source
const NISTBeaconURL = "https://beacon.nist.gov/beacon/2.0"

NISTBeaconURL is the base of NIST's Randomness Beacon 2.0 API, the one address the NIST read goes to (SPEC.md section 10.4, "Common sources").

View Source
const SourceNIST = "nist"

SourceNIST is the name of the NIST entropy source (SPEC.md section 3.5).

View Source
const SourceReadDeadline = 9 * time.Second

SourceReadDeadline bounds each identity read and each chain read of DefaultChainReader, the whole read, every call it makes included (a best-chain block at a height takes two calls, which end within it together), as the Truestamp application bounds each of its verification reads.

View Source
const Version = 1

Version is the one version this verifier reads (SPEC.md section 3.2).

Variables

View Source
var (
	ErrTimePattern   = errors.New("the value does not match the pattern of its class")
	ErrTimeRoundTrip = errors.New("the value does not write back to itself")
)

The ways a string can fail its class: ErrTimePattern when it does not match the class's pattern in full, and ErrTimeRoundTrip when it matches but does not format back to itself.

View Source
var ErrFault = errors.New("the verifier stopped on a fault")

ErrFault marks a fault of the verifier that left no report (SPEC.md section 12.2, exit code 2).

View Source
var ErrInvalidConfig = errors.New("invalid verifier configuration")

ErrInvalidConfig marks a configuration no run can take, such as an environment that is not an E_v, or two keyring sources. It is an invalid command line (exit code 1, SPEC.md section 12.2), not a verification result.

View Source
var ErrSchemaOutsideSubset = errors.New("a schema outside SPEC.md section 9's subset")

ErrSchemaOutsideSubset is the error LoadSchema wraps when it refuses a schema.

Functions

func Admit

func Admit(cfg Config, data []byte) (*Run, *Rejection, error)

Admit makes steps 0 to 3 over the bytes of a document: the run when each passes, so it has a report to hold its rows (SPEC.md section 10.5), or a bare rejection, or an error for a configuration no run can take or a keyring file that cannot be read.

func AdmitFile

func AdmitFile(cfg Config, path string) (*Run, *Rejection, error)

AdmitFile makes steps 0 to 3 over the file at path: CONFIGURATION first, then the file is read, at most MAX_READ_OCTETS + 1 octets of it (SPEC.md section 10.1, J1).

func Chain

func Chain(run *Run)

Chain is step 10, CHAIN (see the file's doc).

func Compare

func Compare(a, b Pointer) int

Compare gives the document order of a and b: -1 when a comes first, 0 when they are one pointer, and +1 when b comes first.

func Configure

func Configure(cfg Config) (*Run, *Rejection, error)

Configure is step 0, CONFIGURATION: it fixes E_v, the pins and the keyring that governs, before the file is read, and adds its row. The keyring source decides the keyring (SPEC.md sections 6.4 and 8.3):

  • keyless mode: no keyring governs, under any E_v;
  • none asked for, under E_v prod: offline, the compiled pin, loaded through the load checks under prod; online, the keyring read from www.truestamp.com;
  • none asked for, under any other E_v: configuration_error, since such a run must not use the compiled pin or the keyring at www.truestamp.com;
  • a keyring file or a configured keyring: read, and loaded through the load checks under E_v, so under prod it is a production keyring; a file over MAX_READ_OCTETS or a failed check is configuration_error, and a file that cannot be read at all is an error;
  • the keyring read from the origin an explicit --base-url names: read online, as from www.truestamp.com.

A keyring read online that does not give a keyring passing the load checks, for any reason, is no rejection: the run holds no keyring and KeyringUnavailable, so no key binds.

Before any read, in every run, a network's source policy at_least n whose n is 0 or above the number of its sources is configuration_error (sources.go). An online run then confirms each Stellar and Bitcoin source's identity (sources.go): a source whose identity contradicts the network it serves, whatever the policy and the network's other sources give, and a pinned network with no source are each configuration_error, and the run holds every other source's outcome, confirmed or unreachable, with the pins it serves, and each pinned network's sources in their order under its policy. A source configured for no network whose answer only pinned networks with a configuration allow serves nothing. Of two sources configured for no network that may serve one pin, whether both answer and show its network or both give no usable answer, the first in the options' order serves it and the other does not. An offline run reads no source.

func Derive

func Derive(run *Run)

Derive is step 9, DERIVE: every recomputation and every link, with the run's trace (see the file's doc).

func EnvelopeChecks

func EnvelopeChecks() []specdata.SubReason

EnvelopeChecks returns the checks of ENVELOPE, in the order step 3 makes them, by their sub_reason.

func Environment

func Environment(run *Run)

Environment is step 4, ENVIRONMENT: the check of SPEC.md section 6.4, one row at /environment. Under E_v prod the member is absent; under any other E_v it is present, a string, and equal to E_v. Anything else is environment_mismatch, and the run ends. The row's values hold E_v, and on a failure the marker the proof declared, whatever JSON value it is, when it carries one (section 10.5); the message never quotes it ([environmentMessage]).

func ExpectedHash

func ExpectedHash(run *Run)

ExpectedHash is step 13, EXPECTED_HASH (see the file's doc).

func FirstBy

func FirstBy[T any](list []T, part func(T) Pointer) (T, bool)

FirstBy returns the element of list whose pointer, as part gives it, comes first in document order, the earliest in list among equals, and false when list is empty.

func FormatTime

func FormatTime(class TimeClass, instant int64) (string, bool)

FormatTime returns instant written in the pattern of class: instant is Unix seconds for TIME and Unix milliseconds for NISTTIME. It gives false for an instant outside the years 0000 to 9999, which the pattern cannot write.

func Gate

func Gate(cfg Config, data []byte) (*Run, *Rejection, error)

Gate makes steps 0 to 6 over the bytes of a document: Admit, then ENVIRONMENT, KEY_BINDING and SIGNATURE over the run it gives. A run whose gate failed has ended, with the attribution none; a run that passed it carries its attribution.

func GateFile

func GateFile(cfg Config, path string) (*Run, *Rejection, error)

GateFile makes steps 0 to 6 over the file at path, which AdmitFile reads only after CONFIGURATION.

func KeyBinding

func KeyBinding(run *Run)

KeyBinding is step 5, KEY_BINDING: the check of SPEC.md section 6.1, item 1, one row with part null, against the keyring that governs. The run looks for a key of that keyring whose 32 octets equal the 32 octets K decodes to, active or not, and reads no key id the proof carries: K's key id is only the row's value. Found, the row passes and the run holds the key; not found, it fails key_binding_failed. When the keyring that would govern could not be read online, the row fails keyring_unavailable whatever K is (section 8.3). In keyless mode the row is skip key_binding_not_performed. A failure ends the run.

func KeyID

func KeyID(key [32]byte) string

KeyID returns the key id of the 32-octet public key key, the hex of the first 4 bytes of SHA-256(0x60 || its 32 bytes) (SPEC.md section 3.3), as 8 lowercase hex characters: the id `convert keyid` prints and the one Inspection gives the signer.

func ParseTime

func ParseTime(class TimeClass, value any) (int64, error)

ParseTime returns the instant value names, a string of class: Unix seconds for TIME, Unix milliseconds for NISTTIME. It gives ErrTimePattern for a value that is not a string, or one that does not match the class's pattern in full, and ErrTimeRoundTrip for one that matches but does not format back to itself.

func Part

func Part(pointer string) *string

Part returns pointer as a row's part: a JSON Pointer that is not null.

func Policy

func Policy(run *Run)

Policy is step 8, POLICY: one row for each network of P, against the run's pins (see the file's doc).

func RegisterFlags

func RegisterFlags(flags *pflag.FlagSet)

RegisterFlags adds to flags --environment and --no-keyring, the two run options only a run may set (SPEC.md sections 6.4 and 8.3), neither of them a config key, and --horizon, --esplora and --bitcoin-core, the sources the operator pins (section 9), which internal/config also reads from the configuration file and the environment. No flag takes a Bitcoin Core node's RPC credentials.

func SchemaKeywords

func SchemaKeywords() []string

SchemaKeywords returns the keywords a schema may use (SPEC.md section 9), in that section's order. Each call returns a new slice.

func Shape

func Shape(run *Run)

Shape is step 7, SHAPE: checks 1 to 6, in order, on the run's P (see the file's doc).

func Signature

func Signature(run *Run)

Signature is step 6, SIGNATURE: the check of SPEC.md section 6.1, item 2, one row with part null. The run computes proof_hash = SHA-256(0x50 || JCS(P)) itself, from P as parsed, through internal/registry, and checks V under K over its 32 octets by the strict rule of section 6.2 (internal/verifier/ed25519's Verify), else signature_invalid, and the run ends. The row's values hold proof_hash as hex, and on a failure the step of section 6.2 that refused. When it passes, the run takes its attribution. A proof_hash that cannot be computed is a fault of the verifier: a fail row internal_error, and the run ends (section 10.5).

func SortBy

func SortBy[T any](list []T, part func(T) Pointer)

SortBy sorts list into the document order of the pointer part gives for each element. The sort is stable, so elements at one pointer keep their order.

func Sources

func Sources(run *Run)

Sources is step 11, SOURCES (see the file's doc).

func Steps

func Steps() []string

Steps returns the steps of SPEC.md section 10.2, 0 to 14, by name, in order. Each call returns a new slice.

func TimePattern

func TimePattern(class TimeClass) string

TimePattern returns the pattern of class, written bare as in SPEC.md section 2.4.

func Verdict

func Verdict(run *Run)

Verdict is step 14, VERDICT: the run's label and, when it is failed, its code (see the file's doc).

func Window

func Window(run *Run)

Window is step 12, WINDOW (see the file's doc).

Types

type AskedSource

type AskedSource struct {
	Source  SourceRecord
	Outcome SourceOutcome
	Place   int
	Count   int
}

AskedSource is one source a row asked, and its outcome: Place, its place in its network's order, from 1, and Count, the number of that network's sources, which a source shown by its scheme, host and port alone is told apart by (SPEC.md sections 10.4 and 11.5).

type Candidate

type Candidate struct {
	Basis     string
	Class     TimeClass
	Instant   int64
	FetchedAt time.Time
}

Candidate is a candidate for an edge (SPEC.md sections 11.1, 11.2 and 11.5): Basis, stellar_ledger_close_read, bitcoin_median_time_read or nist_pulse_time_read; Instant, at its source's precision, in Class's unit: Unix seconds for TIME (Stellar and Bitcoin) and Unix milliseconds for NISTTIME (NIST); and FetchedAt, when the read that gave it came back.

func (Candidate) Milliseconds

func (c Candidate) Milliseconds() int64

Milliseconds is the candidate's instant in Unix milliseconds, so two candidates compare as instants (SPEC.md section 11.3).

type ChainReader

type ChainReader func(source Source, read map[string]any) SourceRead

ChainReader makes one read of CHAIN or SOURCES of a source, live (SPEC.md section 10.4): read names it as a replay record does, {kind, network for a Stellar or Bitcoin read, ...} (section 13.2), and the reader gives its Outcome, with Value, the fields of a found answer, and Reason, for an unreachable one, which never names the source's URL. It is the seam every such read goes through: DefaultChainReader reads over HTTP, and a conformance test answers from a case's replay file. Run.ReadSource sets the answer's Read and FetchedAt.

func DefaultChainReader

func DefaultChainReader() ChainReader

DefaultChainReader returns the reader of each chain read over HTTP, through the default transport and internal/verifier/source's readers: each read builds its own SingleRead, within SourceReadDeadline, when it is made, and the whole read ends within that deadline, every call it makes included (a best-chain block at a height takes two calls); a Bitcoin Core node's reads send the source's credentials, which reach no reason and no value.

type CombinedOutcome

type CombinedOutcome struct {
	Status    Status
	Code      specdata.Reason
	Candidate *Candidate
	Counted   []AskedSource
	Policy    SourcePolicy
	Required  int
	Asked     []AskedSource
}

CombinedOutcome is a row's outcome from its network's sources (see the file's doc): its Status and Code, Code "" exactly when Status is pass; its Candidate, the one its counted sources share, when it passed with one; Counted, the sources that candidate, or the pass, rests on; Policy and Required, the policy's n; and Asked, each source the row asked, in the order of the network's sources.

func CombineSources

func CombineSources(set SourceSet, rule RowRule) CombinedOutcome

CombineSources makes rule once for each source of set the policy asks, in the set's order, and combines their outcomes under the set's policy (see the file's doc). A source whose identity read got no usable answer is skip source_unreachable, with no read, and rule is not made for it. It panics for a set with no source, which no network an online run pins has once CONFIGURATION passes, and for an outcome rule gives that no rule of section 10.4 gives: defects in the caller.

func (CombinedOutcome) Row

func (c CombinedOutcome) Row(step string, part Pointer, message string) Row

Row is the combined outcome as the row of step at part, with message and CombinedOutcome.Values.

func (CombinedOutcome) Values

func (c CombinedOutcome) Values() map[string]any

Values are the row's values: what it read (see the file's doc).

type Config

type Config struct {
	// Environment is E_v (SPEC.md section 6.4): prod, or an ENV value.
	Environment string
	// Keyring is the keyring source.
	Keyring KeyringSource
	// Networks are the network pins (SPEC.md section 9), which POLICY
	// compares every network of the proof with: the row of
	// spec/network-pins.json for E_v, which [NewConfig] sets and nothing a
	// user gives replaces, since no flag, configuration key or environment
	// variable reaches this member ([Options.Config] starts from
	// NewConfig). It is also the conformance seam: a conformance test sets
	// it to a case's networks (SPEC.md section 13.2), which in some cases
	// differ from the defaults of the case's E_v.
	Networks specdata.NetworkPins
	// Online says whether the run reads outside the document.
	Online bool
	// ReadKeyring reads a keyring online. A nil reader reads nothing, so an
	// online keyring read through it fails and binds no key.
	ReadKeyring KeyringReader
	// Sources are the Stellar and Bitcoin sources the operator gives for
	// no network, at most one of each provider in the command's options,
	// in the order of those options, each in place of the compiled-in
	// default of the pinned networks with no configuration that its
	// identity read shows it serves (SPEC.md section 9); one whose answer
	// only networks with a configuration allow serves nothing. Each has
	// Network "".
	Sources []Source
	// NetworkSources are the operator's configurations of a network's
	// several sources, at most one for each network, each with its
	// sources in order and its source policy (SPEC.md section 9, "Several
	// sources for one network"). A pinned network with one serves no other
	// source and reads no default. No document sets any.
	NetworkSources []NetworkSources
	// ReadIdentity reads a source's identity in an online run. A nil
	// reader reads nothing, so each source gives no usable answer.
	ReadIdentity IdentityReader
	// ReadChain makes the reads CHAIN and SOURCES make of a source whose
	// identity was confirmed, and of NIST's Randomness Beacon, which has no
	// identity read (SPEC.md section 10.4). A nil reader reads nothing, so
	// each such read gives no usable answer.
	ReadChain ChainReader
	// ExpectedHash is the caller's hash for step EXPECTED_HASH (SPEC.md
	// section 10.2, step 13), as the caller gave it, or nil when none is
	// given. Any string is taken: one that is not hex of the claims'
	// hash_type's length is that step's failing row, not an invalid
	// configuration.
	ExpectedHash *string
}

Config is a run's configuration (SPEC.md section 10.2, step 0). E_v, keyless mode and --keyring FILE come only from the run's options (sections 6.4 and 8.3). A configured keyring comes from the configuration file, one for each non-production environment, and is used only when --environment names it. Whether the run is offline, and the sources the operator pins, may also come from the configuration file or an environment variable, and a Bitcoin Core node's RPC credentials come only from one of those two (section 9). The network pins are the defaults of E_v (section 9); no option sets them, and only a conformance test replaces them with a case's. No document sets any member.

func NewConfig

func NewConfig(environment string) (Config, error)

NewConfig returns the configuration of an offline run under E_v environment, with no keyring option and the default pins of that E_v, or an error wrapping ErrInvalidConfig when environment is not an E_v.

func (Config) Validate

func (c Config) Validate() error

Validate reports a configuration no run can take, wrapping ErrInvalidConfig: an environment that is not an E_v, a pin that names no network of its chain, a keyring source without its file or URL, a keyring read online in an offline run, a source whose provider is not one of its chain's, whose URL source.CheckURL refuses or whose host is neither an IP address nor a valid DNS name, that names a network not of its chain, or that carries credentials and is not a Bitcoin Core node, a source of Config.Sources that names a network, a network configuration [checkNetworkSources] refuses, and two configurations of one network. No error quotes a source's URL.

type Constructions

type Constructions struct {
	Mode   string
	Digest string
}

Constructions is what check 6 found: Mode, one of ConstructionsFull, ConstructionsReference and ConstructionsNone; and Digest, in full mode the d this run computed of the text, and "" in the other modes, whose d, where there is one, is the proof's.

type DeclaredTime

type DeclaredTime struct {
	Part  string
	Class string
	Value any
}

DeclaredTime is one time P carries: its pointer, its class and the value as P carries it, a string or a strictjson.Number.

type Edge

type Edge struct {
	Assumption string
	Candidate  Candidate
	Part       string
	Sources    []EdgeSource
}

Edge is an edge of the submission window (SPEC.md section 11.5): the Candidate that gave it, its stated Assumption, the Part of the CHAIN or SOURCES row whose read gave it, and Sources, the sources it rests on, in the order of their network's sources, never empty.

func (Edge) Value

func (e Edge) Value() map[string]any

Value is the edge as a report writes it, {assumption, basis, cached, fetched_at, instant, part, source, sources} (SPEC.md section 11.5): cached, fetched_at and source are those of the first of sources, and instant is written at its source's precision, as a TIME for Stellar and Bitcoin and as a NISTTIME for NIST.

type EdgeSource

type EdgeSource struct {
	Source    string
	Cached    bool
	FetchedAt time.Time
	Place     int
	Count     int
}

EdgeSource is one source an edge rests on, with its read that gave the candidate: Source, the source as a report names it, scheme://host[:port] ([printedURL], the form SPEC.md sections 10.4 and 11.5 let it take); Cached, whether that read's answer came from a cache, always false, since the CLI caches nothing; FetchedAt, when that read came back; and Place, its place in its network's order, from 1, and Count, the number of that network's sources. The edge's text names the place when Count is above one, as SPEC.md section 11.5 asks of a source shown in that form; the edge object has no member for it.

type ExternalGate

type ExternalGate string

ExternalGate is the external gate of SPEC.md section 10.2, as DERIVE's end decides it.

const (
	// ExternalGateOpen: CHAIN and SOURCES read.
	ExternalGateOpen ExternalGate = "open"
	// ExternalGateOffline: closed, since the caller asked for an offline
	// run and no row failed; each row of CHAIN and SOURCES is skip offline.
	ExternalGateOffline ExternalGate = "offline"
	// ExternalGatePriorFailure: closed, since a row before CHAIN failed;
	// each row of CHAIN and SOURCES is skip prior_failure.
	ExternalGatePriorFailure ExternalGate = "prior_failure"
)

The external gate's states.

type IdentityReader

type IdentityReader func(Source) (string, error)

IdentityReader reads a source's identity live (SPEC.md section 10.2, step 0): Stellar's network passphrase, or the hash of Bitcoin's block at height 0, or an error for a read with no usable answer. It is the seam every identity read goes through: DefaultIdentityReader reads over HTTP, and a conformance test answers from a case's replay file.

func DefaultIdentityReader

func DefaultIdentityReader() IdentityReader

DefaultIdentityReader returns the reader of each source's identity over HTTP, through the default transport: each read builds its own SingleRead, within SourceReadDeadline, when it is made.

type Inspection

type Inspection struct {
	// Rejection is the bare rejection of READ, PARSE or ENVELOPE, and nil
	// when they pass; every other member is then zero.
	Rejection *Rejection
	// Refusal is SHAPE's failing row, and nil when SHAPE passes.
	Refusal *Row
	// Document is the parsed document and Proof is P, its proof member;
	// set when ENVELOPE passes.
	Document map[string]any
	Proof    map[string]any
	// KeyID is the key id of K and ProofHash is proof_hash as hex, both
	// computed here; set when ENVELOPE passes.
	KeyID     string
	ProofHash string
	// Type, SubjectID and Constructions are what SHAPE gave the run; set
	// when SHAPE passes.
	Type          string
	SubjectID     string
	Constructions Constructions
	// Carried, ClaimsMembers, Recomputed, DeclaredTimes and Recorded are
	// the members of P by their classes (see the file's doc), each list in
	// the document order of its parts; set when SHAPE passes.
	Carried       map[string]any
	ClaimsMembers []string
	Recomputed    []Recomputed
	DeclaredTimes []DeclaredTime
	Recorded      []Recorded
}

Inspection is a document as `truestamp inspect` reads it (see the file's doc).

func Inspect

func Inspect(data []byte) (*Inspection, error)

Inspect reads data as `truestamp inspect` does (see the file's doc). It gives an error only for a fault: a proof_hash or a DERIVE value that cannot be computed over a value the strict reader and SHAPE passed.

type KeyringRead

type KeyringRead struct {
	// Bytes are the keyring's bytes as read, when Replayed is false.
	Bytes []byte
	// Replayed says the answer is Value, with no bytes.
	Replayed bool
	// Value is the replayed keyring, when Replayed is true.
	Value any
}

KeyringRead is what an online keyring read gives: the keyring's bytes as read, which load under SPEC.md section 10.1 and give trust_root its digest d (section 8.3); or, from a conformance case's replay file (section 13.2 (The vectors)), Replayed and the keyring as Value, a value the replay's own reader already read under section 10.1, which has no bytes of its own, so trust_root's digest is null (section 10.5).

type KeyringReader

type KeyringReader func(url string) (KeyringRead, error)

KeyringReader reads the keyring at url online, or gives an error for a read that gave no keyring (a transport failure, an HTTP error, a redirect, a host that is not a valid DNS name, an unreachable answer in a replay). It is the seam every online keyring read goes through: NewKeyringReader reads over HTTP, and a conformance test answers from a case's replay file.

func DefaultKeyringReader

func DefaultKeyringReader() KeyringReader

DefaultKeyringReader returns the reader of an online run's keyring over HTTP, through the default transport, each read within KeyringReadDeadline.

func NewKeyringReader

func NewKeyringReader(reads *httpclient.SingleRead) KeyringReader

NewKeyringReader returns the reader of an online run's keyring through reads: a URL whose host is not a valid DNS name or IP address, or whose scheme is not http or https, is refused before any request; otherwise one GET with no redirect followed, within the reader's deadline, whose 200 OK body of at most MAX_READ_OCTETS octets is the keyring's bytes as read.

type KeyringSource

type KeyringSource struct {
	Kind SourceKind
	// Path is the keyring file, for SourceFile and SourceConfigured.
	Path string
	// URL is the keyring's URL, for SourceOrigin.
	URL string
}

KeyringSource is the keyring a run asks for.

type NetworkSources

type NetworkSources struct {
	Chain   string
	Network string
	Policy  SourcePolicy
	Sources []Source
}

NetworkSources is the operator's configuration of one Stellar or Bitcoin network's sources (SPEC.md section 9, "Several sources for one network"): the chain and network, the policy, and the sources, one or more, in the order the operator gives them, each configured for that network. Each has its own identity read, held to that network (SPEC.md section 10.2, step 0). NIST's Randomness Beacon is one source, so no configuration names it.

type Options

type Options struct {
	// Environment is the run's --environment, or prod when none is given.
	Environment string
	// KeyringFile is the run's --keyring FILE, or "".
	KeyringFile string
	// NoKeyring is the run's --no-keyring.
	NoKeyring bool
	// OriginKeyringURL is the keyring URL of the origin an explicit
	// --base-url names, or "" when the run was given none.
	OriginKeyringURL string
	// Offline says the run reads nothing outside the document.
	Offline bool
	// Configured are the configured keyrings, by environment.
	Configured config.KeyringsConfig
	// Horizon, Esplora and BitcoinCore are the URLs of the sources the
	// operator pins, each "" when none is given.
	Horizon, Esplora, BitcoinCore string
	// BitcoinCoreCredentials are the Bitcoin Core node's RPC credentials,
	// from the configuration file or the environment; they print masked.
	BitcoinCoreCredentials source.Credentials
	// NetworkSources are the operator's configurations of a network's
	// several sources, each with its sources in order and its source
	// policy (SPEC.md section 9), which [Options.Config] gives the run as
	// [Config.NetworkSources]. [OptionsFromCommand] reads them from the
	// configuration file's verify.sources tables, in the order of chain
	// and then network names.
	NetworkSources []NetworkSources
}

Options are the options of one run of `truestamp verify` that decide its Config.

func OptionsFromCommand

func OptionsFromCommand(flags *pflag.FlagSet, cfg *config.Config) (Options, error)

OptionsFromCommand reads a run's options from the flags of the command that runs it and from the resolved configuration, which config.Load resolved with those flags. Only the flags given for the run are read for E_v, the keyring file, keyless mode and the keyring's origin; cfg gives the configured keyrings, the offline flag, the keyring URL an explicit --base-url composes, the sources' URLs (a flag over an environment variable over the configuration file) and the Bitcoin Core node's RPC credentials (an environment variable over the configuration file), and each network's several sources and policy (the configuration file alone, [networkSourcesOf]). A flag the command does not register is read as not given.

func (Options) Config

func (o Options) Config(keyrings KeyringReader, identities IdentityReader) (Config, error)

Config returns the run's configuration, with keyrings for its online keyring reads, identities for its sources' identity reads and DefaultChainReader for the reads CHAIN and SOURCES make, or an error wrapping ErrInvalidConfig for an environment that is not an E_v, for --keyring with --no-keyring, or for a source URL Config.Validate refuses, one carrying user information among them, whose error names the option and never quotes the URL, or for a network configuration Config.Validate refuses. Each source of Horizon, Esplora and BitcoinCore is one the operator pins for no network: when it answers its identity read, it serves only the pins of its chain of networks with no configuration that the answer shows, so one whose answer fits only configured networks serves nothing. Each of NetworkSources keeps its order and policy, its sources copied so that the run holds its own. The keyring source is the first of these the options give:

  1. --no-keyring: keyless mode;
  2. --keyring FILE;
  3. online, an explicit --base-url whose host is not www.truestamp.com: the keyring read from that origin;
  4. under a non-production E_v, the configured keyring of that environment;
  5. none: under prod, the keyring read from www.truestamp.com online and the compiled pin offline; under any other E_v, configuration_error at CONFIGURATION.

An offline run reads no keyring, so an explicit --base-url gives an offline run no keyring source. Nor does one whose host is www.truestamp.com, under any scheme or port: its keyring is Truestamp's, which a run under E_v prod reads as the default and a run under a non-production E_v must not use (SPEC.md section 6.4).

type Outcome

type Outcome struct {
	// Ending is the row of SPEC.md section 12.2 the run ended on.
	Ending specdata.Ending
	// Report is the run's report, for a run VERDICT labelled; nil
	// otherwise.
	Report *Report
	// Rejection is the bare rejection, for a run that ended at steps 0 to
	// 3; nil otherwise.
	Rejection *Rejection
	// Trace is the run's trace (SPEC.md section 10.6), for a run VERDICT
	// labelled; nil for a run that ended before DERIVE or in it, and for
	// every run with no report.
	Trace []TraceRow
	// Err says why, for a runtime error or a fault; nil otherwise.
	Err error
}

Outcome is how one run of Verify ended (see the file's doc).

func Verify

func Verify(cfg Config, read func() ([]byte, error)) (outcome Outcome)

Verify runs steps 0 to 14 of SPEC.md section 10.2 under cfg over the document read gives, which it calls after CONFIGURATION, and gives the run's Outcome. read gives the document's bytes, at most MAX_READ_OCTETS + 1 of them, as strictjson.Read does: a *strictjson.Rejection from it is J1's input_too_large, and any other error an input that cannot be read.

func (Outcome) ExitCode

func (o Outcome) ExitCode() int

ExitCode is the run's exit code (SPEC.md section 12.2).

type Pointer

type Pointer []Segment

Pointer is a JSON Pointer as its segments, outermost first.

func (Pointer) Encode

func (p Pointer) Encode() string

Encode returns the RFC 6901 string of p: each segment after a /, with ~ written ~0 and / written ~1 in a name.

type ReadOutcome

type ReadOutcome string

ReadOutcome is a read's outcome (SPEC.md section 10.4, "Answers").

const (
	// ReadFound: the source returned the object asked for.
	ReadFound ReadOutcome = "found"
	// ReadNotFound: the source answered that it holds no such object.
	ReadNotFound ReadOutcome = "not_found"
	// ReadUnreachable: there is no usable answer.
	ReadUnreachable ReadOutcome = "unreachable"
)

The outcomes of a read.

type Recomputed

type Recomputed struct {
	Construction  string
	Part          string
	Carried       any
	Value         any
	SignedMessage bool
}

Recomputed is one CHECKED value of P: the row of the constructions text that defines it (SPEC.md section 7.3), its pointer, the value P carries there, and the value DERIVE recomputes for it, nil when there is none (a walk that gives no root, or a header of a txoutproof that does not parse). For a handover_signature, SignedMessage is true: Carried is the signature and Value is not a value to compare with it but the 32 octets of the message it signs, as hex.

type Recorded

type Recorded struct {
	Part  string
	Value any
}

Recorded is one RECORDED value of P (SPEC.md section 3.7): its pointer and its value.

type Rejection

type Rejection struct {
	Code      specdata.Reason
	Message   string
	SubReason specdata.SubReason
}

Rejection is a bare rejection. Code is one of the four codes whose status is bare in SPEC.md section 12.1: configuration_error, input_too_large, malformed_json or invalid_envelope. SubReason is set for malformed_json and invalid_envelope only, to one of the names section 12.1 lists for the code, and is "" otherwise.

func ConfigurationError

func ConfigurationError(message string) *Rejection

ConfigurationError is configuration_error, with message saying which check of step 0 failed.

func Envelope

func Envelope(run *Run) *Rejection

Envelope is step 3, ENVELOPE: the document is exactly the envelope of SPEC.md section 3.1. The checks run in the order of EnvelopeChecks, and the first that fails gives invalid_envelope with its name as the sub_reason:

  1. document: an object whose members are exactly proof and signature;
  2. proof: proof is an object;
  3. signature: an object whose members are exactly alg, public_key and value;
  4. alg: alg is the string truestamp-ed25519-sha256-jcs;
  5. public_key: a string that matches B64U32, whose 32 octets K pass the checks of a key's bytes (SPEC.md section 6.2);
  6. value: a string that matches B64U64.

A B64U32 or B64U64 string is matched against its class before it is decoded, so every spelling but the canonical one fails (section 2.4). Its message is fixed, and never names a member the document holds. When the checks pass, the run holds P, K and V, and the row's values hold K's key id.

func InputTooLarge

func InputTooLarge() *Rejection

InputTooLarge is input_too_large (step READ, J1).

func InvalidEnvelope

func InvalidEnvelope(sub specdata.SubReason) *Rejection

InvalidEnvelope is invalid_envelope with the first check of step ENVELOPE that fails (SPEC.md section 10.2, step 3).

func MalformedJSON

func MalformedJSON(sub specdata.SubReason) *Rejection

MalformedJSON is malformed_json with the rule the file breaks (step PARSE, J2 to J6).

func NewRejection

func NewRejection(code specdata.Reason, message string, sub specdata.SubReason) *Rejection

NewRejection returns a bare rejection with code, message and, when the code has one, sub. It panics for a code that is not bare, a sub_reason the code does not list, or a missing one.

func Parse

func Parse(run *Run, data []byte) *Rejection

Parse is step 2, PARSE: J2 to J6 (SPEC.md section 10.1), else malformed_json with its sub_reason.

func Read

func Read(run *Run, data []byte) *Rejection

Read is step 1, READ: J1 (SPEC.md section 10.1), else input_too_large.

func (*Rejection) Encode

func (r *Rejection) Encode() ([]byte, error)

Encode returns the rejection written with JCS (SPEC.md section 2.5), its members in the order JCS gives them.

func (*Rejection) Error

func (r *Rejection) Error() string

Error names the code and the sub_reason, with the message.

func (*Rejection) Value

func (r *Rejection) Value() map[string]any

Value is the rejection as a verifier outputs it, and all it outputs (SPEC.md section 10.2, the gate): {code, message, sub_reason}, with sub_reason present only for malformed_json and invalid_envelope and absent otherwise (section 12.1). There is no report, row or verdict.

type Report

type Report struct {
	Attribution     string
	Code            specdata.Reason
	Environment     string
	Label           string
	Rows            []Row
	SubjectID       string
	SubmittedAfter  *Edge
	SubmittedBefore *Edge
	TrustRoot       TrustRoot
	Type            string
	Verified        bool
	Window          string
}

Report is the report of a run (SPEC.md section 10.5; see the file's doc). A SubjectID or Type of "" is null, and so is a nil edge; Code is "" exactly when Label is not failed.

func NewReport

func NewReport(run *Run) *Report

NewReport returns the report of run, after VERDICT (step 14): its label, code and attribution, E_v, its rows, its type and subject id, its trust root, and the edges WINDOW drew, or none when the label is failed. It panics for a run VERDICT has not labelled, which has no report yet: a defect in the caller.

func (*Report) Encode

func (r *Report) Encode() ([]byte, error)

Encode returns the report written with JCS (SPEC.md section 2.5), its members in the order JCS gives them.

func (*Report) Value

func (r *Report) Value() map[string]any

Value is the report as SPEC.md section 10.5 writes it, with exactly its members (see the file's doc).

type Row

type Row struct {
	Code    specdata.Reason
	Message string
	Part    *string
	Status  Status
	Step    string
	Values  map[string]any
}

Row is a report row:

  • Code: a reason code of SPEC.md section 12.1, "" exactly when the status is pass;
  • Message: for display only, and never compared;
  • Part: an RFC 6901 pointer into the proof, or nil for a row about no single member;
  • Status and Step: the row's status and the name of its step (SPEC.md section 10.2), such as "ENVELOPE";
  • Values: what this run computed or read, and, for a failed comparison, the declared value it contradicts, under "declared". Each is a value internal/jcs can write: a string, a bool, a strictjson.Number, nil, or a []any or map[string]any of them.

func NewRow

func NewRow(step string, code specdata.Reason, part *string, message string, values map[string]any) Row

NewRow returns a row of step with code, at part: its status is the one SPEC.md section 12.1 gives the code, and pass for no code. It panics for a step SPEC.md section 10.2 does not name, a code the table lacks, or a code that ends a run in a bare rejection, so no row can carry a code that does not mean what its status says.

func PassRow

func PassRow(step string, part *string, message string, values map[string]any) Row

PassRow returns a pass row of step at part.

func (Row) Reduce

func (r Row) Reduce() (code *string, part *string, status, step string)

Reduce returns what conformance compares of a row (SPEC.md section 13.1): its code, part, status and step, with a nil code for a pass.

func (Row) Value

func (r Row) Value() map[string]any

Value is the row as a report writes it, {code, message, part, status, step, values} (SPEC.md section 10.5, "Rows"): code is absent exactly when the status is pass, a null part is nil, and a row with no values holds {}.

type RowCandidate

type RowCandidate struct {
	Step      string
	Part      string
	Candidate Candidate
	Counted   []AskedSource
}

RowCandidate is the candidate of a CHAIN or SOURCES row that passed with one (SPEC.md sections 11.1, 11.2 and 11.5): the row's Step and Part, the Candidate its counted sources share, and Counted, those sources, the one whose outcome the row took under first and every source that passed under at_least n or all, in the order of the network's sources.

type RowRule

type RowRule func(source SourceRecord) SourceOutcome

RowRule is a row's whole rule of SPEC.md section 10.4 made against one source, as if it were the only one: every read it makes goes to that source, through Run.ReadSource, and that source's own answers decide each branch. It is made only for a source whose identity was confirmed.

type Run

type Run struct {
	Config             Config
	Keyring            *keyring.Keyring
	KeyringUnavailable bool
	TrustRoot          TrustRoot
	Sources            []SourceRecord
	SourceSets         []SourceSet
	Document           any
	Proof              map[string]any
	PublicKey          [32]byte
	Signature          [64]byte
	BoundKey           *keyring.Key
	ProofHash          [32]byte
	Attribution        string
	Type               string
	SubjectID          string
	Constructions      Constructions
	Trace              []TraceRow
	ExternalGate       ExternalGate
	Candidates         []RowCandidate
	SubmittedAfter     *Edge
	SubmittedBefore    *Edge
	Label              string
	Code               specdata.Reason
	Rows               []Row
	Ended              bool
	// contains filtered or unexported fields
}

Run is the state of a run.

| Member              | Holds                                                       | Set at        |
|---------------------|-------------------------------------------------------------|---------------|
| Config              | the run's configuration                                     | CONFIGURATION |
| Keyring             | the keyring that governs key binding; nil in keyless mode, and when it could not be read | CONFIGURATION |
| KeyringUnavailable  | an online read of the keyring that would govern failed, so no key binds | CONFIGURATION |
| TrustRoot           | trust_root, {digest, kind, location} (SPEC.md section 10.5) | CONFIGURATION |
| Sources             | in an online run, each Stellar and Bitcoin source, confirmed or unreachable, with the pins it serves (sources.go); empty in an offline run | CONFIGURATION |
| SourceSets          | in an online run, each pinned Stellar and Bitcoin network's sources, in their order, and its source policy (sources.go); empty in an offline run | CONFIGURATION |
| Document            | the parsed document                                         | PARSE         |
| Proof               | P, the parsed value of proof                                | ENVELOPE      |
| PublicKey, Signature| the 32 octets of K and the 64 of V                          | ENVELOPE      |
| BoundKey            | the key of the keyring whose 32 octets equal K's, or nil     | KEY_BINDING   |
| ProofHash           | proof_hash, computed from P as parsed                       | SIGNATURE     |
| Attribution         | attribution (SPEC.md section 10.5): truestamp, keyring:<d> or unattributed when SIGNATURE passes, none when the gate fails, "" before | SIGNATURE, or a failure at steps 4 to 6 |
| Type                | the proof's type, which SHAPE has held to the type registry; "" until SHAPE passes, which a report writes as null | SHAPE |
| SubjectID           | the subject's id: /subject/record/id, or /block/record/id for block and beacon (SPEC.md section 10.5); "" until SHAPE passes, which a report writes as null | SHAPE |
| Constructions       | what SHAPE's check 6 found of the constructions member: its mode and, in full mode, the d this run computed (shape.go); zero until SHAPE passes | SHAPE |
| Trace               | the trace (SPEC.md section 10.6): one row for each DERIVE row whose part is a CHECKED value, other than a row of LINK_HEAD, LINK_KEY_EVENT or LINK_CHAIN_ORDER, in DERIVE's order; nil until DERIVE, for a run that ends before it, and after a fault in it | DERIVE |
| ExternalGate        | the external gate (SPEC.md section 10.2): open, offline or prior_failure; "" before DERIVE ends, and in a run that ended before it or in it | DERIVE |
| Candidates          | the candidate of each CHAIN and SOURCES row that passed with one, in row order, and the sources it rests on (chain.go) | CHAIN, SOURCES |
| SubmittedAfter, SubmittedBefore | the edges WINDOW drew under an open gate (window.go), each nil where it has none; nil under a closed gate; kept on a failed run, so never output or shown: a report's edges are read only from [NewReport] | WINDOW |
| Label               | the report's label (SPEC.md section 10.5); "" before VERDICT | VERDICT |
| Code                | the run's code, the code of its first failing row, when Label is failed; "" otherwise | VERDICT |
| Rows                | the rows so far, in step order                              | every step    |
| Ended               | whether a failure ended the run                             | a failure at steps 4 to 7, or a caught fault from ENVIRONMENT on |

func (*Run) AddRow

func (r *Run) AddRow(row Row)

AddRow adds row after the run's rows.

func (*Run) EndRun

func (r *Run) EndRun()

EndRun ends the run after a failure at steps 4 to 7, or after a fault caught from ENVIRONMENT on: one row skip prior_failure, part null, for each step after the last row's up to EXPECTED_HASH (SPEC.md sections 10.2 and 10.5). Every later step passes an ended run through unchanged.

func (*Run) Failed

func (r *Run) Failed() bool

Failed reports whether any row so far is fail.

func (*Run) ReadSource

func (r *Run) ReadSource(source SourceRecord, read map[string]any, do func() SourceRead) SourceRead

ReadSource gives the answer of the read named read, of source, through do, which makes the read live and gives its Outcome, Value and Reason: the answer this run already has for the same read of the same source when it has one, so every row of a run that needs that read takes one answer (SPEC.md section 10.4, "Caches"), and otherwise do's answer, its Read set to read and its FetchedAt to the clock's reading when do returns, which the run keeps when it is found or not found. An unreachable answer is never kept, so a later row that needs the read makes it again ("no cache keeps the answer", section 10.4, "Answers"). No answer of one source ever stands as another's, since the source is part of the key. A read whose name JCS cannot write is not kept. The reads of the identities are not made here: step 0 makes each once.

func (*Run) SourcesFor

func (r *Run) SourcesFor(pin, chain string) (SourceSet, bool)

SourcesFor returns the sources of the run's pin (commitment or entropy) of chain, all of them in their order under the network's policy, and whether it has any: every pin of an online run that passed CONFIGURATION has one or more, and an offline run has none.

type Schema

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

Schema is a checker built from a schema by LoadSchema.

func LoadSchema

func LoadSchema(schema any) (*Schema, error)

LoadSchema builds a checker of schema, a value as internal/strictjson parses it, or refuses a schema outside the subset with an error wrapping ErrSchemaOutsideSubset that names what it found.

func (*Schema) Failures

func (s *Schema) Failures(value any, path ...string) []SchemaFailure

Failures returns every failure of value against the schema at path from the checker's root, each part a pointer into value, in document order. For the schema of the document's proof, path is "properties", "proof", and the failures are those of a document whose signature satisfies its schema, without the leading /proof. It panics for a path that names no schema, which only a caller's defect gives.

type SchemaFailure

type SchemaFailure struct {
	Part    Pointer
	Keyword string
	Schema  string
}

SchemaFailure is one failure of a value against a schema: where it is, the keyword that fails and where that keyword sits in the schema.

func ProofFailures

func ProofFailures(proof any) []SchemaFailure

ProofFailures returns every failure of P, the parsed value of proof, against the schema spec/schema.json gives the document's proof member, each part a pointer into P, in document order.

type Segment

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

Segment is one segment of a pointer: a member's name or an element's index.

func Index

func Index(index int) Segment

Index returns the segment of the array element at index, which must not be negative.

func Name

func Name(name string) Segment

Name returns the segment of the member named name.

type ServedPin

type ServedPin struct {
	Pin     string
	Network string
}

ServedPin is one network pin a source serves: its kind, commitment or entropy, and its network.

type Source

type Source struct {
	// Chain is stellar or bitcoin.
	Chain string
	// Provider is the kind of server: Horizon for Stellar, Esplora or
	// Bitcoin Core for Bitcoin.
	Provider source.Provider
	// URL is the server's base URL, or a Bitcoin Core node's JSON-RPC URL.
	// It never carries user information. The reads use it whole, and a
	// message or a report prints it as [printedURL] does, with no path.
	URL string
	// Credentials are a Bitcoin Core node's RPC credentials; they print
	// masked.
	Credentials source.Credentials
	// Network is the one network the source is configured for, a
	// compiled-in default's or that of the [NetworkSources] it is one of,
	// or "" for a source configured for no network, which, when it answers
	// its identity read, serves only the pins of its chain of networks with
	// no configuration that the answer shows. Step 0 sets it on each source
	// of a network's configuration.
	Network string
}

Source is one Stellar or Bitcoin source a run may read.

func DefaultSource

func DefaultSource(chain, network string) (Source, bool)

DefaultSource returns the compiled-in source of network of chain, and whether there is one.

type SourceFrom

type SourceFrom string

SourceFrom says where a run's source came from.

const (
	// FromDefault: a compiled-in default.
	FromDefault SourceFrom = "default"
	// FromOperator: a source the operator pins, or one a conformance
	// case's replay file stands for.
	FromOperator SourceFrom = "operator"
)

Where a source comes from.

type SourceKind

type SourceKind int

SourceKind is how a run's keyring is chosen.

const (
	// SourceDefault: no keyring is asked for. Under E_v prod, the keyring
	// read from www.truestamp.com governs an online run and the compiled
	// pin an offline one; under any other E_v the run stops at
	// CONFIGURATION with configuration_error (section 6.4).
	SourceDefault SourceKind = iota
	// SourceKeyless: keyless mode (--no-keyring); no keyring governs.
	SourceKeyless
	// SourceFile: a supplied keyring read from a file (--keyring FILE).
	SourceFile
	// SourceConfigured: a configured keyring, a supplied keyring read from
	// the file the configuration file names for the run's E_v.
	SourceConfigured
	// SourceOrigin: a supplied keyring read online from the origin an
	// explicit --base-url names.
	SourceOrigin
)

The keyring sources of a run (SPEC.md section 8.3).

type SourceOutcome

type SourceOutcome struct {
	Status    Status
	Code      specdata.Reason
	Candidate *Candidate
	Reads     []SourceRead
	Notes     map[string]any
}

SourceOutcome is one source's outcome on a row (SPEC.md section 10.4, "Several sources"): Status pass, fail or skip; Code, "" exactly when Status is pass, chain_mismatch or entropy_mismatch for a failure, and source_unreachable, not_held_by_source, not_yet_indexed or chain_not_final for a skip; Candidate, present exactly when the source passed with one; Reads, every read the rule made of the source, in the order made; and Notes, anything else the rule noted, which a row's values hold under notes, each a value internal/jcs can write.

type SourcePolicy

type SourcePolicy struct {
	Kind SourcePolicyKind
	N    int
}

SourcePolicy is a network's source policy (SPEC.md sections 9 and 10.4, "Several sources"): first, at_least n with N its n, or all. Only the operator sets it, never the document. N is 0 under first and all; under at_least, an N that is 0 or above the number of the network's sources is configuration_error at step 0.

func (SourcePolicy) Required

func (p SourcePolicy) Required(count int) int

Required is the policy's n for a network of count sources, the number of conclusive outcomes it asks for (SPEC.md section 10.4, "What a row read"): 1 under first, N under at_least and count under all.

func (SourcePolicy) String

func (p SourcePolicy) String() string

String writes the policy as a message names it: first, at_least n or all.

type SourcePolicyKind

type SourcePolicyKind string

SourcePolicyKind names a source policy (SPEC.md section 9, "Several sources for one network").

const (
	// SourcePolicyFirst: the sources are asked in their order, and a row
	// takes the first conclusive outcome.
	SourcePolicyFirst SourcePolicyKind = "first"
	// SourcePolicyAtLeast: every source is asked, and a row passes or
	// fails when n of them agree.
	SourcePolicyAtLeast SourcePolicyKind = "at_least"
	// SourcePolicyAll: at_least the number of sources.
	SourcePolicyAll SourcePolicyKind = "all"
)

The source policies.

type SourceRead

type SourceRead struct {
	Read      map[string]any
	Outcome   ReadOutcome
	Value     map[string]any
	Reason    string
	FetchedAt time.Time
}

SourceRead is one read a rule made of one source, in the form of a replay record (SPEC.md section 13.2): Read names the read, its kind, its network for a Stellar or Bitcoin source and its parameters, each spelled as the proof spells the value it comes from; Outcome, with Value, the fields the read uses, for a found answer and Reason, which says why and never names the source's URL, for an unreachable one; and FetchedAt, when the answer came back. Run.ReadSource sets Read and FetchedAt. Each member of Read and Value is a value internal/jcs can write.

type SourceRecord

type SourceRecord struct {
	Source Source
	From   SourceFrom
	Status SourceStatus
	// Identity is the value the source gave, when confirmed.
	Identity string
	// Reason says why the source gave no usable answer, when unreachable.
	Reason string
	// Pins are the network pins the source serves, none for a source that
	// serves nothing.
	Pins []ServedPin
	// FetchedAt is when the identity read's answer, or its failure, came
	// back, by the verifier's clock (SPEC.md section 10.4, "What a row
	// read"): a row whose source was asked nothing else gives it. The read
	// is always live, so it is never cached.
	FetchedAt time.Time
}

SourceRecord is one source of an online run and its identity read.

type SourceSet

type SourceSet struct {
	Chain   string
	Network string
	Policy  SourcePolicy
	Sources []SourceRecord
}

SourceSet is one pinned network's sources, in their order, each with its identity read's outcome, and its policy: what CHAIN and SOURCES read that network from, each row's rule made once for each source and the outcomes combined under the policy (SPEC.md section 10.4, "Several sources"). A network with no configuration has the policy first and either its compiled-in default or the sources configured for no network that serve it, one or more, in the order of Config.Sources: SPEC.md section 9 gives such a network one source, and several is the CLI's own rule, which [assign] applies.

func (SourceSet) Required

func (s SourceSet) Required() int

Required is the set's n: the number of conclusive outcomes its policy asks for (SPEC.md section 10.4, "What a row read").

type SourceStatus

type SourceStatus string

SourceStatus is the outcome of a source's identity read.

const (
	// SourceConfirmed: the source answered with a value its pins allow;
	// a source configured for no network whose answer only pinned networks
	// with a configuration allow is confirmed with no pins.
	SourceConfirmed SourceStatus = "confirmed"
	// SourceUnreachable: the source gave no usable answer, and the run
	// reads nothing else from it.
	SourceUnreachable SourceStatus = "unreachable"
)

The outcomes of an identity read that is no configuration_error.

type Status

type Status string

Status is a row's status (SPEC.md section 10.5).

const (
	StatusPass Status = "pass"
	StatusFail Status = "fail"
	StatusSkip Status = "skip"
	StatusWarn Status = "warn"
	StatusInfo Status = "info"
)

The row statuses.

type TimeClass

type TimeClass int

TimeClass is TIME or NISTTIME (SPEC.md section 2.4).

const (
	ClassTIME TimeClass = iota
	ClassNISTTIME
)

The two classes of a time.

func (TimeClass) String

func (c TimeClass) String() string

String names the class as SPEC.md section 2.4 does.

type TraceRow

type TraceRow struct {
	Construction string
	Declared     any
	Inputs       []string
	Part         string
	Recomputed   any
	Status       Status
}

TraceRow is one row of a run's trace (SPEC.md section 10.6): the constructions row that defines the value, the value the proof carries, the pointers of the values the check read, in document order, the part of its DERIVE row, what the check compared the declared value with (nil when a walk gives no root), and the status of its DERIVE row, pass or fail.

func (TraceRow) Value

func (r TraceRow) Value() map[string]any

Value returns the trace row as SPEC.md section 10.6 writes it, a value internal/jcs writes: {construction, declared, inputs, part, recomputed, status}.

type TrustRoot

type TrustRoot struct {
	Digest   string
	Kind     TrustRootKind
	Location string
}

TrustRoot is trust_root, {digest, kind, location} (SPEC.md section 10.5): Digest, d, the lowercase hex SHA-256 of the bytes of the keyring that governs key binding as read (section 8.3), or "", which a report writes as null, in keyless mode and when the keyring could not be read; Kind; and Location, the URL or file the keys came from, or "" when they came from neither, which a report writes as null.

func (TrustRoot) Value

func (t TrustRoot) Value() map[string]any

Value is trust_root as a report writes it, {digest, kind, location} (SPEC.md section 10.5), digest and location null where they are "".

type TrustRootKind

type TrustRootKind string

TrustRootKind is trust_root's kind (SPEC.md section 10.5), as section 8.3 assigns it to an external verifier's keyring.

const (
	KindCurrentKeyring  TrustRootKind = "current_keyring"
	KindCompiledPin     TrustRootKind = "compiled_pin"
	KindSuppliedKeyring TrustRootKind = "supplied_keyring"
	KindNone            TrustRootKind = "none"
)

The kinds of an external verifier's trust root.

Directories

Path Synopsis
Package bitcoin holds the strict readers of the Bitcoin bytes a commitment entry carries, for the Bitcoin evidence of DERIVE (SPEC.md section 10.2, step 9 (d)): a raw_transaction and a txoutproof, each judged well formed or not by the rules that step lists, and the values the step reads out of a well-formed one.
Package bitcoin holds the strict readers of the Bitcoin bytes a commitment entry carries, for the Bitcoin evidence of DERIVE (SPEC.md section 10.2, step 9 (d)): a raw_transaction and a txoutproof, each judged well formed or not by the rules that step lists, and the values the step reads out of a well-formed one.
Package ed25519 holds the strict Ed25519 rule of SPEC.md section 6.2 (Strict verification) for the new verifier: CheckKeyBytes, the checks of a key's bytes (this file), and Verify, Verify(A, msg, S), which makes them and then calls Go's crypto/ed25519 (verify.go).
Package ed25519 holds the strict Ed25519 rule of SPEC.md section 6.2 (Strict verification) for the new verifier: CheckKeyBytes, the checks of a key's bytes (this file), and Verify, Verify(A, msg, S), which makes them and then calls Go's crypto/ed25519 (verify.go).
Package keyring holds a keyring and the load checks of SPEC.md section 10.2, step 0 (CONFIGURATION), which every keyring the verifier loads passes before any key in it can bind (sections 8.3 (External verifiers) and 9 (What a verifier pins)).
Package keyring holds a keyring and the load checks of SPEC.md section 10.2, step 0 (CONFIGURATION), which every keyring the verifier loads passes before any key in it can bind (sections 8.3 (External verifiers) and 9 (What a verifier pins)).
Package source holds the CLI verifier's readers of a Stellar or Bitcoin source, the servers SPEC.md section 9 (What a verifier pins) names under "Sources": a Horizon server for Stellar, and an Esplora server or a Bitcoin Core node for Bitcoin; and of NIST's Randomness Beacon, which section 9 makes one source, read at its one compiled-in address.
Package source holds the CLI verifier's readers of a Stellar or Bitcoin source, the servers SPEC.md section 9 (What a verifier pins) names under "Sources": a Horizon server for Stellar, and an Esplora server or a Bitcoin Core node for Bitcoin; and of NIST's Randomness Beacon, which section 9 makes one source, read at its one compiled-in address.

Jump to

Keyboard shortcuts

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