vectors

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 27 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 internal/secrec. 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 opens what was wrapped to it, a member of another epoch does not, BRC-369's own vectors still reproduce) fails the run when it stops holding.

Index

Constants

View Source
const Created = 1798761600

Created is the vectors' fixed time, in Unix seconds.

View Source
const Crypt = "example_crypt_hmqzvtkwrx"

Crypt is the vectors' crypt identifier; its suffix is a fixed example.

View Source
const Hall = "example_hall_vkqzmtrwxp"

Hall is the identifier of the hall the vectors' group lives in.

View Source
const OtherCrypt = "other_crypt_qwertyuiop"

OtherCrypt is a well-formed crypt that is not the vectors' topic.

View Source
const PadBlock = 256

PadBlock is the block the scenario pads payloads to.

Variables

View Source
var (
	Org   = party("org", 0x51)
	Alice = party("alice", 0x52)
	Bob   = party("bob", 0x53)
	Carol = party("carol", 0x54)
	Dave  = party("dave", 0x56)
)

The parties: the organisation that owns the vault, three members of its group, and a key that is never a member. They are the identities the group substrate's own vectors use, so the two vector sets describe one scenario.

View Source
var GroupEpochs = []GroupEpoch{
	{0, h32("f32d56bd890f105f1e9731d9607b464078644b0ce1df8e7a87196589bd0266ca"),
		h32("3d67c0041301c203085c253fb02a70d5d86ebdbe411759a18c7e63a40af8bd35"),
		h32("ceeed5d6813b5155763f35d7209ce29228cd9625bb6527946fcdf6ee1b30f4ee"),
		h32("f177512800bb4d36592b8d1828c32da6573fd256908efb8f0a234cd6911e79dc"),
		"the group is created with alice and bob; carol is added within the epoch", []string{"alice", "bob", "carol"}, 1000, false},
	{1, h32("2502fa9da5b7f889d8de37defbdda85531e2c6b20626a3e59efa6815aac06189"),
		h32("836a3cd360f7eb2a083d0fd085c537f6fb6d29df6fbca8b68835e48d07d62dc0"),
		h32("33446213fbf23b1a12c81c0b6679ff8cb4345db876f39affabc0050bb46604eb"),
		h32("2f7d1933ba956338f37d5b60627c5ba30e86dbde98192030d8c0bed41fe3f421"),
		"bob is removed", []string{"alice", "carol"}, 1010, true},
	{2, h32("ceebd5308ddfaee2f1fb4f5f2dc96b596b58f4ad1643136ec53eb35071587947"),
		h32("b73945e40061c4823d1d9cf528a76b2e7a33a2b97ef182828c6aaeca48fea003"),
		h32("16a5a7e954bc2b7400de9f24edd5d81c62e9d0c88557ee6cf2298e3dd39a62be"),
		h32("2eb099db87764574f67fa85ef85a6b467e003a109aaef169755cf2edb56f8ab2"),
		"a scheduled rotation, no member change", []string{"alice", "carol"}, 1030, false},
}

GroupEpochs is the group's history: created with alice and bob, carol added within epoch 0, bob removed (epoch 1), a scheduled rotation (epoch 2). The heights are those the audit vector uses.

View Source
var GroupID = func() (id [16]byte) { copy(id[:], unhex("406504d3fbe1ae098f09a49dffa12222")); return }()

GroupID is the vectors' group identifier.

Functions

func Generate

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

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

func Names

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

Names returns the file names in a stable order.

Types

type GroupEpoch

type GroupEpoch struct {
	Epoch      uint64
	Key        [32]byte
	Symmetric  [32]byte
	Commitment [32]byte
	EpochID    [32]byte
	Began      string
	Holders    []string
	Height     uint32
	Removed    bool
}

GroupEpoch is one epoch of the vectors' group, as the group substrate's own golden vectors give it: the key the organisation sampled, the BRC-369 symmetric key and commitment it derives, and the epoch id. Holders is who was a member during the epoch and so holds its key.

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 {
	VaultID    [32]byte
	Genesis    [32]byte // the stand-in txid of the chain tree the first token spends
	Versions   map[string]*Version
	Order      []string
	Vaults     []*secrec.Vault
	VaultRecs  [][]byte
	VaultTxids [][32]byte
	Heights    []uint32
	Labels     []string
	// Name is the vault's display name; "Example vault" when empty.
	Name string
	// Used is the tooling's record of every commitment it published or
	// listed, shared by every vault of the owner (docs/spec.md section 6.2).
	Used *secrec.Commitments
	// contains filtered or unexported fields
}

Scenario is the vectors' one vault: its secrets' versions and its chain of tokens.

func Build

func Build() (*Scenario, error)

Build makes the scenario: one vault of the organisation, keyed to the group's epochs, through a removal and a scheduled rotation.

type Version

type Version struct {
	Name    string
	Number  uint64
	Epoch   uint64
	Key     [32]byte
	Payload *secrec.Payload
	Plain   []byte // the encoded payload
	Cipher  []byte
	Rec     *secrec.Secret
	Raw     []byte
	CID     [32]byte
	SelfIV  [32]byte
	WrapIV  [32]byte
	File    string
}

Version is one version of one secret of the scenario.

Jump to

Keyboard shortcuts

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