Documentation
¶
Overview ¶
Package specdata holds what a verifier pins (SPEC.md section 9): every file under the spec repository's spec/, the 12 files and the constructions texts under constructions/, embedded byte for byte from verification/spec/ beside this file, with verification/SOURCE naming the spec commit they came from.
task verification-sync writes verification/ here and testdata/verification/ at the module root from one commit on the spec's main, and nothing else may change either copy; task verification-check compares both with that commit. The tests hold testdata/verification/ to its MANIFEST.sha256, the embedded files and verification/ to that copy, and each table this package holds to the file it is transcribed from (SPEC.md section 13.1, "Beyond the vectors").
A file comes back as its bytes, from File: nothing here decodes JSON, so a file is read under the parsing rules of SPEC.md section 10.1 by the verifier's own strict reader. What a verifier needs as constants is written here as Go values, transcribed from its file and held equal to it by a test:
- the constants of constants.json, as Go constants, and Constants;
- SMALL_ORDER_KEYS, SmallOrderKeys;
- the pattern classes of encodings.json, Encodings;
- the network names of networks.json, Networks;
- the default network pins of network-pins.json, DefaultNetworkPins and Environments;
- the reason codes of reason-codes.json, with their sub_reasons, ReasonCodes;
- the exit codes of exit-codes.json, ExitCodes and ExitCode;
- CONSTRUCTIONS_ACCEPTED, the digests of the texts under constructions/, computed from the embedded bytes, Accepted.
The contents of keyring.production.json, the compiled keyring pin of SPEC.md section 8.3, are read only through File: it holds Truestamp's production key, and no table of this package transcribes it.
Index ¶
- Constants
- func Accepted() []string
- func Constants() map[string]any
- func Encodings() map[string]Encoding
- func Environments() []string
- func ExitCode(ending Ending) (int, bool)
- func File(name string) ([]byte, error)
- func IsAccepted(digest string) bool
- func IsReason(name string) bool
- func Names() []string
- func Networks() map[string][]string
- func PrefixByte(text string) (byte, error)
- func Source() string
- type ChainNetworks
- type Encoding
- type Ending
- type ExitEntry
- type IntRange
- type NetworkPins
- type Reason
- type ReasonEntry
- type SmallOrderKey
- type Status
- type SubReason
Constants ¶
const ( // BitcoinFinality is BITCOIN_FINALITY. BitcoinFinality = 10 // BitcoinMaxTotalTxs is BITCOIN_MAX_TOTAL_TXS. BitcoinMaxTotalTxs = 16666 // BitcoinMedianSpan is BITCOIN_MEDIAN_SPAN. BitcoinMedianSpan = 11 // ClaimsMaxOctets is CLAIMS_MAX_OCTETS. ClaimsMaxOctets = 20480 // MaxDepth is MAX_DEPTH, counting the document object as 1. MaxDepth = 32 // MaxDocumentOctets is MAX_DOCUMENT_OCTETS. MaxDocumentOctets = 65536 // MaxInteger is MAX_INTEGER, 2^53 - 1. MaxInteger = 9007199254740991 // MaxPathSteps is MAX_PATH_STEPS. MaxPathSteps = 32 // MaxReadOctets is MAX_READ_OCTETS. MaxReadOctets = 262144 // RawTxMaxOctets is RAW_TX_MAX_OCTETS. RawTxMaxOctets = 1000 // StellarIndexMargin is STELLAR_INDEX_MARGIN, in ledgers. StellarIndexMargin = 60 // TxoutproofMaxOctets is TXOUTPROOF_MAX_OCTETS. TxoutproofMaxOctets = 1024 // VectorKey is VECTOR_KEY, in hex: the public key of the seed of 32 // bytes of 0x42, valid only when the verifier's environment is test. VectorKey = "2152f8d19b791d24453242e15f2eab6cb7cffa7b6a5ed30097960e069881db12" )
The constants of SPEC.md section 9, each named after the name spec/constants.json gives it. A test holds each to the file and to SPEC.md's table.
Variables ¶
This section is empty.
Functions ¶
func Accepted ¶
func Accepted() []string
Accepted returns CONSTRUCTIONS_ACCEPTED, the accepted digests, sorted. Each call returns a new slice.
func Constants ¶
Constants returns every constant by its name in spec/constants.json, an integer as an int64 and VECTOR_KEY as its hex string. Each call returns a new map.
func Encodings ¶
Encodings returns the pattern classes of spec/encodings.json, by name. Each call returns a new map, sharing nothing with the table.
func Environments ¶
func Environments() []string
Environments returns every E_v (SPEC.md section 6.4): prod, then the values of ENV in the order spec/encodings.json lists them. Each call returns a new slice.
func File ¶
File returns the bytes of name, a path under spec/ such as "constants.json" or "constructions/<d>.json", exactly as the sync copied them. Each call returns a new slice. A name that is not a file under spec/, or not a clean relative path, is an error.
func IsAccepted ¶
IsAccepted reports whether digest, 64 lowercase hex digits, is in CONSTRUCTIONS_ACCEPTED.
func Names ¶
func Names() []string
Names returns the path under spec/ of every embedded file, sorted.
func Networks ¶
Networks returns the network names of each chain, by chain, as spec/networks.json lists them. Each call returns a new map.
func PrefixByte ¶
PrefixByte reads a registry byte as spec/prefixes.json writes it: "0x" and two lowercase hex digits, such as "0x50". Any other spelling is an error.
Types ¶
type ChainNetworks ¶
ChainNetworks is a network for each chain: for a commitment pin, the chain's; for an entropy pin, the network of the source of that name.
type Encoding ¶
type Encoding struct {
// Pattern is the class's regular expression as the file writes it,
// with no ^ or $.
Pattern string
// DecodesToOctets is the length of what a base64url class decodes to.
DecodesToOctets int
// CapsInOctets bounds HEXBYTES, by the member it appears at.
CapsInOctets map[string]int
// Values lists the values of ENV.
Values []string
// ValuesByChain lists the values of NETWORK, by chain.
ValuesByChain map[string][]string
// Range bounds INT.
Range *IntRange
// Schema names the schema definition of MERKLE_PROOF.
Schema string
// RoundTrip says a TIME or NISTTIME value must equal its own
// re-formatting.
RoundTrip bool
}
Encoding is one pattern class of spec/encodings.json (SPEC.md section 2.4). Each member is the file's member of that name, and is the zero value when the class has none.
type Ending ¶
type Ending string
Ending is how a run of the command ended. Its value is the words the row of SPEC.md section 12.2 for it begins with.
const ( EndingVerified Ending = "label verified" EndingInternallyConsistent Ending = "label internally-consistent" EndingSuppliedKeyring Ending = "label supplied-keyring" EndingUnattributed Ending = "label unattributed" EndingFailed Ending = "label failed" EndingRuntimeError Ending = "a runtime error outside verification" EndingFault Ending = "the verifier stopped on a fault" EndingBareRejection Ending = "a bare rejection other than configuration_error" EndingConfigurationError Ending = "configuration_error" )
The endings of a run, one for each row of SPEC.md section 12.2.
type ExitEntry ¶
ExitEntry is one row of the table of SPEC.md section 12.2: an exit code and the run it is for, as spec/exit-codes.json writes it.
type IntRange ¶
type IntRange struct {
Minimum, Maximum int64
}
IntRange is the minimum and maximum of a class of integers.
type NetworkPins ¶
type NetworkPins struct {
Commitment ChainNetworks
Entropy ChainNetworks
}
NetworkPins is one row of spec/network-pins.json (SPEC.md section 9): the default commitment pins and entropy pins of one E_v.
func DefaultNetworkPins ¶
func DefaultNetworkPins(environment string) (NetworkPins, bool)
DefaultNetworkPins returns the default network pins of environment, an E_v, from spec/network-pins.json, and whether it is one.
type Reason ¶
type Reason string
Reason is a reason code of SPEC.md section 12.1.
const ( ReasonConfigurationError Reason = "configuration_error" ReasonInputTooLarge Reason = "input_too_large" ReasonMalformedJSON Reason = "malformed_json" ReasonInvalidEnvelope Reason = "invalid_envelope" ReasonEnvironmentMismatch Reason = "environment_mismatch" ReasonKeyBindingFailed Reason = "key_binding_failed" ReasonKeyBindingNotPerformed Reason = "key_binding_not_performed" ReasonSignatureInvalid Reason = "signature_invalid" ReasonUnsupportedFormat Reason = "unsupported_format" ReasonUnsupportedVersion Reason = "unsupported_version" ReasonShapeInvalid Reason = "shape_invalid" ReasonConstructionMismatch Reason = "construction_mismatch" ReasonNetworkMismatch Reason = "network_mismatch" ReasonDerivationMismatch Reason = "derivation_mismatch" ReasonBitcoinEvidenceInvalid Reason = "bitcoin_evidence_invalid" ReasonKeyEventMismatch Reason = "key_event_mismatch" ReasonOrderingViolation Reason = "ordering_violation" ReasonNotAttributable Reason = "not_attributable" ReasonOffline Reason = "offline" ReasonChainMismatch Reason = "chain_mismatch" ReasonSourceUnreachable Reason = "source_unreachable" ReasonNotHeldBySource Reason = "not_held_by_source" ReasonNotYetIndexed Reason = "not_yet_indexed" ReasonChainNotFinal Reason = "chain_not_final" ReasonSourcesDisagree Reason = "sources_disagree" ReasonSourcesIncomplete Reason = "sources_incomplete" ReasonEntropyMismatch Reason = "entropy_mismatch" ReasonWindowNotEstablished Reason = "window_not_established" ReasonWindowInverted Reason = "window_inverted" ReasonRecordedTimeOutsideWindow Reason = "recorded_time_outside_window" ReasonExpectedHashMismatch Reason = "expected_hash_mismatch" ReasonExpectedHashWeakAlgorithm Reason = "expected_hash_weak_algorithm" ReasonExpectedHashNotChecked Reason = "expected_hash_not_checked" ReasonPriorFailure Reason = "prior_failure" ReasonInternalError Reason = "internal_error" )
The reason codes of SPEC.md section 12.1, in the table's order.
type ReasonEntry ¶
type ReasonEntry struct {
Code Reason
Status Status
// Step is the step as the table writes it, such as "DERIVE, CHAIN" for
// a code of two steps.
Step string
Meaning string
// SubReasons lists the values the code's sub_reason takes, in SPEC.md's
// order. It is empty for every code but malformed_json and
// invalid_envelope, since no other code carries a sub_reason.
SubReasons []SubReason
}
ReasonEntry is one row of the table of SPEC.md section 12.1.
func LookupReason ¶
func LookupReason(code Reason) (ReasonEntry, bool)
LookupReason returns the row of code, and whether code is in the table.
func ReasonCodes ¶
func ReasonCodes() []ReasonEntry
ReasonCodes returns the table of SPEC.md section 12.1, in its order. Each call returns a new slice, sharing nothing with the table.
type SmallOrderKey ¶
SmallOrderKey is one entry of SMALL_ORDER_KEYS (SPEC.md sections 6.2 and 9): a 32-byte encoding of a point of small order, the point's order, and whether the encoding is the sign-bit variant of a canonical one.
func SmallOrderKeys ¶
func SmallOrderKeys() []SmallOrderKey
SmallOrderKeys returns SMALL_ORDER_KEYS in the order of spec/small-order-keys.json. Each call returns a new slice.
type Status ¶
type Status string
Status is a reason code's status: StatusBare ends the run in a bare rejection, and the others are row statuses.
type SubReason ¶
type SubReason string
SubReason is a value the sub_reason of a malformed_json or invalid_envelope rejection takes.
const ( SubReasonSyntax SubReason = "syntax" SubReasonInvalidUTF8 SubReason = "invalid_utf8" SubReasonLoneSurrogate SubReason = "lone_surrogate" SubReasonDuplicateName SubReason = "duplicate_name" SubReasonNumber SubReason = "number" SubReasonDepth SubReason = "depth" SubReasonDocument SubReason = "document" SubReasonProof SubReason = "proof" SubReasonSignature SubReason = "signature" SubReasonAlg SubReason = "alg" SubReasonPublicKey SubReason = "public_key" SubReasonValue SubReason = "value" )
The sub_reason values of malformed_json (SPEC.md section 10.1) and of invalid_envelope (SPEC.md section 10.2, step 3), each in its order.
func SubReasons ¶
SubReasons returns the values the sub_reason of code takes, in SPEC.md's order: those of malformed_json and of invalid_envelope, and none for any other code.