vectors

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 26 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 vectors generates the golden vectors under testdata/vectors from the codec in borgrec. Every value is derived from fixed stand-ins (public test keys, hashes of labels for anything a client draws at random), so the files are reproducible byte for byte; every check the generator makes (a wallet decrypts what was wrapped, a certificate verifies, the SDK still refuses a short protocol name) fails the run when it stops holding.

Index

Constants

View Source
const Created = 1798761600

Created is the vectors' fixed time, 2027-01-01T00:00:00Z.

View Source
const Hall = "example_hall_vkqzmtrwxp"

Hall is the vectors' hall identifier; its suffix is a fixed example.

View Source
const OtherHall = "other_hall_qwertyuiop"

OtherHall is a well-formed hall that is not the vectors' topic.

Variables

View Source
var (
	Org   = party("org", 0x51)
	Alice = party("alice", 0x52)
	Bob   = party("bob", 0x53)
	Carol = party("carol", 0x54)
	// Dave is never a member: the stranger of refusal cases.
	Dave = party("dave", 0x56)
	// Successor is the key an organization hands over to (spec section 3.4).
	Successor = party("successor", 0x57)
)

The parties: the organization and three members.

View Source
var GrantValues = map[string]map[string]string{
	"alice": {"expiry": "2028-01-01T00:00:00Z", "role": "engineer", "scope": "member"},
	"bob":   {"expiry": "2028-01-01T00:00:00Z", "role": "team lead", "scope": "member,admin"},
	"carol": {"expiry": "2027-07-01T00:00:00Z", "role": "contractor", "scope": "member"},
}

GrantValues are the members' grant fields in the clear.

View Source
var OrgOpaque = party("org-opaque", 0x55)

OrgOpaque is the second test organization, whose roll is opaque.

Functions

func Generate

func Generate() (map[string][]byte, error)

Generate builds every vector file. It fails when a check stops holding.

func GroupID

func GroupID() [16]byte

GroupID is the vectors' group identifier: the first 16 bytes of a label.

func Names

func Names(files map[string][]byte) []string

Names returns the file names in a stable order.

Types

type Headers

type Headers map[uint32]chainhash.Hash

Headers is the test chain's block headers: a merkle root per height. It is the chain tracker the transaction vectors are admitted against.

func (Headers) CurrentHeight

func (h Headers) CurrentHeight(context.Context) (uint32, error)

CurrentHeight is the highest height held.

func (Headers) IsValidRootForHeight

func (h Headers) IsValidRootForHeight(_ context.Context, root *chainhash.Hash, height uint32) (bool, error)

IsValidRootForHeight holds root to the one the test chain has at height.

type Party

type Party struct {
	Name string
	Priv *ec.PrivateKey
}

Party is one public test identity: 32 bytes of one value as the private key. Never for real use.

func (Party) Pub

func (p Party) Pub() []byte

Pub is the party's compressed identity key.

func (Party) Wallet

func (p Party) Wallet() wallet.Interface

Wallet is a BRC-100 wallet over the party's key.

type Scenario

type Scenario struct {
	Grants      map[string]*borgrec.Grant // by member name
	GrantRecs   map[string][]byte
	Commit      map[string][32]byte // stand-in grant commitments (carrier txids)
	OpaqueGrant *borgrec.Grant
	OpaqueRec   []byte

	Orgs      []*borgrec.Org
	OrgRecs   [][]byte
	OrgTxids  [][32]byte // stand-ins for each org token's mined txid
	OpaqueOrg *borgrec.Org
	OpaqueRaw []byte

	Groups     []*borgrec.Group
	GroupRecs  [][]byte
	GroupTxids [][32]byte
	EpochKeys  [][32]byte // by epoch
	EpochIDs   [][32]byte // by epoch

	Wraps    []*borgrec.WrapRecord
	WrapRecs [][]byte
	WrapIVs  []map[string][32]byte
}

Scenario is the story every record vector tells: an organization grants three members, makes a group of two, adds the third without rotating, removes one (the epoch rotates and the removed member cannot open it), rotates on schedule, and offboards the removed member from the roll.

func Build

func Build() (*Scenario, error)

Build makes the scenario and checks it as it goes.

Jump to

Keyboard shortcuts

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