Documentation
¶
Index ¶
- Constants
- Variables
- func CopyFr(dst, src *Fr)
- func CopyPoint(dst, src *Point)
- func Equal(self *Point, other *Point) bool
- func FromBytes(fr *Fr, data []byte)
- func FromLEBytes(fr *Fr, data []byte)
- func MakeVerkleMultiProof(root VerkleNode, keys [][]byte, keyvals map[string][]byte) (*Proof, []*Point, []byte, []*Fr, error)
- func StemFromBytes(fr *Fr, data []byte)
- func ToDot(root VerkleNode) string
- func VerifyVerkleProof(proof *Proof, Cs []*Point, indices []uint8, ys []*Fr, tc *Config) bool
- type Committer
- type Config
- type Empty
- func (n Empty) Commit() *Point
- func (Empty) Commitment() *Point
- func (Empty) Copy() VerkleNode
- func (Empty) Delete([]byte, NodeResolverFn) error
- func (Empty) Get([]byte, NodeResolverFn) ([]byte, error)
- func (Empty) GetProofItems(keylist) (*ProofElements, []byte, [][]byte)
- func (Empty) Hash() *Fr
- func (Empty) Insert([]byte, []byte, NodeResolverFn) error
- func (e Empty) InsertOrdered(key []byte, value []byte, _ NodeFlushFn) error
- func (Empty) Serialize() ([]byte, error)
- type Fr
- type HashedNode
- func (n *HashedNode) Commit() *Point
- func (n *HashedNode) Commitment() *Point
- func (n *HashedNode) Copy() VerkleNode
- func (*HashedNode) Delete([]byte, NodeResolverFn) error
- func (*HashedNode) Get([]byte, NodeResolverFn) ([]byte, error)
- func (*HashedNode) GetProofItems(keylist) (*ProofElements, []byte, [][]byte)
- func (n *HashedNode) Hash() *Fr
- func (*HashedNode) Insert([]byte, []byte, NodeResolverFn) error
- func (*HashedNode) InsertOrdered([]byte, []byte, NodeFlushFn) error
- func (*HashedNode) Serialize() ([]byte, error)
- type IPAConfig
- type InternalNode
- func (n *InternalNode) Children() []VerkleNode
- func (n *InternalNode) Commit() *Point
- func (n *InternalNode) Commitment() *Point
- func (n *InternalNode) Copy() VerkleNode
- func (n *InternalNode) Delete(key []byte, resolver NodeResolverFn) error
- func (n *InternalNode) Flush(flush NodeFlushFn)
- func (n *InternalNode) FlushAtDepth(depth uint8, flush NodeFlushFn)
- func (n *InternalNode) Get(k []byte, getter NodeResolverFn) ([]byte, error)
- func (n *InternalNode) GetProofItems(keys keylist) (*ProofElements, []byte, [][]byte)
- func (n *InternalNode) Hash() *Fr
- func (n *InternalNode) Insert(key []byte, value []byte, resolver NodeResolverFn) error
- func (n *InternalNode) InsertOrdered(key []byte, value []byte, flush NodeFlushFn) (err error)
- func (n *InternalNode) InsertStem(stem []byte, node VerkleNode, resolver NodeResolverFn, overwrite bool) error
- func (n *InternalNode) InsertStemOrdered(key []byte, leaf *LeafNode, flush NodeFlushFn) error
- func (n *InternalNode) Serialize() ([]byte, error)
- func (n *InternalNode) SetChild(i int, c VerkleNode) error
- type KeyValuePair
- type LeafNode
- func (n *LeafNode) Commit() *Point
- func (n *LeafNode) Commitment() *Point
- func (n *LeafNode) Copy() VerkleNode
- func (n *LeafNode) Delete(k []byte, _ NodeResolverFn) error
- func (n *LeafNode) Get(k []byte, _ NodeResolverFn) ([]byte, error)
- func (n *LeafNode) GetProofItems(keys keylist) (*ProofElements, []byte, [][]byte)
- func (n *LeafNode) Hash() *Fr
- func (n *LeafNode) Insert(k []byte, value []byte, _ NodeResolverFn) error
- func (n *LeafNode) InsertOrdered(key []byte, value []byte, _ NodeFlushFn) error
- func (n *LeafNode) Key(i int) []byte
- func (n *LeafNode) Serialize() ([]byte, error)
- func (n *LeafNode) ToHashedNode() *HashedNode
- func (n *LeafNode) Value(i int) []byte
- type NodeFlushFn
- type NodeResolverFn
- type Point
- type Proof
- type ProofElements
- type StatelessNode
- func (n *StatelessNode) Children() []VerkleNode
- func (n *StatelessNode) Commit() *Point
- func (n *StatelessNode) Commitment() *Point
- func (n *StatelessNode) Copy() VerkleNode
- func (n *StatelessNode) Delete(key []byte, resolver NodeResolverFn) error
- func (n *StatelessNode) Flush(flush NodeFlushFn)
- func (n *StatelessNode) Get(k []byte, getter NodeResolverFn) ([]byte, error)
- func (n *StatelessNode) GetProofItems(keys keylist) (*ProofElements, []byte, [][]byte)
- func (n *StatelessNode) Hash() *Fr
- func (n *StatelessNode) Insert(key []byte, value []byte, resolver NodeResolverFn) error
- func (n *StatelessNode) InsertAtStem(stem []byte, values [][]byte, resolver NodeResolverFn, _ bool) error
- func (*StatelessNode) InsertOrdered([]byte, []byte, NodeFlushFn) error
- func (n *StatelessNode) Serialize() ([]byte, error)
- func (n *StatelessNode) SetChild(i int, v VerkleNode) error
- func (n *StatelessNode) ToHashedNode() *HashedNode
- type VerkleNode
Constants ¶
const ( NodeWidth = 256 NodeBitWidth byte = 8 )
Variables ¶
var ErrInvalidNodeEncoding = errors.New("invalid node encoding")
Functions ¶
func FromLEBytes ¶
func MakeVerkleMultiProof ¶
func StemFromBytes ¶
func ToDot ¶
func ToDot(root VerkleNode) string
Types ¶
type Committer ¶
Committer represents an object that is able to create the commitment to a polynomial.
type Empty ¶
type Empty struct{}
func (Empty) Commitment ¶
func (Empty) Copy ¶
func (Empty) Copy() VerkleNode
func (Empty) GetProofItems ¶
func (Empty) GetProofItems(keylist) (*ProofElements, []byte, [][]byte)
func (Empty) InsertOrdered ¶
func (e Empty) InsertOrdered(key []byte, value []byte, _ NodeFlushFn) error
type HashedNode ¶
type HashedNode struct {
// contains filtered or unexported fields
}
func (*HashedNode) Commit ¶
func (n *HashedNode) Commit() *Point
func (*HashedNode) Commitment ¶
func (n *HashedNode) Commitment() *Point
func (*HashedNode) Copy ¶
func (n *HashedNode) Copy() VerkleNode
func (*HashedNode) Delete ¶
func (*HashedNode) Delete([]byte, NodeResolverFn) error
func (*HashedNode) Get ¶
func (*HashedNode) Get([]byte, NodeResolverFn) ([]byte, error)
func (*HashedNode) GetProofItems ¶
func (*HashedNode) GetProofItems(keylist) (*ProofElements, []byte, [][]byte)
func (*HashedNode) Hash ¶
func (n *HashedNode) Hash() *Fr
func (*HashedNode) Insert ¶
func (*HashedNode) Insert([]byte, []byte, NodeResolverFn) error
func (*HashedNode) InsertOrdered ¶
func (*HashedNode) InsertOrdered([]byte, []byte, NodeFlushFn) error
func (*HashedNode) Serialize ¶
func (*HashedNode) Serialize() ([]byte, error)
type InternalNode ¶
type InternalNode struct {
// contains filtered or unexported fields
}
Represents an internal node at any level
func CreateInternalNode ¶
func (*InternalNode) Children ¶
func (n *InternalNode) Children() []VerkleNode
func (*InternalNode) Commit ¶
func (n *InternalNode) Commit() *Point
func (*InternalNode) Commitment ¶
func (n *InternalNode) Commitment() *Point
func (*InternalNode) Copy ¶
func (n *InternalNode) Copy() VerkleNode
func (*InternalNode) Delete ¶
func (n *InternalNode) Delete(key []byte, resolver NodeResolverFn) error
func (*InternalNode) Flush ¶
func (n *InternalNode) Flush(flush NodeFlushFn)
Flush hashes the children of an internal node and replaces them with HashedNode. It also sends the current node on the flush channel.
func (*InternalNode) FlushAtDepth ¶
func (n *InternalNode) FlushAtDepth(depth uint8, flush NodeFlushFn)
FlushAtDepth goes over all internal nodes of a given depth, and flushes them to disk. Its purpose it to free up space if memory is running scarce.
func (*InternalNode) Get ¶
func (n *InternalNode) Get(k []byte, getter NodeResolverFn) ([]byte, error)
func (*InternalNode) GetProofItems ¶
func (n *InternalNode) GetProofItems(keys keylist) (*ProofElements, []byte, [][]byte)
func (*InternalNode) Hash ¶
func (n *InternalNode) Hash() *Fr
func (*InternalNode) Insert ¶
func (n *InternalNode) Insert(key []byte, value []byte, resolver NodeResolverFn) error
func (*InternalNode) InsertOrdered ¶
func (n *InternalNode) InsertOrdered(key []byte, value []byte, flush NodeFlushFn) (err error)
func (*InternalNode) InsertStem ¶
func (n *InternalNode) InsertStem(stem []byte, node VerkleNode, resolver NodeResolverFn, overwrite bool) error
InsertStem inserts a pre-constructed node into the tree at stem stem. If the `overwrite` bit is set to true, if and the inserted node is a leaf, it will attempt to merge that leaf with the one already present in the trie (if such a leaf is already present). Merging a leaf and another type of node (i.e. a subtree insertion) will return an error.
func (*InternalNode) InsertStemOrdered ¶
func (n *InternalNode) InsertStemOrdered(key []byte, leaf *LeafNode, flush NodeFlushFn) error
InsertStemOrdered does the same thing as InsertOrdered but is meant to insert a pre-build LeafNode at a given stem, instead of individual leaves.
func (*InternalNode) Serialize ¶
func (n *InternalNode) Serialize() ([]byte, error)
func (*InternalNode) SetChild ¶
func (n *InternalNode) SetChild(i int, c VerkleNode) error
type KeyValuePair ¶
A structure representing a tuple
func SerializeProof ¶
func SerializeProof(proof *Proof) ([]byte, []KeyValuePair, error)
SerializeProof serializes the proof in the rust-verkle format: * len(Proof of absence stem) || Proof of absence stems * len(depths) || serialize(depth || ext statusi) * len(commitments) || serialize(commitment) * Multipoint proof it also returns the serialized keys and values
type LeafNode ¶
type LeafNode struct {
// contains filtered or unexported fields
}
func NewLeafNode ¶
New creates a new leaf node
func (*LeafNode) Commitment ¶
func (*LeafNode) Copy ¶
func (n *LeafNode) Copy() VerkleNode
func (*LeafNode) GetProofItems ¶
func (n *LeafNode) GetProofItems(keys keylist) (*ProofElements, []byte, [][]byte)
func (*LeafNode) InsertOrdered ¶
func (n *LeafNode) InsertOrdered(key []byte, value []byte, _ NodeFlushFn) error
func (*LeafNode) ToHashedNode ¶
func (n *LeafNode) ToHashedNode() *HashedNode
type NodeFlushFn ¶
type NodeFlushFn func(VerkleNode)
type NodeResolverFn ¶
type Proof ¶
type Proof struct { Multipoint *ipa.MultiProof // multipoint argument ExtStatus []byte // the extension status of each stem Cs []*Point // commitments, sorted by their path in the tree PoaStems [][]byte // stems proving another stem is absent Keys [][]byte Values [][]byte }
func DeserializeProof ¶
func DeserializeProof(proofSerialized []byte, keyvals []KeyValuePair) (*Proof, error)
DeserializeProof deserializes the proof found in blocks, into a format that can be used to rebuild a stateless version of the tree.
type ProofElements ¶
type ProofElements struct { Cis []*Point Zis []byte Yis []*Fr Fis [][]Fr ByPath map[string]*Point // Gather commitments by path // contains filtered or unexported fields }
ProofElements gathers the elements needed to build a proof.
func GetCommitmentsForMultiproof ¶
func GetCommitmentsForMultiproof(root VerkleNode, keys [][]byte) (*ProofElements, []byte, [][]byte)
func (*ProofElements) Merge ¶
func (pe *ProofElements) Merge(other *ProofElements)
Merge merges the elements of two proofs and removes duplicates.
type StatelessNode ¶
type StatelessNode struct {
// contains filtered or unexported fields
}
StatelessNode represents a node for execution in a stateless context, i.e. that its children/values are not all known. It can represent both an InternalNode or a LeafNode.
func NewStateless ¶
func NewStateless() *StatelessNode
func NewStatelessWithCommitment ¶
func NewStatelessWithCommitment(point *Point) *StatelessNode
func (*StatelessNode) Children ¶
func (n *StatelessNode) Children() []VerkleNode
func (*StatelessNode) Commit ¶
func (n *StatelessNode) Commit() *Point
func (*StatelessNode) Commitment ¶
func (n *StatelessNode) Commitment() *Point
func (*StatelessNode) Copy ¶
func (n *StatelessNode) Copy() VerkleNode
func (*StatelessNode) Delete ¶
func (n *StatelessNode) Delete(key []byte, resolver NodeResolverFn) error
Delete writes the value `0` at `key` since verkle trees need to distinguish between a node that used to be present and was then deleted, and a node that was never present.
func (*StatelessNode) Flush ¶
func (n *StatelessNode) Flush(flush NodeFlushFn)
func (*StatelessNode) Get ¶
func (n *StatelessNode) Get(k []byte, getter NodeResolverFn) ([]byte, error)
func (*StatelessNode) GetProofItems ¶
func (n *StatelessNode) GetProofItems(keys keylist) (*ProofElements, []byte, [][]byte)
func (*StatelessNode) Hash ¶
func (n *StatelessNode) Hash() *Fr
func (*StatelessNode) Insert ¶
func (n *StatelessNode) Insert(key []byte, value []byte, resolver NodeResolverFn) error
func (*StatelessNode) InsertAtStem ¶
func (n *StatelessNode) InsertAtStem(stem []byte, values [][]byte, resolver NodeResolverFn, _ bool) error
func (*StatelessNode) InsertOrdered ¶
func (*StatelessNode) InsertOrdered([]byte, []byte, NodeFlushFn) error
func (*StatelessNode) Serialize ¶
func (n *StatelessNode) Serialize() ([]byte, error)
func (*StatelessNode) SetChild ¶
func (n *StatelessNode) SetChild(i int, v VerkleNode) error
func (*StatelessNode) ToHashedNode ¶
func (n *StatelessNode) ToHashedNode() *HashedNode
type VerkleNode ¶
type VerkleNode interface { // Insert or Update value into the tree Insert([]byte, []byte, NodeResolverFn) error // Insert "à la" Stacktrie. Same thing as insert, except that // values are expected to be ordered, and the commitments and // hashes for each subtrie are computed online, as soon as it // is clear that no more values will be inserted in there. InsertOrdered([]byte, []byte, NodeFlushFn) error // Delete a leaf with the given key Delete([]byte, NodeResolverFn) error // Get value at a given key Get([]byte, NodeResolverFn) ([]byte, error) // Commit computes the commitment of the node. The // result (the curve point) is cached. Commit() *Point // Commitment is a getter for the cached commitment // to this node. Commitment() *Point // Hash returns the field representation of the commitment. Hash() *Fr // GetProofItems collects the various proof elements, and // returns them breadth-first. On top of that, it returns // one "extension status" per stem, and an alternate stem // if the key is missing but another stem has been found. GetProofItems(keylist) (*ProofElements, []byte, [][]byte) // Serialize encodes the node to RLP. Serialize() ([]byte, error) // Copy a node and its children Copy() VerkleNode // contains filtered or unexported methods }
func MergeTrees ¶
func MergeTrees(subroots []*InternalNode) VerkleNode
MergeTrees takes a series of subtrees that got filled following a command-and-conquer method, and merges them into a single tree.
func TreeFromProof ¶
func TreeFromProof(proof *Proof, rootC *Point) (VerkleNode, error)
TreeFromProof builds a stateless tree from the proof