Documentation ¶
Overview ¶
Package trie_blake2b_20 implements trie.CommitmentModel based on blake2b 32-byte hashing
Index ¶
- Constants
- Variables
- func CompressToHashSize(data []byte, sz HashSize) ([]byte, bool)
- func HashTheVector(hashes [][]byte, arity common.PathArity, sz HashSize) []byte
- type CommitmentModel
- func (m *CommitmentModel) AlwaysStoreTerminalWithNode() bool
- func (m *CommitmentModel) CalcNodeCommitment(par *common.NodeData, nodePath []byte) common.VCommitment
- func (m *CommitmentModel) CommitToData(data []byte) common.TCommitment
- func (m *CommitmentModel) Description() string
- func (m *CommitmentModel) EqualCommitments(c1, c2 common.Serializable) bool
- func (m *CommitmentModel) ForceStoreTerminalWithNode(c common.TCommitment) bool
- func (m *CommitmentModel) HashSize() HashSize
- func (m *CommitmentModel) NewTerminalCommitment() common.TCommitment
- func (m *CommitmentModel) NewVectorCommitment() common.VCommitment
- func (m *CommitmentModel) PathArity() common.PathArity
- func (m *CommitmentModel) ProofImmutable(key []byte, tr *immutable.TrieReader) *MerkleProof
- func (m *CommitmentModel) ProofMut(key []byte, tr mutable.NodeStore) *MerkleProof
- func (m *CommitmentModel) ShortName() string
- func (m *CommitmentModel) UpdateNodeCommitment(mutate *common.NodeData, childUpdates map[byte]common.VCommitment, ...)
- type HashSize
- type MerkleProof
- type MerkleProofElement
Constants ¶
const ( HashSize160 = HashSize(20) HashSize192 = HashSize(24) HashSize256 = HashSize(32) )
Variables ¶
var AllHashSize = []HashSize{HashSize160, HashSize256}
Functions ¶
func CompressToHashSize ¶
CompressToHashSize hashes data if longer than hash size, otherwise copies it
Types ¶
type CommitmentModel ¶
type CommitmentModel struct {
// contains filtered or unexported fields
}
CommitmentModel provides commitment common implementation for the 256+ trie
func New ¶
func New(arity common.PathArity, hashSize HashSize, valueSizeOptimizationThreshold ...int) *CommitmentModel
New creates new CommitmentModel. Parameter valueSizeOptimizationThreshold means that for terminal commitments to values longer than threshold, the terminal commitments will always be stored with the trie node, i.e. ForceStoreTerminalWithNode will return true. For terminal commitments of this or smaller size, the choice depends on the trie setup Default valueSizeOptimizationThreshold = 0, which means that by default all value commitments are stored in the node. If valueSizeOptimizationThreshold > 0 valueStore must be specified in the trie parameters Reasonable value of valueSizeOptimizationThreshold, allows significantly optimize trie storage without requiring hashing big data each time
func (*CommitmentModel) AlwaysStoreTerminalWithNode ¶
func (m *CommitmentModel) AlwaysStoreTerminalWithNode() bool
func (*CommitmentModel) CalcNodeCommitment ¶
func (m *CommitmentModel) CalcNodeCommitment(par *common.NodeData, nodePath []byte) common.VCommitment
CalcNodeCommitment computes commitment of the node. It is suboptimal in KZG trie. Used in computing root commitment
func (*CommitmentModel) CommitToData ¶
func (m *CommitmentModel) CommitToData(data []byte) common.TCommitment
func (*CommitmentModel) Description ¶
func (m *CommitmentModel) Description() string
func (*CommitmentModel) EqualCommitments ¶
func (m *CommitmentModel) EqualCommitments(c1, c2 common.Serializable) bool
func (*CommitmentModel) ForceStoreTerminalWithNode ¶
func (m *CommitmentModel) ForceStoreTerminalWithNode(c common.TCommitment) bool
func (*CommitmentModel) HashSize ¶
func (m *CommitmentModel) HashSize() HashSize
func (*CommitmentModel) NewTerminalCommitment ¶
func (m *CommitmentModel) NewTerminalCommitment() common.TCommitment
NewTerminalCommitment creates empty terminal commitment
func (*CommitmentModel) NewVectorCommitment ¶
func (m *CommitmentModel) NewVectorCommitment() common.VCommitment
NewVectorCommitment create empty vector commitment
func (*CommitmentModel) PathArity ¶
func (m *CommitmentModel) PathArity() common.PathArity
func (*CommitmentModel) ProofImmutable ¶
func (m *CommitmentModel) ProofImmutable(key []byte, tr *immutable.TrieReader) *MerkleProof
ProofImmutable converts generic proof path of the immutable trie implementation to the Merkle proof path
func (*CommitmentModel) ProofMut ¶
func (m *CommitmentModel) ProofMut(key []byte, tr mutable.NodeStore) *MerkleProof
ProofMut converts generic proof path of the mutable trie implementation to the Merkle proof path
func (*CommitmentModel) ShortName ¶
func (m *CommitmentModel) ShortName() string
func (*CommitmentModel) UpdateNodeCommitment ¶
func (m *CommitmentModel) UpdateNodeCommitment(mutate *common.NodeData, childUpdates map[byte]common.VCommitment, newTerminalUpdate common.TCommitment, pathFragment, nodePath []byte, _ bool)
UpdateNodeCommitment computes update to the node data and, optionally, updates existing commitment In the blake2b implementation, the delta it just means computing the hash of data
type MerkleProof ¶
type MerkleProof struct { PathArity common.PathArity HashSize HashSize Key []byte Path []*MerkleProofElement }
MerkleProof blake2b model specific proof of inclusion
func ProofFromBytes ¶
func ProofFromBytes(data []byte) (*MerkleProof, error)
func (*MerkleProof) Bytes ¶
func (p *MerkleProof) Bytes() []byte
Directories ¶
Path | Synopsis |
---|---|
Package trie_blake2b_verify contains functions for verification of the proofs of inclusion or absence in the trie with trie_blake2b commitment model.
|
Package trie_blake2b_verify contains functions for verification of the proofs of inclusion or absence in the trie with trie_blake2b commitment model. |