trie

package
v0.0.0-...-bfa3489 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenKeys

func GenKeys(n int) []*kvpair

func GenKeysISCP

func GenKeysISCP(total, numSC int) []*kvpair

func HasAllKeys

func HasAllKeys(st *State, kvpairs []*kvpair) bool

func NewSimpleKVStore

func NewSimpleKVStore() *kvStoreSimple

func PrintSizeDistrib

func PrintSizeDistrib(t *testing.T, distrib map[int]int)

func RandomizeKeys

func RandomizeKeys(pairs []*kvpair) []*kvpair

func UpdateKeys

func UpdateKeys(st *State, pairs []*kvpair) kyber.Point

func VerifyProof

func VerifyProof(ts *kzg.TrustedSetup, proof *Proof) error

Types

type KVStore

type KVStore interface {
	Set(k []byte, v []byte)
	Del(k []byte)
	Get(k []byte) ([]byte, bool)
	Has(k []byte) bool
	Partition(prefix string) KVStore
	Keys() []string
	Size() int
}

KVStore abstract interface only used in this trie implementation

type Node

type Node struct {
	// contains filtered or unexported fields
}

Node is a node of the 257-ary verkle trie

func (*Node) Bytes

func (n *Node) Bytes() []byte

Bytes

func (*Node) Clone

func (n *Node) Clone() *Node

Clone

func (*Node) Commit

func (n *Node) Commit(ts *kzg.TrustedSetup) kyber.Point

Commit calculates commitment of the node from child commitments

func (*Node) String

func (n *Node) String() string

func (*Node) Vector

func (n *Node) Vector(ts *kzg.TrustedSetup, ret *[257]kyber.Scalar)

Vector extracts vector from the node

type Proof

type Proof struct {
	Key   []byte
	Value []byte
	Path  []*ProofElement
}

func (*Proof) IsProofOfAbsence

func (pr *Proof) IsProofOfAbsence() bool

func (*Proof) Len

func (pr *Proof) Len() int

func (*Proof) RootCommitment

func (pr *Proof) RootCommitment(ret kyber.Point)

type ProofElement

type ProofElement struct {
	C     kyber.Point // vector (node) commitment
	Index int
	Proof kyber.Point
}

type State

type State struct {
	// contains filtered or unexported fields
}

State represents kv store plus trie

func NewState

func NewState(ts *kzg.TrustedSetup) *State

func (*State) Check

func (st *State) Check(ts *kzg.TrustedSetup) bool

Check checks consistency with the provided trusted setup The trie always has to contain proof of binary data of the trusted setup present at nil key

func (*State) FlushCaches

func (st *State) FlushCaches()

func (*State) GetNode

func (st *State) GetNode(key []byte) (*Node, bool)

func (*State) GetValue

func (st *State) GetValue(key []byte) ([]byte, bool)

func (*State) NewNode

func (st *State) NewNode(key []byte) (*Node, error)

func (*State) NodeFromBytes

func (st *State) NodeFromBytes(data []byte) (*Node, error)

NodeFromBytes

func (*State) Prove

func (st *State) Prove(key []byte) (*Proof, bool)

Prove return a valid proof. If the key is present in the state, it contains the proof of presence of it in the key If the key is absent, the field Value == nil and the proof is a prove of commitment to 0 value in the last element of the path

func (*State) ProveStr

func (st *State) ProveStr(key string) (*Proof, bool)

ProveStr prove

func (*State) RootCommitment

func (st *State) RootCommitment(ret ...kyber.Point) kyber.Point

func (*State) StoreNode

func (st *State) StoreNode(key []byte, node *Node)

func (*State) StoreValue

func (st *State) StoreValue(key, value []byte)

func (*State) StringTrie

func (st *State) StringTrie() string

func (*State) Update

func (st *State) Update(key, value []byte)

func (*State) UpdateStr

func (st *State) UpdateStr(key, value string)

UpdateStr for testing

type StatsKVStore

type StatsKVStore struct {
	NumKeys      int
	AvgKeyLen    float64
	KeyLen       []int
	AvgValueSize float64
}

func GetStatsKVStore

func GetStatsKVStore(kvs KVStore) *StatsKVStore

type StatsTrie

type StatsTrie struct {
	NumNodes       int
	AvgNumChildren float64
	NumChildren    [258]int
	OnlyTerminal   int
}

func GetStatsTrie

func GetStatsTrie(st *State) *StatsTrie

Jump to

Keyboard shortcuts

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