Documentation
¶
Overview ¶
Package zonerec is bdns's record codec: the four records a zone's topic carries, the leaves a state commits to, their root and their proofs (docs/spec.md). Each record is a canonical CBOR map with unsigned-integer keys, key 0 its four-byte magic, read with bcommon's record rules: a record is refused for the first rule it breaks, in key order, and keys above the last one a version defines are preserved verbatim.
| Record | Magic | Carried as | | Record set state | "bdr" 0x01 | a chain token under the set's owner | | Origin state | "bdo" 0x01 | a chain token under the origin's owner | | Attached record | "bda" 0x01 | a carrier, signed by its writer | | Host record | "bdh" 0x01 | a carrier, signed by the host |
A leaf is not a record: it is a canonical CBOR array, one per name and type, and a state commits to its leaves by an RFC 6962 root.
Index ¶
- Constants
- Variables
- func Ahead(kind uint64) (uint64, bool)
- func ChangesProtected(beforeGuard []byte, beforeLeaves []*Leaf, guard []byte, leaves []*Leaf) bool
- func CheckAnswer(leaves []*Leaf) error
- func CheckGuard(before, s *State, beforeLeaves, leaves []*Leaf, spent transaction.Outpoint) error
- func CheckKey(b []byte) error
- func CheckLeaves(leaves []*Leaf) error
- func CheckOrder(leaves []*Leaf) error
- func Commitment(originID, secret [32]byte) [32]byte
- func EncodeLeaves(leaves []*Leaf, maxCount, maxSize int) ([]byte, error)
- func EncodeName(n Name) ([]byte, error)
- func FundingScript(key *ec.PublicKey) []byte
- func GuardSign(ctx context.Context, guard wallet.Interface, originator string, s *State, ...) ([]byte, error)
- func GuardSigned(s *State, spent transaction.Outpoint) ([]byte, error)
- func LeafKey(name Name, typ uint16, scope []byte) []byte
- func LockingKey(d pushdrop.Derivation, identity []byte) (*ec.PublicKey, error)
- func MemberDerivation(keyID string) pushdrop.Derivation
- func OriginID(genesis []byte, txid [32]byte, vout uint32) [32]byte
- func Permission(domain string, name Name) (string, error)
- func Pieces(size uint64) uint64
- func Protected(l *Leaf) bool
- func Reason(err error) string
- func Reasons() []string
- func RecordSetID(genesis []byte, txid [32]byte, vout uint32) [32]byte
- func Root(leaves []*Leaf) ([32]byte, error)
- func SameRecord(a, b *Kept) bool
- func Signed(tag, rec []byte, spent transaction.Outpoint) []byte
- func SignedBy(tx *transaction.Transaction, vout int, c Chain, identity []byte, ...) bool
- func SortLeaves(leaves []*Leaf)
- func Supersedes(k, have *Kept) bool
- func TokenLock(ctx context.Context, signer wallet.Interface, originator string, s *State, ...) (*script.Script, error)
- func TokenScript(key *ec.PublicKey, tag, rec, sig []byte) []byte
- func Topic(id [32]byte) string
- func TopicLetters(id [32]byte) string
- func ValidDomain(d string) bool
- func ValidLabel(l string) bool
- type Absence
- type Admission
- type Admitter
- type Attached
- type Chain
- type Challenge
- type CheckFailure
- type Claim
- type Data
- type Extension
- type Finding
- type Held
- type Host
- type Kept
- type Kind
- type Leaf
- type Member
- type MemberRule
- type Name
- type Origin
- func (o *Origin) AnswersWith(s *RecordSet) bool
- func (o *Origin) Check(object []byte) ([]*Leaf, error)
- func (o *Origin) Commit(leaves []*Leaf) ([]byte, error)
- func (o *Origin) Commitment() [32]byte
- func (o *Origin) Encode() ([]byte, error)
- func (o *Origin) Precedes(next *Origin) bool
- func (o *Origin) UnknownCritical(known func(kind uint64) bool) (uint64, bool)
- type Part
- type Piece
- type Presence
- type Proof
- type RecordSet
- func (s *RecordSet) Check(object []byte) ([]*Leaf, error)
- func (s *RecordSet) Commit(leaves []*Leaf) ([]byte, error)
- func (s *RecordSet) Encode() ([]byte, error)
- func (s *RecordSet) Lists(c [32]byte) bool
- func (s *RecordSet) Precedes(next *RecordSet) bool
- func (s *RecordSet) UnknownCritical(known func(kind uint64) bool) (uint64, bool)
- type State
- func (s *State) Anchor() transaction.Outpoint
- func (s *State) Check(object []byte) ([]*Leaf, error)
- func (s *State) Count() uint64
- func (s *State) Data() [32]byte
- func (s *State) Follows(prev *State) error
- func (s *State) Genesis() []byte
- func (s *State) Guard() []byte
- func (s *State) GuardSig() []byte
- func (s *State) ID() [32]byte
- func (s *State) Lapse() uint64
- func (s *State) Owner() []byte
- func (s *State) Root() [32]byte
- func (s *State) Seq() uint64
- func (s *State) Signer(prev *State) []byte
- func (s *State) Size() uint64
- func (s *State) UnknownCritical(known func(kind uint64) bool) (uint64, bool)
- type Tree
- func (t *Tree) Count() uint64
- func (t *Tree) Find(key []byte) (int, bool)
- func (t *Tree) Prove(index int) (*Presence, error)
- func (t *Tree) ProveAbsent(key []byte) (*Absence, error)
- func (t *Tree) ProveAbsentName(name Name) (*Absence, error)
- func (t *Tree) ProveKey(name Name, typ uint16, scope []byte) (*Proof, error)
- func (t *Tree) ProveName(name Name) (*Proof, error)
- func (t *Tree) Root() [32]byte
- type View
Constants ¶
const ( MaxTokenBEEF = 196608 // a token with its parent, or with what its inputs spend MaxPieceBEEF = 196608 // a leaves piece's carrier and its funding tree MaxLoosePieces = 256 // pieces a chain holds that no kept state names MaxRecordBEEF = 196608 // an attached or host record's carrier and its funding tree MaxFindings = 16 // live findings one writer may have on a topic DefaultMaxBEEF = 262144 )
Bounds on what a host admits.
const ( AKMagic = 0 AKZone = 1 // the identifier of the record set or origin it attaches to AKKind = 2 // what it is, 1 to 65,535 AKWriter = 3 // who signs it, 33 bytes AKName = 4 // the name it is about; no labels for the zone AKExpiry = 5 // Unix seconds after which it is not believed AKBody = 6 // at most 8,192 bytes; its form is the kind's AKLast = AKBody )
The attached record's keys (docs/spec.md section 9). It rides a carrier signed by its writer (section 12.7).
const ( KindMember = 1 KindNameserver = 2 // a nameserver advertisement KindReceipt = 3 // a render receipt KindObjection = 4 KindFinding = 5 KindReport = 6 KindOutcome = 7 KindChallenge = 8 // texts for _acme-challenge.<name> )
The assigned kinds of an attached record. A member's, a finding's and a challenge text's bodies have a form; every other kind's is opaque.
const ( AheadMember = 3600 // a member: one hour AheadFinding = 3600 // a finding: one hour AheadChallenge = 600 // a challenge text: ten minutes AheadHost = 86400 // a host record: one day )
How far ahead of a host's clock a record's expiry may be (spec sections 9 and 10): a host refuses one further ahead (section 12.7).
const ( MKHost = 1 // a member's host key, 33 bytes FKHost = 1 // a finding's host key, 33 bytes: the host the finding is against CKText = 1 // a challenge's texts MaxChallengeTexts = 4 MaxChallengeText = 255 )
The bodies of the attached kinds that have a form (docs/spec.md section 9). Each is a canonical CBOR map of exactly its keys: a different body is a different kind.
const ( RuleGrant = 1 RuleAdvert = 2 )
The rules a member rule leaf names (section 4.1).
const ( TypeA = 1 TypeNS = 2 TypeCNAME = 5 TypeSOA = 6 TypePTR = 12 TypeMX = 15 TypeTXT = 16 TypeAAAA = 28 TypeSRV = 33 TypeDNAME = 39 TypeOPT = 41 TypeDS = 43 TypeRRSIG = 46 TypeNSEC = 47 TypeDNSKEY = 48 TypeNSEC3 = 50 TypeNSEC3PARAM = 51 TypeCDS = 59 TypeCDNSKEY = 60 TypeSVCB = 64 TypeHTTPS = 65 TypeTKEY = 249 TypeTSIG = 250 )
The record types the checks name.
const ( HKMagic = 0 HKHost = 1 // the host's key, 33 bytes HKAddresses = 2 // 1 to 32 addresses of 4 or 16 bytes, distinct, ascending; none IPv4-mapped HKPort = 3 // 1 to 65,535 HKProtocols = 4 // 0 to 8 ALPN identifiers of 1 to 32 bytes, distinct, ascending HKCA = 5 // the certificate authority's CAA domain, or "" HKAccount = 6 // the account URI at that authority, at most 512 bytes; "" when there is no authority HKLocation = 7 // an IATA metro code, three upper-case letters, or "" HKExpiry = 8 // Unix seconds after which it is not believed HKMethods = 9 // 0 to 8 ACME validation methods (RFC 8657), distinct, ascending; none when there is no authority HKLast = HKMethods MaxMethods = 8 MaxMethod = 32 )
The host record's keys (docs/spec.md section 10). It rides a carrier signed by the host's key (section 12.7), on the topic of the zone whose member names it.
const ( SecurityLevel = 1 ProtocolRecordSet = "bdns records" ProtocolOrigin = "bdns origin" ProtocolMember = "bdns member" // attached and host records KeyIDState = "state" // token lock and field signature KeyIDChain = "chain" // the outputs of the tree that pays for a chain's first token KeyIDAttach = "attach" // an attached record's carrier lock and field signature, and its funding tree KeyIDHost = "host" // a host record's carrier lock and field signature, and its funding tree KeyIDGuard = "guard" // a guard's field signature, under the chain's own protocol )
The BRC-43 protocols, all at security level 1, and their key ids. Derivations are BRC-42 with the anyone counterparty.
const ( TopicPrefix = "tm_bdns_" LookupService = "ls_bdns" TopicLetterN = 28 )
The topic prefix and the lookup service.
const ( OKMagic = 0 OKID = 1 // the origin's identifier: 32 bytes, the same in every state OKSeq = 2 // 0 for the first state, then one more each state OKGenesis = 3 // the owner at seq 0, 33 bytes; the same in every state OKOwner = 4 // who signs this state; the genesis key at seq 0 OKAnchor = 5 // the outpoint the first state spent: txid || uint32be(vout) OKBase = 6 // the identifier of the record set this origin answers with OKSecret = 7 // opens the record set's commitment to this origin OKSerial = 8 // the SOA serial, greater than the previous state's OKRoot = 9 // the RFC 6962 root over this origin's own leaves OKCount = 10 // the number of its own leaves OKData = 11 // SHA-256 of its leaves object OKSize = 12 // bytes of its leaves object OKRecovery = 13 // empty, or SHA-256 of a key that may replace a lost owner key OKSigning = 14 // reserved for the zone's signing keys; empty OKExtensions = 15 // extensions, as a record set's OKLapse = 16 // Unix seconds after which an unmined state is not believed OKGuard = 17 // optional: the second key from this state on, as a record set's OKGuardSig = 18 // optional: the previous state's guard's field signature OKLast = OKGuardSig )
The origin state's keys (docs/spec.md section 6).
const ( MaxPiece = 128 << 10 // bytes of a leaves object one piece carries MaxPieceRecord = MaxPiece + 512 // a piece, encoded )
Bounds of a leaves piece (docs/spec.md section 12).
const ( PKMagic = 0 PKZone = 1 // the chain's identifier PKGenesis = 2 // the chain's genesis key PKAnchor = 3 // the chain's anchor: txid || uint32be(vout) PKWriter = 4 // who signs the piece PKData = 5 // SHA-256 of the whole leaves object PKSize = 6 // bytes of the whole leaves object PKIndex = 7 // which piece, from 0 PKBytes = 8 // the object's bytes from index * MaxPiece PKLast = PKBytes )
The leaves piece's keys.
const ( MaxProofLeaves = 64 // leaves at one name a proof carries MaxProof = 2 << 20 // a proof, encoded )
Bounds of a proof's byte form (docs/spec.md section 13).
const ( RKMagic = 0 RKID = 1 // the record set's identifier: 32 bytes, the same in every state RKSeq = 2 // 0 for the first state, then one more each state RKGenesis = 3 // the owner at seq 0, 33 bytes; the same in every state RKOwner = 4 // who signs this state; the genesis key at seq 0 RKAnchor = 5 // the outpoint the first state spent: txid || uint32be(vout) RKRoot = 6 // the RFC 6962 root over the leaves RKCount = 7 // the number of leaves RKData = 8 // SHA-256 of the leaves object RKSize = 9 // bytes of the leaves object RKAccepts = 10 // commitments to origins: distinct, ascending RKExtensions = 11 // extensions: distinct and ascending by kind RKLapse = 12 // Unix seconds after which an unmined state is not believed RKGuard = 13 // optional: the second key from this state on (section 5.1) RKGuardSig = 14 // optional: the previous state's guard's field signature RKLast = RKGuardSig )
The record set state's keys (docs/spec.md section 5).
const ( MaxRecord = 16 << 10 // any record, encoded MaxLeaf = 16 << 10 // a leaf, encoded MaxLabel = 63 // a label's bytes MaxNameWire = 200 // a relative name's labels with their length bytes MaxDNSName = 255 // an absolute name on the wire, its root byte included MaxParts = 16 // parts of one record's data MaxPartBytes = 4096 // a byte-string part MaxValues = 64 // records of one leaf MaxType = 65535 MaxTTL = 1<<31 - 1 MaxSetCount = 1 << 20 // leaves of a record set MaxSetSize = 16 << 20 // a record set's leaves object, bytes MaxOriginCount = 4096 // an origin's own leaves MaxOriginSize = 1 << 20 // an origin's leaves object, bytes MaxAccepts = 64 MaxExtensions = 8 MaxExtension = 1024 // an extension's body MaxSerial = 1<<32 - 1 MaxBody = 8192 // an attached record's body MaxAddresses = 32 MaxProtocols = 8 MaxProtocol = 32 MaxAccount = 512 MaxCADomain = 253 MaxSafe = 1<<53 - 1 MaxGuardSig = 72 // a guard's strict DER signature )
Bounds on what a record, a leaf and a leaves object carry.
const KeyIDLeaves = "leaves"
KeyIDLeaves locks a leaves piece's carrier and the trees that fund them (docs/spec.md sections 7 and 12).
const LabelBinding = "_bweb"
LabelBinding is the first label of a binding to a bweb site, _bweb.<name>.
const MaxGrantKeys = 64
MaxGrantKeys bounds the keys one grant lists.
const MaxPermission = len("bdns/write/") + borgrec.MaxResource
MaxPermission is the longest permission a grant asks: borg's bound on a resource (borg docs/spec.md section 5A.2) and its service and action.
const TypeCAA = 257
TypeCAA is the CAA record type (RFC 8659), a protected type.
const TypeMemberRule = 65534
TypeMemberRule is the leaf type of a member rule (docs/spec.md section 4.1): the last of RFC 6895's private-use types, 65,280 to 65,534. A renderer never writes a leaf of this type as a record; it decides which members a name answers.
Variables ¶
var ( ErrShape = errors.New("zonerec: transaction has the wrong shape") ErrBEEF = chaintoken.ErrBEEF ErrZone = errors.New("zonerec: record is not for this topic's chain") ErrLock = errors.New("zonerec: output script is not the canonical one for its key") ErrTokenInput = errors.New("zonerec: token does not spend its predecessor, or its chain tree at seq 0") ErrAnchor = errors.New("zonerec: anchor is not the outpoint the first token spends") ErrContinuity = errors.New("zonerec: state does not follow its predecessor") ErrSerial = errors.New("zonerec: serial is not greater than the previous state's") ErrRecovery = errors.New("zonerec: recovery differs from the previous state's") ErrFieldSig = errors.New("zonerec: field signature is not strict or does not verify under its signer") ErrUnmined = errors.New("zonerec: proof does not verify against the host's headers") ErrScript = errors.New("zonerec: an unmined token's input does not unlock the output it spends") ErrLapsed = errors.New("zonerec: an unmined state's lapse time has passed") ErrOrphan = errors.New("zonerec: the host does not hold the state this one follows") ErrFork = errors.New("zonerec: the host holds another successor of the same state") ErrNoLeaves = errors.New("zonerec: the host does not hold the state's whole leaves object") ErrPiece = errors.New("zonerec: a leaves piece is not a piece of its object") ErrMineable = errors.New("zonerec: carrier is mineable") ErrUnlock = errors.New("zonerec: unlocking script is not one canonical signature push") ErrFunding = errors.New("zonerec: carrier does not spend a funding output of its key, or does not carry its value") ErrWriter = errors.New("zonerec: a leaves piece's writer may not sign the chain's next state") ErrHeld = errors.New("zonerec: the host already holds a piece of this place, or a record of the same writer, kind and name as late") ErrFull = errors.New("zonerec: the host holds its bound of pieces that no kept state names, or of the writer's live findings") ErrUnsupported = errors.New("zonerec: a retired tag, or an attached record of a kind this version does not admit") ErrExpiry = errors.New("zonerec: a record's expiry is further ahead of the host's clock than its kind's bound") ErrUnnamed = errors.New("zonerec: no live member names what the record is about") ErrNotBdns = errors.New("zonerec: transaction is not for this topic") ErrHostConfig = errors.New("zonerec: host configuration or previous coins out of range") )
The transaction refusals (docs/spec.md section 12), beside the record refusals. A transaction is refused for the first rule it breaks.
var ( TagRecordSet = []byte{0x62, 0x64, 0x01} TagFunding = []byte{0x62, 0x64, 0x02} TagOrigin = []byte{0x62, 0x64, 0x03} TagAttached = []byte{0x62, 0x64, 0x04} TagHost = []byte{0x62, 0x64, 0x05} )
The tags a script carries before its record. TagAttached and TagHost are retired: version 2 carries those records on carriers, claimed by their magic, and an output that claims either tag is refused (unsupported).
var ( MagicRecordSet = []byte("bdr\x01") MagicOrigin = []byte("bdo\x01") MagicAttached = []byte("bda\x01") MagicHost = []byte("bdh\x01") )
The records' magics: four bytes, the last the version.
var ( ErrLabel = errors.New("zonerec: not a label") ErrName = errors.New("zonerec: a name is over its bound, or has a wildcard label that is not first") ErrPart = errors.New("zonerec: a data part is malformed, or two byte parts are adjacent") ErrData = errors.New("zonerec: record data is missing, over the bound, or not distinct and ascending") ErrLeaf = errors.New("zonerec: a leaf is not its five items") ErrScope = errors.New("zonerec: a scope is not empty or 32 bytes that are not all zero, or an origin's own leaf has one") ErrOrder = errors.New("zonerec: leaves are not in key order") ErrDuplicate = errors.New("zonerec: two leaves share a key") ErrKey = errors.New("zonerec: not a canonical compressed public key, or the anyone key") ErrGenesis = errors.New("zonerec: the owner at seq 0 is not the genesis key") ErrID = errors.New("zonerec: the identifier is not the one its genesis key and outpoint give") ErrExtension = errors.New("zonerec: an extension is malformed, or kinds are not distinct and ascending") ErrMember = errors.New("zonerec: not a member body") ErrFinding = errors.New("zonerec: not a finding body") ErrChallenge = errors.New("zonerec: not a challenge body") ErrMethods = errors.New("zonerec: validation methods are malformed, not distinct and ascending, or have no certificate authority") ErrAddress = errors.New("zonerec: addresses are missing, not 4 or 16 bytes, IPv4-mapped, or not distinct and ascending") ErrProtocol = errors.New("zonerec: protocols are over the bound, not ALPN identifiers of the allowed characters, or not distinct and ascending") ErrCA = errors.New("zonerec: not a certificate authority's domain") ErrAccount = errors.New("zonerec: an account with no certificate authority, or not of URI characters without \";\"") ErrLocation = errors.New("zonerec: not an IATA metro code") ErrProof = errors.New("zonerec: the proof does not hold") ErrPresent = errors.New("zonerec: the key is present") )
Refusals beyond bcommon's record ones. Reason gives each a fixed label.
var ( ErrMismatch = errors.New("zonerec: the leaves object does not match the state") ErrRendererType = errors.New("zonerec: a leaf of a type the renderer writes, or of a type that is not data") ErrCNAME = errors.New("zonerec: a CNAME at the apex, beside another type, or of more than one record") ErrCut = errors.New("zonerec: a leaf at or below a delegation") ErrNoName = errors.New("zonerec: data of a type that names a host holds no name part") ErrMemberRule = errors.New("zonerec: a member rule leaf is malformed, at a wildcard, or beside fixed addresses") )
The refusals of the checks of spec section 8: C1 ErrMismatch, C2 ErrScope, then C3 to C7 in order.
var AnyoneKey = []byte{
0x02, 0x79, 0xbe, 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07,
0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xce, 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8, 0x17, 0x98,
}
AnyoneKey is BRC-43's anyone counterparty: the generator point, whose private key is 1. No record names it.
var Chains = []Chain{ChainRecordSet, ChainOrigin}
Chains lists them, for a host's metrics.
var EmptyRoot = commit.RootOfLeafHashes(nil)
EmptyRoot is the root of no leaves: SHA-256 of the empty string.
var ErrGuard = errors.New("zonerec: a protected name changed without the guard's signature")
ErrGuard is the guard check's refusal (spec section 5.1): a state that changes a protected name without the previous state's guard's signature.
var Kinds = []Kind{KindRecordSet, KindOrigin, KindLeaves, KindMemberRecord, KindFindingRecord, KindChallengeRecord, KindHostRecord}
Kinds lists them, for a host's metrics.
var MagicPiece = []byte("bdl\x01")
MagicPiece is a leaves piece's magic.
var RecordKinds = []Kind{KindMemberRecord, KindFindingRecord, KindChallengeRecord, KindHostRecord}
RecordKinds are the kinds of record a carrier brings (spec section 12.7).
Functions ¶
func Ahead ¶ added in v0.3.0
Ahead is how far ahead of a host's clock an attached record of kind may expire, in seconds, and false for a kind version 2 does not admit.
func ChangesProtected ¶ added in v0.3.0
ChangesProtected reports whether a state with guard and leaves changes a protected name from the state before, with beforeGuard and beforeLeaves: its protected leaves are not those of the state before, byte for byte in key order, or its guard differs.
func CheckAnswer ¶
CheckAnswer applies C3 to C7 to what an origin answers: the leaves are one zone, so C4 and C5 hold whatever scope a leaf was written with.
func CheckGuard ¶ added in v0.3.0
func CheckGuard(before, s *State, beforeLeaves, leaves []*Leaf, spent transaction.Outpoint) error
CheckGuard is the guard check of spec section 5.1, a pure function of two states of one chain, their leaves (each state's own, as check C1 read them) and the outpoint the later token spends. before is the guarded state before s: the latest earlier state this check did not mark, which is the state before unless that one was marked; nil at seq 0. A caller keeps it for each chain, so a thief who writes an unsigned change twice is marked twice. It returns nil, or ErrGuard when:
- s carries a guard signature and the state before names no guard (none can be checked);
- s carries a guard signature that is not strict low-S DER or does not verify, over GuardSigned, under derive(guard before, "guard");
- s carries none, the state before names a guard, and s changes a protected name (ChangesProtected).
The guard that counts is the guarded state before's, never the last state a node rendered, so every node decides alike. A host admits a state that fails and marks it not renderable (label guard), as it does for checks C2 to C7.
func CheckKey ¶
CheckKey holds b to the key rule of spec section 1: a canonical compressed point (bcommon guard.ParsePubKey) that is not the anyone key.
func CheckLeaves ¶
CheckLeaves applies checks C3 to C7 of spec section 8 to one state's leaves, in that order, each over all the leaves in the order given, and returns the first refusal:
C3 ErrRendererType a leaf of a type the renderer writes or that is not data
C4 ErrCNAME a CNAME at the apex, of more than one record, or at a
name with another type under the same scope
C5 ErrCut a leaf at or below a name with an NS leaf, off the apex
C6 ErrNoName a record of a type that names a host with no name part
C7 ErrMemberRule a member rule leaf that is malformed, at a wildcard,
or at a name with an A, AAAA or CNAME leaf under the
same scope
C5 reads a delegation as cutting every leaf an origin could answer beside it: of the same scope, or with either scope empty. It lets through the NS leaves at the cut, DS at the cut, and A and AAAA leaves whose name an NS record of the cut gives as a single name part relative to the origin.
func CheckOrder ¶
CheckOrder holds leaves to key order with no key twice: ErrDuplicate for two leaves of one key, ErrOrder for a leaf before its place.
func Commitment ¶
Commitment is what a record set lists for an origin it answers for: SHA-256 of the label, the origin's identifier and its secret.
func EncodeLeaves ¶
EncodeLeaves writes the leaves object: the canonical CBOR array of the leaves in key order. It refuses a leaf DecodeLeaf refuses, leaves out of order, a key twice, more than maxCount leaves and more than maxSize bytes.
func EncodeName ¶
EncodeName writes a relative name as its canonical CBOR array of text labels, refusing what DecodeName refuses.
func FundingScript ¶
FundingScript is a funding output locked to key: <key> OP_CHECKSIG <62 64 02> OP_DROP. A chain tree's outputs and a leaves tree's are each this, under their own key.
func GuardSign ¶ added in v0.3.0
func GuardSign(ctx context.Context, guard wallet.Interface, originator string, s *State, spent transaction.Outpoint) ([]byte, error)
GuardSign is a tool's: the guard's field signature on s, by the guard's wallet under its "guard" key of the chain's protocol, for the outpoint the token will spend. s.Record is not read; the caller sets the returned signature as the state's guard signature and encodes it again.
func GuardSigned ¶ added in v0.3.0
func GuardSigned(s *State, spent transaction.Outpoint) ([]byte, error)
GuardSigned is what a guard's field signature on s covers: Signed's bytes for the state's record written without its guard signature (key 14 of a record set, 18 of an origin), and the outpoint the token spends. The owner's signature then covers the record with it.
func LockingKey ¶
LockingKey is the key an identity's output is locked to under d.
func MemberDerivation ¶ added in v0.3.0
func MemberDerivation(keyID string) pushdrop.Derivation
MemberDerivation is the derivation of keyID under the attached and host records' protocol, [1, "bdns member"], with counterparty anyone: KeyIDAttach for an attached record's carrier and funding tree, KeyIDHost for a host record's.
func Permission ¶ added in v0.4.0
Permission is what a grant naming an organization asks of a member's writer at name in the zone of domain: the borg permission bdns/write/<domain>/<name>, both written in full, lower case, with no final dot; for the apex, name is the domain. An error when the two are longer than a permission's resource (192 bytes), or the domain breaks the grammar: no writer is admitted by the organization at such a name.
func Protected ¶ added in v0.3.0
Protected reports whether a leaf is at a protected name (docs/spec.md section 5.1): a binding (a name whose first label is _bweb, of any type), a CAA leaf, a member rule leaf, the NS leaf at the apex, or a TXT leaf at a wildcard name, which can answer for a _bweb name with no leaf of its own.
func Reason ¶
Reason is the fixed label of a refusal: bcommon's record labels, then this package's, else "other".
func Reasons ¶
func Reasons() []string
Reasons are every label Reason gives but "other": bcommon's record labels, then this package's. A host presets a counter for each.
func RecordSetID ¶
RecordSetID is a record set's identifier: SHA-256 of the label, the genesis key, and the anchor: the outpoint its first state spent, the txid in hash byte order.
func Root ¶
Root is the RFC 6962 root over leaves, which are in key order: each leaf's hash is commit.HashLeaf of its encoding.
func SameRecord ¶ added in v0.3.0
SameRecord reports whether two kept records are of one writer, kind and name: the place one record holds and a later one replaces.
func Signed ¶
func Signed(tag, rec []byte, spent transaction.Outpoint) []byte
Signed is what a token's field signature covers: the tag, the record and the outpoint the token spends (its predecessor's, or the anchor at seq 0), the txid in hash byte order then the index as four big-endian bytes. The outpoint binds the signature to the token's place in the chain: the output copied into a transaction that spends anything else does not verify.
func SignedBy ¶
func SignedBy(tx *transaction.Transaction, vout int, c Chain, identity []byte, spent transaction.Outpoint) bool
SignedBy reports whether the token at output vout of tx carries a strict field signature of identity's "state" key over its tag, its record and the outpoint spent.
func Supersedes ¶ added in v0.4.0
Supersedes reports whether record k takes the place of have, another carrier in the same place (spec section 12.7, rule 9): a strictly later expiry, or the same expiry and the lower txid, compared in its display form (hex as written), then the lower output index. Admission and a restore decide alike by it, so every host keeps the same record whatever order it saw them in.
func TokenLock ¶
func TokenLock(ctx context.Context, signer wallet.Interface, originator string, s *State, spent transaction.Outpoint) (*script.Script, error)
TokenLock builds a state token's locking script: locked to derive(owner, "state") and signed, over Signed's bytes for the outpoint the token will spend, by signer's wallet under its own "state" key. signer is the owner's wallet, or at a change of owner the previous owner's.
func TokenScript ¶
TokenScript is a state token's output: <key> OP_CHECKSIG <tag> <record> <signature> OP_2DROP OP_DROP. The signature is over tag || record.
func TopicLetters ¶
TopicLetters is the identifier's first 16 bytes read as a big-endian number and written in base 26 with the digits a to z, padded on the left with a to 28 letters.
func ValidDomain ¶
ValidDomain reports a lower-case DNS name in dotted form: at least two letter-digit-hyphen labels, 253 bytes at most, no trailing dot, and a last label that is not all digits.
func ValidLabel ¶
ValidLabel reports a label: 1 to 63 bytes of lower-case letters, digits, hyphen and underscore, or the single byte "*".
Types ¶
type Absence ¶
Absence proves that a state holds no leaf in a range of keys: the leaf before the range and the leaf after it, adjacent in the state. Before is nil when the range sorts before every leaf, After when it sorts after every leaf, and both when the state has no leaves.
type Admission ¶
type Admission struct {
Kind Kind
Txid [32]byte
Outputs []int
Retain []int
// For a token: the state, whether the token is proven, the outpoint it
// spends (its predecessor, or its anchor at seq 0), the unmined rival it
// replaces, an unknown critical extension's kind, and a failed check.
State *State
Mined bool
Spends transaction.Outpoint
Replaces *transaction.Outpoint
Critical *uint64
// Check is the label of the check of C2 to C7 the state fails, else
// "guard" when it fails the guard check, or "": such a state is admitted
// and is not rendered (spec section 12.2, rules 16 and 17).
Check string
// For a leaves piece or a record: the piece and the funding outpoint.
Piece *Piece
Funding transaction.Outpoint
// For an attached or host record: the record. Replaces, above, is then
// the kept record of the same writer, kind and name it replaces.
Record *Kept
}
Admission is what a host admits from one transaction.
type Admitter ¶
type Admitter struct {
Zone [32]byte
Headers chaintracker.ChainTracker
MaxBEEF int
Now func() time.Time
View View
}
Admitter is what admission needs beyond the submission: the topic's chain, a chain tracker over the host's headers, its BEEF bound (zero is the floor, DefaultMaxBEEF), its clock and its view of the topic.
type Attached ¶
type Attached struct {
Zone [32]byte
Kind uint64
Writer []byte
Name Name
Expiry uint64
Body []byte
Extra cbor.Map
}
Attached is a record attached to a record set or an origin.
func DecodeAttached ¶
DecodeAttached reads an attached record's payload, key by key. A member's, a finding's and a challenge text's bodies are held to their forms; every other kind's body is opaque and only bounded.
type Chain ¶
type Chain string
Chain is which of the two chains a topic carries.
func ChainOf ¶
ChainOf is the chain whose identifier id is, for a genesis key and an anchor: a record set's and an origin's are hashed under different labels.
func (Chain) Derivation ¶
func (c Chain) Derivation(keyID string) pushdrop.Derivation
Derivation is the chain's derivation of keyID, with counterparty anyone, so anyone derives a key from the identity key alone.
type Challenge ¶ added in v0.3.0
type Challenge struct {
Texts []string
}
Challenge is the body of an attached record of kind challenge: {1: texts}, the values its writer, an admitted member of the record's name, asks for at _acme-challenge.<name>. One to four texts, each 1 to 255 bytes of the base64url alphabet, distinct and ascending.
func DecodeChallenge ¶ added in v0.3.0
DecodeChallenge reads a challenge body.
type CheckFailure ¶ added in v0.1.1
CheckFailure is a refusal by one of checks C2 to C7 (spec section 8): the leaves object is the state's (C1 holds), and what it holds may not be rendered. A host admits such a state and keeps it for the chain's continuity (spec section 12.2).
func Failed ¶ added in v0.1.1
func Failed(err error) (*CheckFailure, bool)
Failed reports whether err is a refusal by one of checks C2 to C7, and which.
func (*CheckFailure) Error ¶ added in v0.1.1
func (e *CheckFailure) Error() string
func (*CheckFailure) Label ¶ added in v0.1.1
func (e *CheckFailure) Label() string
Label is the check's label (Reason).
func (*CheckFailure) Unwrap ¶ added in v0.1.1
func (e *CheckFailure) Unwrap() error
type Claim ¶
type Claim string
Claim is what an output claims to be.
const ( ClaimNone Claim = "" ClaimRecordSet Claim = "record-set" ClaimOrigin Claim = "origin" ClaimAttached Claim = "attached" ClaimHost Claim = "host" ClaimPiece Claim = "leaves" ClaimFunding Claim = "funding" // ClaimRetired is an output that claims the retired attached or host // record tag, 62 64 04 or 62 64 05: a form no writer makes. ClaimRetired Claim = "retired" )
The claims.
func Classify ¶
Classify says what a locking script claims, reading only its first push after <33-byte key> OP_CHECKSIG: a token's tag; the start of a leaves piece, an attached record or a host record, each a carrier's one field; a retired tag; or, for the whole 40-byte script <key> OP_CHECKSIG <tag> OP_DROP, the funding tag.
type Data ¶
type Data []Part
Data is one resource record's data: 1 to 16 parts, no two byte parts adjacent. The codec does not know record types.
func DecodeData ¶
DecodeData reads one record's data from its canonical CBOR array.
func (Data) Encode ¶
Encode writes the data as its canonical CBOR array, refusing what DecodeData refuses.
func (Data) Join ¶
Join returns the data with adjacent byte parts joined, as an encoder writes it. A joined part over 4,096 bytes is still refused by Check.
func (Data) Wire ¶
Wire is the data in DNS wire form under origin, the origin's labels leftmost first: the parts in order, each name written uncompressed with its root byte, and the origin's labels appended to a relative one. It is nil when the data does not hold to section 3, when origin has a label that is not 1 to 63 bytes, or when a name would pass 255 bytes on the wire.
type Extension ¶
Extension is one extension of a state: a kind, whether a reader that does not know the kind must stop, and a body of at most 1,024 bytes.
type Finding ¶ added in v0.3.0
type Finding struct {
Host []byte
}
Finding is the body of an attached record of kind finding: {1: host key}, the host behind the record's name that the writer says fails. It makes a renderer challenge that host at once and removes nothing by itself.
func DecodeFinding ¶ added in v0.3.0
DecodeFinding reads a finding body.
type Held ¶
type Held struct {
Outpoint transaction.Outpoint
State *State
Mined bool
}
Held is a state the host keeps: its token's outpoint, the state, and whether the host knows the token mined.
type Host ¶
type Host struct {
Host []byte
Addresses [][]byte
Port uint16
Protocols []string
CA string
Account string
Location string
Expiry uint64
Methods []string
Extra cbor.Map
}
Host is a host's claim of where it answers.
func DecodeHost ¶
DecodeHost reads a host record's payload, key by key. Addresses and protocols ascend by their own bytes.
type Kept ¶ added in v0.3.0
type Kept struct {
Outpoint transaction.Outpoint
// Attached is an attached record's, nil for a host record.
Attached *Attached
// Host is a host record's, nil for an attached record.
Host *Host
// Names is the host key a member or a finding names, else nil.
Names []byte
}
Kept is an attached or host record a topic keeps (spec section 12.7): the carrier's output and the record it carries.
func ReadKept ¶ added in v0.3.0
func ReadKept(o *transaction.TransactionOutput, op transaction.Outpoint) (*Kept, error)
ReadKept reads a record off a carrier's output: its one field decoded as an attached or a host record by the claim it makes. It checks the record's own rules and nothing of the carrier.
func (*Kept) Kind ¶ added in v0.3.0
Kind is the record's kind; "" for an attached kind version 2 does not admit.
func (*Kept) Live ¶ added in v0.3.0
Live reports whether the record is believed at the Unix time now: now is at or before its expiry.
type Kind ¶
type Kind string
Kind is what an admitted transaction is to the topic.
const ( KindRecordSet Kind = "record-set" KindOrigin Kind = "origin" KindLeaves Kind = "leaves" // The records of spec section 12.7, each on a carrier. KindMemberRecord Kind = "member" KindFindingRecord Kind = "finding" KindChallengeRecord Kind = "challenge" KindHostRecord Kind = "host" )
The kinds.
func RecordKind ¶ added in v0.3.0
RecordKind is the kind of record an attached record of kind is, and false for a kind version 2 does not admit.
type Leaf ¶
type Leaf struct {
Name Name
Type uint16 // 1 to 65,535
TTL uint32 // 0 to 2,147,483,647
// Data is 1 to 64 records' data, distinct, ascending by encoded bytes.
Data []Data
// Scope is empty, or the 32-byte identifier of the one origin this leaf
// stands under.
Scope []byte
}
Leaf is one record set in the DNS sense: every record of one name and type (spec section 4). It is the canonical CBOR array [name, type, ttl, data, scope].
func Answer ¶
Answer is what an origin answers (spec section 6): the record set's leaves with an empty scope, then its leaves with the origin's identifier as scope, then the origin's own leaves; of leaves of one name and type the later wins. The result is ordered by name and type as leaf keys are, and its leaves keep the scope they were written with.
Both inputs are in key order with no key twice. An own leaf with a scope is refused (ErrScope), and so is a result that does not hold to checks C3 to C7 read as one zone (CheckAnswer). The origin's domain is not known here: a name that would pass 255 bytes under it is the renderer's to leave out and report.
func DecodeLeaf ¶
DecodeLeaf reads a leaf, refusing it for the first rule it breaks: the bound, canonical CBOR, an array of five items, then item by item.
func DecodeLeaves ¶
DecodeLeaves reads a leaves object of at most maxSize bytes and maxCount leaves: the bound, canonical CBOR, an array, then leaf by leaf, each within MaxLeaf and after the one before it in key order.
func LeavesOf ¶ added in v0.3.0
LeavesOf reads a kept state's leaves back through the view: its object, held to the state by check C1. A failure of C2 to C7 is not an error here.
func (*Leaf) Encode ¶
Encode writes the leaf canonically. It refuses what DecodeLeaf refuses, so a leaf this package writes is one it reads.
func (*Leaf) Key ¶
Key is the leaf's key: for each label from the last to the first, the label then one zero byte; then one more zero byte; then the type as two big-endian bytes; then the scope, or 32 zero bytes when it is empty. Leaves are ordered by their keys as byte strings, which orders their names as RFC 4034 section 6.1 does.
type Member ¶
type Member struct {
Host []byte
}
Member is the body of an attached record of kind member: {1: host key}. The rule a member is held to is the zone's member rule leaf, not the member's.
func DecodeMember ¶
DecodeMember reads a member body.
type MemberRule ¶ added in v0.3.0
type MemberRule struct {
Rule uint64
Keys [][]byte
// Org is the organization's identity key and Hall the hall its chains
// live in (borg docs/spec.md section 10.1). A grant may name one.
Org []byte
Hall string
}
MemberRule is the rule a name's members are held to: grant, with the keys whose members it admits and, when Org is set, the borg organization whose members holding the name's permission it admits (Permission); or advert, with none.
func DecodeMemberRule ¶ added in v0.3.0
func DecodeMemberRule(l *Leaf) (*MemberRule, error)
DecodeMemberRule reads a member rule leaf, refusing (ErrMemberRule) one that is not of the type, is at a wildcard name, has a TTL other than 0, is not one record of one byte part, names no rule, or whose keys are not 1 to 64 canonical keys, distinct and ascending, for a grant of keys, 0 to 64 for a grant naming an organization, or are any for an advert. A grant naming an organization names a canonical key and a hall identifier of borg's grammar.
func (*MemberRule) Grants ¶ added in v0.3.0
func (r *MemberRule) Grants(key []byte) bool
Grants reports whether the rule is a grant that lists key. An organization's members are the renderer's to read (Permission).
func (*MemberRule) Leaf ¶ added in v0.3.0
func (r *MemberRule) Leaf(name Name, scope []byte) (*Leaf, error)
Leaf is the member rule as a leaf at name with scope: TTL 0, one record whose data is one byte part. A grant of keys alone is byte 1 then the keys; a grant naming an organization is byte 3, the organization's key, the hall's length in one byte, the hall, then the keys; an advert is byte 2.
type Name ¶
type Name []string
Name is a name of spec section 2: labels, leftmost first, each a CBOR text string. A relative name stands under an origin a record does not know; no labels is the origin itself. An absolute name is the same form read as a full domain name; no labels is the root.
func DecodeName ¶
DecodeName reads a relative name from its canonical CBOR array.
func (Name) Check ¶
Check holds a relative name to section 2: every label a label, "*" only first, and at most 200 bytes with the labels' length bytes.
func (Name) CheckAbsolute ¶
CheckAbsolute holds an absolute name to section 2: as Check, and at most 255 bytes with the labels' length bytes and the root byte.
func (Name) KeyPrefix ¶
KeyPrefix is what every leaf key of exactly this name starts with: the labels last to first, each followed by one zero byte, then one more zero byte.
type Origin ¶
type Origin struct {
ID [32]byte
Seq uint64
Genesis []byte
Owner []byte
// AnchorTxid and AnchorVout are the outpoint the chain's seq 0 token
// spent (key 5), as a record set's.
AnchorTxid [32]byte
AnchorVout uint32
Base [32]byte
Secret [32]byte
Serial uint32
Root [32]byte
Count uint64
Data [32]byte
Size uint64
Recovery []byte
Signing [][]byte
Extensions []Extension
Lapse uint64
// Guard and GuardSig are keys 17 and 18, nil when absent.
Guard []byte
GuardSig []byte
// Extra holds keys above OKLast, verbatim.
Extra cbor.Map
}
Origin is one state of an origin: a zone apex that answers with a record set's leaves and its own. It does not carry its domain.
func DecodeOrigin ¶
DecodeOrigin reads an origin state, key by key, then the rules that join keys, as DecodeRecordSet.
func (*Origin) AnswersWith ¶
AnswersWith reports whether the origin answers with the record set's state s: s is a state of the origin's base, and it lists the origin's commitment. That s is the record set's latest state is the caller's.
func (*Origin) Commit ¶
Commit is RecordSet.Commit for an origin state and its own leaves, none of which has a scope.
func (*Origin) Commitment ¶
Commitment is the value a record set lists to answer for this origin.
type Part ¶
type Part struct {
// Bytes is a byte part: 1 to 4,096 bytes. Unused by a name part.
Bytes []byte
// IsName marks a name part. Absolute is its form: false for a name
// relative to the origin, true for an absolute name.
IsName bool
Absolute bool
Name Name
}
Part is one part of a record's data (spec section 3): wire-format bytes copied as they are, or a name the renderer writes out.
type Piece ¶
type Piece struct {
Zone [32]byte
Genesis []byte
AnchorTxid [32]byte
AnchorVout uint32
Writer []byte
Data [32]byte
Size uint64
Index uint64
Bytes []byte
// Chain is the chain Zone names, set by DecodePiece.
Chain Chain
// Extra holds keys above PKLast, verbatim.
Extra cbor.Map
}
Piece is one piece of a leaves object: the object cut every MaxPiece bytes, so one object has one cutting.
func DecodePiece ¶
DecodePiece reads a leaves piece: the record rules with its own bound, key by key, then the rules that join keys, in this order: the zone is the identifier the genesis key and the anchor give, as a record set or as an origin (id); then the object is within its chain's bound, the index is one of its pieces and the bytes are that piece's length (piece).
type Presence ¶
Presence proves one leaf of a state: the leaf, its index, and its RFC 6962 audit path, leaf to root. The state's count and root are the verifier's own, from the state.
type Proof ¶
type Proof struct {
// Whole is every leaf at Name, whatever its type and scope; else the
// one leaf of Name, Type and Scope.
Whole bool
Name Name
Type uint16
Scope []byte
// Present are the leaves there, in key order.
Present []*Presence
// Before and After are the leaves next to the key or the name's leaves:
// nil at either end of the state, and both nil for one leaf proven
// present, which needs no neighbor.
Before, After *Presence
}
Proof is the byte form of a proof against one state (spec section 13): for one key (a name, a type and a scope) or for a whole name, the leaves there, each with its path, and the neighbors that show there is no other. It answers both ways: Present holds what is there, and when it is empty the neighbors prove absence (section 4).
func DecodeProof ¶
DecodeProof reads a proof's byte form: the bound, canonical CBOR, the seven items, each of its type and within its rule. It decides nothing about whether the proof holds: Verify does, against a state.
func (*Proof) Encode ¶
Encode writes the proof as its canonical CBOR array [form, name, type, scope, present, before, after], refusing what DecodeProof refuses.
func (*Proof) Verify ¶
Verify holds the proof against a state of count leaves under root. It trusts nothing of the prover. With no leaf present it is section 4's proof of absence. One key present is the leaf under the root, with that key and no neighbor. A whole name present is its leaves, adjacent by index, each under the root with the name's prefix, and on either side a neighbor outside the name, or the end of the state.
type RecordSet ¶
type RecordSet struct {
ID [32]byte
Seq uint64
Genesis []byte
Owner []byte
// AnchorTxid and AnchorVout are the outpoint the chain's seq 0 token
// spent (key 5): the txid in hash byte order. With Genesis it is hashed
// into ID.
AnchorTxid [32]byte
AnchorVout uint32
Root [32]byte
Count uint64
Data [32]byte
Size uint64
Accepts [][32]byte
Extensions []Extension
Lapse uint64
// Guard and GuardSig are keys 13 and 14, nil when absent: a version 1
// state has neither.
Guard []byte
GuardSig []byte
// Extra holds keys above RKLast, verbatim.
Extra cbor.Map
}
RecordSet is one state of a record set: the leaves it commits to and the origins it answers for.
func DecodeRecordSet ¶
DecodeRecordSet reads a record set state, refusing it for the first rule it breaks: the record rules (too-large, cbor, key-type, magic), then key by key in key order (missing, type, the key's own rule), then the rules that join keys, in this order: at seq 0 the owner is the genesis key (genesis), and the identifier is the one the genesis key and the anchor give (id).
func (*RecordSet) Check ¶
Check applies checks C1 and C3 to C7 of spec section 8 to the state and its leaves object, and returns the leaves or the first refusal. A refusal by C2 to C7 is a CheckFailure, returned with the leaves.
func (*RecordSet) Commit ¶
Commit sets the state's root, count, data and size from leaves and returns the leaves object it then commits to.
func (*RecordSet) Encode ¶
Encode writes the record canonically. It refuses what DecodeRecordSet refuses, so a record this package writes is one it reads.
func (*RecordSet) Precedes ¶
Precedes reports whether next may follow s in one record set's chain: the same identifier, genesis key and outpoint, one more seq. The token transactions' own link, and who signs a change of owner, are the module's to check.
func (*RecordSet) UnknownCritical ¶
UnknownCritical reports the first critical extension of a kind the reader does not know. When it reports one, the reader stops rendering the chain at this state and says so. Version 1 defines no kind.
type State ¶
type State struct {
Chain Chain
Set *RecordSet // a record set's state
Origin *Origin // an origin's
// Record is the record's bytes, as the token carries them.
Record []byte
}
State is one state of either chain, read through what the two share.
func DecodeState ¶
DecodeState reads rec as a state of chain c.
func ReadState ¶
func ReadState(tx *transaction.Transaction) (*State, int, error)
ReadState reads the one state token a stored transaction holds, without its parent: how an index reads a token it admitted. The field signature is not checked here, since it covers the outpoint spent and at a change of owner is the previous owner's; SignedBy checks it once both are known.
func (*State) Anchor ¶
func (s *State) Anchor() transaction.Outpoint
Anchor is the outpoint the chain's first token spent.
func (*State) Check ¶
Check applies checks C1 to C7 to the state and its leaves object. A refusal by C2 to C7 is a CheckFailure, returned with the leaves.
func (*State) Follows ¶
Follows holds s to the continuity rules after prev (spec section 12), in their order: the same chain, identifier, genesis key and anchor and one more seq (ErrContinuity); for an origin a greater serial (ErrSerial) and the same recovery (ErrRecovery).
func (*State) GuardSig ¶ added in v0.3.0
GuardSig is the guard signature the state carries, nil when none.
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree is a state's leaves in key order with their keys and hashes: what a holder of the leaves object proves from.
func NewTree ¶
NewTree hashes leaves, which are in key order with no key twice. It refuses a leaf DecodeLeaf refuses.
func (*Tree) ProveAbsent ¶
ProveAbsent proves that no leaf has key, or returns ErrPresent.
func (*Tree) ProveAbsentName ¶
ProveAbsentName proves that no leaf of any type or scope is at name, or returns ErrPresent.
func (*Tree) ProveKey ¶
ProveKey proves the leaf of a name, a type and a scope, or that there is none.
type View ¶
type View interface {
// At is the state kept at seq, or nil.
At(seq uint64) *Held
// Tip is the kept state of the highest seq, or nil.
Tip() *Held
// HasPiece reports whether a piece of the object of data and size is
// held at index.
HasPiece(data [32]byte, size, index uint64) bool
// Loose is how many pieces are held that no kept state names.
Loose() int
// Object is the leaves object of data and size joined from the pieces
// held, or nil while a piece is missing. The bytes are not checked.
Object(ctx context.Context, data [32]byte, size uint64) ([]byte, error)
// GuardedBefore is the guarded state before a state at seq (spec section
// 5.1): the latest kept state below seq that neither checks C2 to C7 nor
// the guard check marked and that has no unknown critical extension, or
// nil. A view may answer any kept state below seq when none of them names
// a guard: the guard check then decides alike whichever it reads.
GuardedBefore(ctx context.Context, seq uint64) (*Held, error)
// Record is the record the topic keeps of kind, writer and name (for a
// host record, of the host key writer; name is not read), or nil. It may
// be one past its expiry that the view has not dropped yet.
Record(kind Kind, writer []byte, name Name) *Kept
// MembersOf are the members the topic keeps that name host, expired ones
// perhaps among them.
MembersOf(host []byte) []*Kept
// Findings are the findings the topic keeps of writer, expired ones
// perhaps among them.
Findings(writer []byte) []*Kept
}
View is what admission reads of what the topic holds, and nothing more: the states kept and the leaves pieces held.