sigtree

package
v0.0.0-...-63a5211 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tree

type Tree struct {

	// The bitset indicating what signatures are present.
	// This is exported so that the SignatureProof can read it.
	SigBits *bitset.BitSet
	// contains filtered or unexported fields
}

Tree presents a set of keys and signatures in a tree, using an array layout.

func New

func New(keys iter.Seq[blst.P2Affine], nKeys int) Tree

New returns a new Tree. The keys are an iterator because the caller collects [gcrypto.PubKey] but this tree wants the lower-level blst values; since we are collecting the values into a new slice, it doesn't make sense to have the caller allocate a new slice either.

func (Tree) AddSignature

func (t Tree) AddSignature(idx int, sig blst.P1Affine)

AddSignature associates the signature with the key at the given index. It is the caller's responsibility to ensure the signature was verified first, using Get if necessary to retrieve the key.

If this signature's neighbor is also populated, the parent signature will be aggregated automatically, cascading up as many layers as required.

func (Tree) ClearSignatures

func (t Tree) ClearSignatures()

ClearSignatures zeros every signature in the tree. This is useful for reusing a tree if no keys have changed.

func (Tree) Clone

func (t Tree) Clone() Tree

Clone returns a new Tree with cloned signatures.

func (Tree) Derive

func (t Tree) Derive() Tree

Derive returns a new Tree with the same keys but with a new, empty set of signatures.

func (Tree) FinalizedSig

func (t Tree) FinalizedSig() blst.P1Affine

Return the finalized signature represented in the tree, by doing a final aggregation across all non-zero signatures without regard to tree structure.

func (Tree) Get

func (t Tree) Get(idx int) (key blst.P2Affine, sig blst.P1Affine, ok bool)

Get returns the key and signature at the given index. The ok value indicates whether the index was in bounds. The key is guaranteed to be set if ok is true, and the signature may be a zero value if it was not explicitly set or inferred by its children being set.

func (Tree) Index

func (t Tree) Index(k blst.P2Affine) int

Index searches through the tree and returns the numeric index for the key equal to the input k.

If no matching key is found, -1 is returned.

func (Tree) NUnaggregatedKeys

func (t Tree) NUnaggregatedKeys() int

NUnaggregatedKeys returns the number of unaggregated keys in the tree.

func (Tree) SparseIndices

func (t Tree) SparseIndices(dst []int) []int

SparseIndices appends to dst the index of each minimally-aggregated non-zero signature.

Jump to

Keyboard shortcuts

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