Documentation ¶
Index ¶
- Constants
- Variables
- func AnalysisTire(t SALTTrie) (int, int, int, int)
- func ComputeCommitCount(s SALTTrie, cs *SaltChangeSet) (int, int)
- func ComputeStemCommitCount(s SALTTrie, js []*map[int]*JobChangeSet) int
- func FromBytes(fr *Fr, data []byte)
- func FromLEBytes(fr *Fr, data []byte) error
- func GetBucketIdxByKey(k []byte) int
- func GetMemUsedByCmd(pro string) int
- func GetMemUsedByGoPs() uint64
- func GetMemUsedBySmemCmd(pro string) int
- func GetMemUsedByStats() uint64
- func H256Compare(c1, c2 []byte) int
- func H256Mod(k []byte) int
- func HexToPrefixedString(data []byte) string
- func InternalNodeCount(n *VerkleNode) (int, int, float64)
- func IsEqualSaltTire(s, t SALTTrie) bool
- func MakeVerkleMultiProof(preroot, postroot VerkleNode, keys [][]byte, resolver NodeResolverFn) (*Proof, []*Point, []byte, []*Fr, error)
- func NewRand(seed int64) *rr.Rand
- func PrefixedHexStringToBytes(input string) ([]byte, error)
- func RandH256Key(updates_key [][32]byte, update_nums, mod int, r *rr.Rand)
- func SerializeProof(proof *Proof) (*VerkleProof, StateDiff, error)
- func SetVerkleJobs(jobs int)
- func StatisticTireBuckectCDF(t SALTTrie, gap int) ([]int, []float64)
- func StemFromBytes(fr *Fr, data []byte) error
- func TestMemory()
- func ToDot(root VerkleNode) string
- func VerifyVerkleProof(proof *Proof, Cs []*Point, indices []uint8, ys []*Fr, tc *Config) (bool, error)
- func VerifyVerkleProofWithPreState(proof *Proof, preroot VerkleNode) error
- type BatchNewLeafNodeData
- type BriefCommitment
- type Bucket
- type BucketChangeSet
- type Commitment
- type Config
- type Empty
- func (n Empty) Commit() *Point
- func (Empty) Commitment() *Point
- func (Empty) Copy() VerkleNode
- func (Empty) Delete([]byte, NodeResolverFn) (bool, error)
- func (Empty) Get([]byte, NodeResolverFn) ([]byte, error)
- func (Empty) GetProofItems(keylist, NodeResolverFn) (*ProofElements, []byte, [][]byte, error)
- func (Empty) Hash() *Fr
- func (Empty) Insert([]byte, []byte, NodeResolverFn) error
- func (Empty) Serialize() ([]byte, error)
- type ExportableInternalNode
- type ExportableLeafNode
- type Fr
- type H256
- type HashedNode
- func (HashedNode) Commit() *Point
- func (HashedNode) Commitment() *Point
- func (HashedNode) Copy() VerkleNode
- func (HashedNode) Delete([]byte, NodeResolverFn) (bool, error)
- func (HashedNode) Get([]byte, NodeResolverFn) ([]byte, error)
- func (HashedNode) GetProofItems(keylist, NodeResolverFn) (*ProofElements, []byte, [][]byte, error)
- func (HashedNode) Hash() *Fr
- func (HashedNode) Insert([]byte, []byte, NodeResolverFn) error
- func (HashedNode) Serialize() ([]byte, error)
- type IPAConfig
- type IPAProof
- type InternalNode
- func (n *InternalNode) BatchSerialize() ([]SerializedNode, error)
- func (n *InternalNode) Children() []VerkleNode
- func (n *InternalNode) Commit() *Point
- func (n *InternalNode) Commitment() *Point
- func (n *InternalNode) Copy() VerkleNode
- func (n *InternalNode) CreatePath(path []byte, stemInfo stemInfo, comms []*Point, values [][]byte) ([]*Point, error)
- func (n *InternalNode) Delete(key []byte, resolver NodeResolverFn) (bool, error)
- func (n *InternalNode) Flush(flush NodeFlushFn)
- func (n *InternalNode) FlushAtDepth(depth uint8, flush NodeFlushFn)
- func (n *InternalNode) Get(key []byte, resolver NodeResolverFn) ([]byte, error)
- func (n *InternalNode) GetProofItems(keys keylist, resolver NodeResolverFn) (*ProofElements, []byte, [][]byte, error)
- func (n *InternalNode) GetValuesAtStem(stem []byte, resolver NodeResolverFn) ([][]byte, error)
- func (n *InternalNode) Hash() *Fr
- func (n *InternalNode) Insert(key []byte, value []byte, resolver NodeResolverFn) error
- func (n *InternalNode) InsertMigratedLeaves(leaves []LeafNode, resolver NodeResolverFn) error
- func (n *InternalNode) InsertValuesAtStem(stem []byte, values [][]byte, resolver NodeResolverFn) error
- func (n *InternalNode) InternalNodeCount(nLevlel, nLeaf, nStem *int)
- func (n *InternalNode) Serialize() ([]byte, error)
- func (n *InternalNode) SetChild(i int, c VerkleNode) error
- func (n *InternalNode) ToJSON() ([]byte, error)
- type InternalNodeChangeSet
- type JobChangeSet
- type KV
- type LeafNode
- func (n *LeafNode) Commit() *Point
- func (n *LeafNode) Commitment() *Point
- func (n *LeafNode) Copy() VerkleNode
- func (n *LeafNode) Delete(k []byte, _ NodeResolverFn) (bool, error)
- func (n *LeafNode) Get(k []byte, _ NodeResolverFn) ([]byte, error)
- func (n *LeafNode) GetProofItems(keys keylist, _ NodeResolverFn) (*ProofElements, []byte, [][]byte, error)
- func (n *LeafNode) Hash() *Fr
- func (n *LeafNode) Insert(key []byte, value []byte, _ NodeResolverFn) error
- func (n *LeafNode) Key(i int) []byte
- func (n *LeafNode) Serialize() ([]byte, error)
- func (n *LeafNode) Value(i int) []byte
- func (n *LeafNode) Values() [][]byte
- type Metric
- func (m *Metric) AvgNum() float64
- func (m *Metric) AvgTime() time.Duration
- func (m *Metric) ReduceTimeX(x int)
- func (m *Metric) ShowNum(title string)
- func (m *Metric) ShowTime(title string)
- func (m *Metric) UpdateNum(num int)
- func (m *Metric) UpdateNumTime(num int, time_num time.Duration)
- func (m *Metric) UpdateTime(time_num time.Duration)
- type NodeFlushFn
- type NodeResolverFn
- type Point
- type Proof
- type ProofElements
- type SALTTrie
- type SHITable
- func (t *SHITable) Delete(k []byte, s *BucketChangeSet) error
- func (t *SHITable) Delete2(k []byte, s *BucketChangeSet) error
- func (t *SHITable) GetNodeByKey(key []byte) (KV, error)
- func (t *SHITable) Insert(k, v []byte, set *BucketChangeSet) error
- func (t *SHITable) Insert2(k, v []byte, set *BucketChangeSet) error
- func (t *SHITable) IsEqual(other *SHITable) bool
- type SHITableChangeSet
- type SHITableGoMap
- func (t *SHITableGoMap) Delete(k []byte, s *BucketChangeSet) error
- func (t *SHITableGoMap) Delete2(k []byte, s *BucketChangeSet) error
- func (t *SHITableGoMap) GetNodeByKey(key []byte) (KV, error)
- func (t *SHITableGoMap) Insert(k, v []byte, set *BucketChangeSet) error
- func (t *SHITableGoMap) Insert2(k, v []byte, set *BucketChangeSet) error
- func (t *SHITableGoMap) IsEqual(other *SHITableGoMap) bool
- type SHITableManager
- func (m *SHITableManager) CheckBucketKV(i, j int, k, v []byte) bool
- func (m *SHITableManager) Delete(k []byte, cm *SHITableChangeSet) error
- func (m *SHITableManager) GetKVCount() int
- func (m *SHITableManager) GetNodeByKey(k []byte) (KV, error)
- func (m *SHITableManager) Insert(k, v []byte, cm *SHITableChangeSet) error
- type SaltChangeSet
- type SerializedNode
- type SerializedPoint
- type SerializedPointCompressed
- type StateDiff
- type StemStateDiff
- type SuffixStateDiff
- type SuffixStateDiffs
- type U256
- type UnknownNode
- func (n UnknownNode) Commit() *Point
- func (UnknownNode) Commitment() *Point
- func (UnknownNode) Copy() VerkleNode
- func (UnknownNode) Delete([]byte, NodeResolverFn) (bool, error)
- func (UnknownNode) Get([]byte, NodeResolverFn) ([]byte, error)
- func (UnknownNode) GetProofItems(keylist, NodeResolverFn) (*ProofElements, []byte, [][]byte, error)
- func (UnknownNode) Hash() *Fr
- func (UnknownNode) Insert([]byte, []byte, NodeResolverFn) error
- func (UnknownNode) Serialize() ([]byte, error)
- type VerkleNode
- func MergeTrees(subroots []*InternalNode) VerkleNode
- func New() VerkleNode
- func NewStatelessInternal(depth byte, comm *Point) VerkleNode
- func ParseNode(serializedNode []byte, depth byte) (VerkleNode, error)
- func PostStateTreeFromStateDiff(preroot VerkleNode, statediff StateDiff) (VerkleNode, error)
- func PreStateTreeFromProof(proof *Proof, rootC *Point) (VerkleNode, error)
- type VerkleProof
Constants ¶
const ( LeafValueSize = 32 NodeWidth = 256 NodeBitWidth byte = 8 StemSize = 31 )
const ( CodeHashVectorPosition = 3 // Defined by the spec. EmptyCodeHashFirstHalfIdx = CodeHashVectorPosition * 2 EmptyCodeHashSecondHalfIdx = EmptyCodeHashFirstHalfIdx + 1 )
const ( LEVEL1_NODE = 1 LEVEL2_NODE = (1 << 8) //6 LEVEL3_NODE = (1 << 16) //16 LEVEL4_NODE = (1 << 24) //26 )
const ( MAX_LEAF_NODE = LEVEL4_NODE //Maximum number of leaf nodes MAX_INTERNAL_NODE = (LEVEL1_NODE + LEVEL2_NODE + LEVEL3_NODE + LEVEL4_NODE) DEFAULT_JOB_NUMS = 4 MIN_NODES_PER_JOB = 4 )
const ( MAX_SHI_TABLE = MAX_LEAF_NODE // Maximum number of shi tables TABLE_SLOTS_BITS = 8 //10 MAX_TABLE_SLOTS = (1 << TABLE_SLOTS_BITS) // Maximum number of slots MAX_KEY_SIZE = 32 // Maximum number of keys )
const ( TYPE_SALT_FULL = 0 // TYPE_SALT_BRIEF = 1 )
const ( SHI_EMPTY = 0 // Empty slot SHI_OCCUPYING = 1 //Occupy slot SHI_FULL = 2 //no more slots available SHI_FIND = 3 // find the key in shi table SHI_NOT_FIND = 4 )
shiTable node status
const ( COMPARE_EQUAL = 0 //c1 == c2 COMPARE_LESS = -1 // c1 < c2 COMPARE_LARGE = 1 // c1 > c2 )
const ( MAP_TYPE_GOMAP = 0 MAP_TYPE_SWISS = 0 )
const (
DEF_CACHE_COMMITMENT_SIZE = 65536
)
const IPA_PROOF_DEPTH = 8
Variables ¶
var ( EmptyCodeHashPoint Point EmptyCodeHashFirstHalfValue Fr EmptyCodeHashSecondHalfValue Fr )
EmptyCodeHashPoint is a cached point that is used to represent an empty code hash. This value is initialized once in GetConfig().
var (
ErrInvalidNodeEncoding = errors.New("invalid node encoding")
)
var NewSaltChangeSet = NewSHITableChangeSet
var TotalInternalCommitments = 0
var TotalLeafCommitments = 0
Functions ¶
func ComputeCommitCount ¶
func ComputeCommitCount(s SALTTrie, cs *SaltChangeSet) (int, int)
func ComputeStemCommitCount ¶
func ComputeStemCommitCount(s SALTTrie, js []*map[int]*JobChangeSet) int
func FromLEBytes ¶
func GetBucketIdxByKey ¶
Get Buckect Index with binary in Little Endian ordering
func GetMemUsedByCmd ¶
use the Command method to get used memory
func GetMemUsedByGoPs ¶
func GetMemUsedByGoPs() uint64
func GetMemUsedBySmemCmd ¶
func GetMemUsedByStats ¶
func GetMemUsedByStats() uint64
use the MemStats method to get used memory but the data is not quite right
func HexToPrefixedString ¶
HexToPrefixedString turns a byte slice into its hex representation and prefixes it with `0x`.
func InternalNodeCount ¶
func InternalNodeCount(n *VerkleNode) (int, int, float64)
func MakeVerkleMultiProof ¶
func MakeVerkleMultiProof(preroot, postroot VerkleNode, keys [][]byte, resolver NodeResolverFn) (*Proof, []*Point, []byte, []*Fr, error)
func PrefixedHexStringToBytes ¶
PrefixedHexStringToBytes does the opposite of HexToPrefixedString.
func RandH256Key ¶
swap array values at random
func SerializeProof ¶
func SerializeProof(proof *Proof) (*VerkleProof, StateDiff, 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
func SetVerkleJobs ¶
func SetVerkleJobs(jobs int)
func StatisticTireBuckectCDF ¶
collect statistics on leaf distribution in buckets gap is X-axis spacing
func StemFromBytes ¶
func TestMemory ¶
func TestMemory()
func ToDot ¶
func ToDot(root VerkleNode) string
func VerifyVerkleProof ¶
func VerifyVerkleProofWithPreState ¶
func VerifyVerkleProofWithPreState(proof *Proof, preroot VerkleNode) error
VerifyVerkleProofWithPreState takes a proof and a trusted tree root and verifies that the proof is valid.
Types ¶
type BatchNewLeafNodeData ¶
BatchNewLeafNodeData is a struct that contains the data needed to create a new leaf node.
type BriefCommitment ¶
type BriefCommitment = [64]byte
type BucketChangeSet ¶
type BucketChangeSet struct {
// contains filtered or unexported fields
}
Bucket Change sets
func NewBucketChangeSet ¶
func NewBucketChangeSet(proc func(o *KV, rs []byte)) *BucketChangeSet
New a BucketChangeSet
func (*BucketChangeSet) IsEqual ¶
func (b *BucketChangeSet) IsEqual(other *BucketChangeSet) bool
tow BucketChangeSet is equal or not
type Commitment ¶
type Commitment = banderwagon.Element
type Empty ¶
type Empty struct{}
func (Empty) Commitment ¶
func (Empty) Copy ¶
func (Empty) Copy() VerkleNode
func (Empty) GetProofItems ¶
func (Empty) GetProofItems(keylist, NodeResolverFn) (*ProofElements, []byte, [][]byte, error)
type ExportableInternalNode ¶
type ExportableInternalNode struct { Children []interface{} `json:"children"` Commitment []byte `json:"commitment"` }
A few proxy types that export their fields, so that the core type does not. The conversion from one type to the other is done by calling toExportable on an InternalNode.
type ExportableLeafNode ¶
type ExportableLeafNode struct { Stem []byte `json:"stem"` Values [][]byte `json:"values"` C [32]byte `json:"commitment"` C1 [32]byte `json:"c1"` C2 [32]byte `json:"c2"` }
A few proxy types that export their fields, so that the core type does not. The conversion from one type to the other is done by calling toExportable on an InternalNode.
type H256 ¶
type H256 = [MAX_KEY_SIZE]byte
type HashedNode ¶
type HashedNode struct{}
func (HashedNode) Commit ¶
func (HashedNode) Commit() *Point
func (HashedNode) Commitment ¶
func (HashedNode) Commitment() *Point
func (HashedNode) Copy ¶
func (HashedNode) Copy() VerkleNode
func (HashedNode) Delete ¶
func (HashedNode) Delete([]byte, NodeResolverFn) (bool, error)
func (HashedNode) Get ¶
func (HashedNode) Get([]byte, NodeResolverFn) ([]byte, error)
func (HashedNode) GetProofItems ¶
func (HashedNode) GetProofItems(keylist, NodeResolverFn) (*ProofElements, []byte, [][]byte, error)
func (HashedNode) Hash ¶
func (HashedNode) Hash() *Fr
func (HashedNode) Insert ¶
func (HashedNode) Insert([]byte, []byte, NodeResolverFn) error
func (HashedNode) Serialize ¶
func (HashedNode) Serialize() ([]byte, error)
type IPAProof ¶
type IPAProof struct { CL [IPA_PROOF_DEPTH][32]byte `json:"cl"` CR [IPA_PROOF_DEPTH][32]byte `json:"cr"` FinalEvaluation [32]byte `json:"finalEvaluation"` }
func (*IPAProof) MarshalJSON ¶
func (*IPAProof) UnmarshalJSON ¶
type InternalNode ¶
type InternalNode struct {
// contains filtered or unexported fields
}
Represents an internal node at any level
func CreateInternalNode ¶
func CreateInternalNode(bitlist []byte, raw []byte, depth byte) (*InternalNode, error)
func (*InternalNode) BatchSerialize ¶
func (n *InternalNode) BatchSerialize() ([]SerializedNode, error)
BatchSerialize is an optimized serialization API when multiple VerkleNodes serializations are required, and all are available in memory.
func (*InternalNode) Children ¶
func (n *InternalNode) Children() []VerkleNode
Children return the children of the node. The returned slice is internal to the tree, so callers *must* consider it readonly.
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) CreatePath ¶
func (n *InternalNode) CreatePath(path []byte, stemInfo stemInfo, comms []*Point, values [][]byte) ([]*Point, error)
CreatePath inserts a given stem in the tree, placing it as described by stemInfo. Its third parameters is the list of commitments that have not been assigned a node. It returns the same list, save the commitments that were consumed during this call.
func (*InternalNode) Delete ¶
func (n *InternalNode) Delete(key []byte, resolver NodeResolverFn) (bool, 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(key []byte, resolver NodeResolverFn) ([]byte, error)
func (*InternalNode) GetProofItems ¶
func (n *InternalNode) GetProofItems(keys keylist, resolver NodeResolverFn) (*ProofElements, []byte, [][]byte, error)
func (*InternalNode) GetValuesAtStem ¶
func (n *InternalNode) GetValuesAtStem(stem []byte, resolver NodeResolverFn) ([][]byte, error)
GetValuesAtStem returns the all NodeWidth values of the stem. The returned slice is internal to the tree, so it *must* be considered readonly for callers.
func (*InternalNode) Hash ¶
func (n *InternalNode) Hash() *Fr
func (*InternalNode) Insert ¶
func (n *InternalNode) Insert(key []byte, value []byte, resolver NodeResolverFn) error
func (*InternalNode) InsertMigratedLeaves ¶
func (n *InternalNode) InsertMigratedLeaves(leaves []LeafNode, resolver NodeResolverFn) error
func (*InternalNode) InsertValuesAtStem ¶
func (n *InternalNode) InsertValuesAtStem(stem []byte, values [][]byte, resolver NodeResolverFn) error
func (*InternalNode) InternalNodeCount ¶
func (n *InternalNode) InternalNodeCount(nLevlel, nLeaf, nStem *int)
func (*InternalNode) Serialize ¶
func (n *InternalNode) Serialize() ([]byte, error)
Serialize returns the serialized form of the internal node. The format is: <nodeType><bitlist><commitment>
func (*InternalNode) SetChild ¶
func (n *InternalNode) SetChild(i int, c VerkleNode) error
SetChild *replaces* the child at the given index with the given node.
func (*InternalNode) ToJSON ¶
func (n *InternalNode) ToJSON() ([]byte, error)
Turn an internal node into a JSON string
type InternalNodeChangeSet ¶
type InternalNodeChangeSet struct {
// contains filtered or unexported fields
}
type JobChangeSet ¶
type JobChangeSet struct {
// contains filtered or unexported fields
}
func (*JobChangeSet) Count ¶
func (t *JobChangeSet) Count() int
type LeafNode ¶
type LeafNode struct {
// contains filtered or unexported fields
}
func BatchNewLeafNode ¶
func BatchNewLeafNode(nodesValues []BatchNewLeafNodeData) ([]LeafNode, error)
BatchNewLeafNode creates a new leaf node from the given data. It optimizes LeafNode creation by batching expensive cryptography operations. It returns the LeafNodes sorted by stem.
func NewLeafNode ¶
New creates a new leaf node
func NewLeafNodeWithNoComms ¶
NewLeafNodeWithNoComms create a leaf node but does compute its commitments. The created node's commitments are intended to be initialized with `SetTrustedBytes` in a deserialization context.
func (*LeafNode) Commitment ¶
func (*LeafNode) Copy ¶
func (n *LeafNode) Copy() VerkleNode
func (*LeafNode) Delete ¶
func (n *LeafNode) Delete(k []byte, _ NodeResolverFn) (bool, error)
Delete deletes a value from the leaf, return `true` as a second return value, if the parent should entirely delete the child.
func (*LeafNode) GetProofItems ¶
func (n *LeafNode) GetProofItems(keys keylist, _ NodeResolverFn) (*ProofElements, []byte, [][]byte, error)
func (*LeafNode) Insert ¶
func (n *LeafNode) Insert(key []byte, value []byte, _ NodeResolverFn) error
type Metric ¶
type Metric struct { MinNum int MaxNum int TotalNum int CountNum int MinTime time.Duration MaxTime time.Duration TotalTime time.Duration CountTime time.Duration }
used to record measurement values
func (*Metric) UpdateNumTime ¶
update measurement time and num
func (*Metric) UpdateTime ¶
update measurement value of time
type NodeFlushFn ¶
type NodeFlushFn func([]byte, VerkleNode)
type NodeResolverFn ¶
type Point ¶
type Point = banderwagon.Element
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 PreValues [][]byte PostValues [][]byte }
func DeserializeProof ¶
func DeserializeProof(vp *VerkleProof, statediff StateDiff) (*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 Vals [][]byte // list of values read from the tree // contains filtered or unexported fields }
ProofElements gathers the elements needed to build a proof.
func GetCommitmentsForMultiproof ¶
func GetCommitmentsForMultiproof(root VerkleNode, keys [][]byte, resolver NodeResolverFn) (*ProofElements, []byte, [][]byte, error)
func (*ProofElements) Merge ¶
func (pe *ProofElements) Merge(other *ProofElements)
Merge merges the elements of two proofs and removes duplicates.
type SALTTrie ¶
type SALTTrie interface { Commit(cs *SaltChangeSet) Commitment CommitBatch(cs []*map[int]*JobChangeSet) Commitment GetJobNums() int GetNodeCommitment(idx int) Commitment Insert(k, v []byte, cm *SaltChangeSet) error InsertBatch(ks, vs [][32]byte) ([]*map[int]*JobChangeSet, error) InternalNodeCount() int BucketCount() int SetJobNums(nums int) IsLeafNil(idx int) bool GetKvCount(idx int) int }
func NewSALTTrie ¶
type SHITable ¶
type SHITable struct {
// contains filtered or unexported fields
}
SHITable
func (*SHITable) Delete ¶
func (t *SHITable) Delete(k []byte, s *BucketChangeSet) error
Delete item by key in SHITable
func (*SHITable) Delete2 ¶
func (t *SHITable) Delete2(k []byte, s *BucketChangeSet) error
Delete item by key in SHITable
type SHITableChangeSet ¶
type SHITableChangeSet struct {
// contains filtered or unexported fields
}
SHITable Manager's Change sets
func (*SHITableChangeSet) Count ¶
func (cm *SHITableChangeSet) Count() (int, int)
Get the Changeset numbers
type SHITableGoMap ¶
type SHITableGoMap struct {
// contains filtered or unexported fields
}
SHITable
func (*SHITableGoMap) Delete ¶
func (t *SHITableGoMap) Delete(k []byte, s *BucketChangeSet) error
Delete item by key in SHITable
func (*SHITableGoMap) Delete2 ¶
func (t *SHITableGoMap) Delete2(k []byte, s *BucketChangeSet) error
Delete item by key in SHITable
func (*SHITableGoMap) GetNodeByKey ¶
func (t *SHITableGoMap) GetNodeByKey(key []byte) (KV, error)
func (*SHITableGoMap) Insert ¶
func (t *SHITableGoMap) Insert(k, v []byte, set *BucketChangeSet) error
func (*SHITableGoMap) Insert2 ¶
func (t *SHITableGoMap) Insert2(k, v []byte, set *BucketChangeSet) error
Insert/Update k,v to SHITable
func (*SHITableGoMap) IsEqual ¶
func (t *SHITableGoMap) IsEqual(other *SHITableGoMap) bool
Check that the two tables are equal
type SHITableManager ¶
type SHITableManager struct {
// contains filtered or unexported fields
}
SHITableManager store k/v paris.
func NewSHITableManager ¶
func NewSHITableManager(mapType int) *SHITableManager
New a ShiTableManager
func (*SHITableManager) CheckBucketKV ¶
func (m *SHITableManager) CheckBucketKV(i, j int, k, v []byte) bool
Check Bucket[i][j] is equal k,v
func (*SHITableManager) Delete ¶
func (m *SHITableManager) Delete(k []byte, cm *SHITableChangeSet) error
Delete item by key
func (*SHITableManager) GetKVCount ¶
func (m *SHITableManager) GetKVCount() int
Count the number of kvs in SHITableManager
func (*SHITableManager) GetNodeByKey ¶
func (m *SHITableManager) GetNodeByKey(k []byte) (KV, error)
Get the SHITable Node by key
func (*SHITableManager) Insert ¶
func (m *SHITableManager) Insert(k, v []byte, cm *SHITableChangeSet) error
Insert/Update to SHITable
type SaltChangeSet ¶
type SaltChangeSet = SHITableChangeSet
type SerializedNode ¶
type SerializedNode struct { Node VerkleNode CommitmentBytes [banderwagon.UncompressedSize]byte Path []byte SerializedBytes []byte }
SerializedNode contains a serialization of a tree node. It provides everything that the client needs to save the node to the database. For example, CommitmentBytes is usually use as key and SerializedBytes as value. Providing both allows this library to do more optimizations.
type SerializedPoint ¶
type SerializedPoint = []byte
type SerializedPointCompressed ¶
type SerializedPointCompressed = []byte
type StateDiff ¶
type StateDiff []StemStateDiff
type StemStateDiff ¶
type StemStateDiff struct { Stem [31]byte `json:"stem"` SuffixDiffs SuffixStateDiffs `json:"suffixDiffs"` }
func (StemStateDiff) MarshalJSON ¶
func (ssd StemStateDiff) MarshalJSON() ([]byte, error)
func (*StemStateDiff) UnmarshalJSON ¶
func (ssd *StemStateDiff) UnmarshalJSON(data []byte) error
type SuffixStateDiff ¶
type SuffixStateDiff struct { Suffix byte `json:"suffix"` CurrentValue *[32]byte `json:"currentValue"` NewValue *[32]byte `json:"newValue"` }
func (SuffixStateDiff) MarshalJSON ¶
func (ssd SuffixStateDiff) MarshalJSON() ([]byte, error)
func (*SuffixStateDiff) UnmarshalJSON ¶
func (ssd *SuffixStateDiff) UnmarshalJSON(data []byte) error
type SuffixStateDiffs ¶
type SuffixStateDiffs []SuffixStateDiff
type U256 ¶
type U256 = [MAX_KEY_SIZE]byte
type UnknownNode ¶
type UnknownNode struct{}
func (UnknownNode) Commit ¶
func (n UnknownNode) Commit() *Point
func (UnknownNode) Commitment ¶
func (UnknownNode) Commitment() *Point
func (UnknownNode) Copy ¶
func (UnknownNode) Copy() VerkleNode
func (UnknownNode) Delete ¶
func (UnknownNode) Delete([]byte, NodeResolverFn) (bool, error)
func (UnknownNode) Get ¶
func (UnknownNode) Get([]byte, NodeResolverFn) ([]byte, error)
func (UnknownNode) GetProofItems ¶
func (UnknownNode) GetProofItems(keylist, NodeResolverFn) (*ProofElements, []byte, [][]byte, error)
func (UnknownNode) Hash ¶
func (UnknownNode) Hash() *Fr
func (UnknownNode) Insert ¶
func (UnknownNode) Insert([]byte, []byte, NodeResolverFn) error
func (UnknownNode) Serialize ¶
func (UnknownNode) Serialize() ([]byte, error)
type VerkleNode ¶
type VerkleNode interface { // Insert or Update value into the tree Insert([]byte, []byte, NodeResolverFn) error // Delete a leaf with the given key Delete([]byte, NodeResolverFn) (bool, 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, NodeResolverFn) (*ProofElements, []byte, [][]byte, error) // 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. This method is deprecated, use with caution.
func NewStatelessInternal ¶
func NewStatelessInternal(depth byte, comm *Point) VerkleNode
func ParseNode ¶
func ParseNode(serializedNode []byte, depth byte) (VerkleNode, error)
ParseNode deserializes a node into its proper VerkleNode instance. The serialized bytes have the format: - Internal nodes: <nodeType><bitlist><commitment> - Leaf nodes: <nodeType><stem><bitlist><comm><c1comm><c2comm><children...>
func PostStateTreeFromStateDiff ¶
func PostStateTreeFromStateDiff(preroot VerkleNode, statediff StateDiff) (VerkleNode, error)
PostStateTreeFromProof uses the pre-state trie and the list of updated values to produce the stateless post-state trie.
func PreStateTreeFromProof ¶
func PreStateTreeFromProof(proof *Proof, rootC *Point) (VerkleNode, error)
PreStateTreeFromProof builds a stateless prestate tree from the proof.
type VerkleProof ¶
type VerkleProof struct { OtherStems [][31]byte `json:"otherStems"` DepthExtensionPresent []byte `json:"depthExtensionPresent"` CommitmentsByPath [][32]byte `json:"commitmentsByPath"` D [32]byte `json:"d"` IPAProof *IPAProof `json:"ipa_proof"` }
func (*VerkleProof) Copy ¶
func (vp *VerkleProof) Copy() *VerkleProof
func (*VerkleProof) MarshalJSON ¶
func (vp *VerkleProof) MarshalJSON() ([]byte, error)
func (*VerkleProof) UnmarshalJSON ¶
func (vp *VerkleProof) UnmarshalJSON(data []byte) error