Documentation ¶
Index ¶
- func VerifyProof(hashFunc arbo.HashFunction, key, value, proof, root []byte) (bool, error)
- type Options
- type Tree
- func (t *Tree) Add(wTx db.WriteTx, key, value []byte) error
- func (t *Tree) AddBatch(wTx db.WriteTx, keys, values [][]byte) ([]int, error)
- func (t *Tree) DB() db.Database
- func (t *Tree) Del(wTx db.WriteTx, key []byte) error
- func (t *Tree) Dump() ([]byte, error)
- func (t *Tree) DumpWriter(w io.Writer) error
- func (t *Tree) FromRoot(root []byte) (*Tree, error)
- func (t *Tree) GenProof(rTx db.Reader, key []byte) ([]byte, []byte, error)
- func (t *Tree) Get(rTx db.Reader, key []byte) ([]byte, error)
- func (t *Tree) ImportDump(b []byte) error
- func (t *Tree) Iterate(rTx db.Reader, callback func(key, value []byte) bool) error
- func (t *Tree) IterateLeaves(rTx db.Reader, callback func(key, value []byte) bool) error
- func (t *Tree) PrintGraphviz(rTx db.Reader) error
- func (t *Tree) Root(rTx db.Reader) ([]byte, error)
- func (t *Tree) Set(wTx db.WriteTx, key, value []byte) error
- func (t *Tree) SetRoot(wTx db.WriteTx, root []byte) error
- func (t *Tree) Size(rTx db.Reader) (uint64, error)
- func (t *Tree) VerifyProof(key, value, proof, root []byte) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func VerifyProof ¶
func VerifyProof(hashFunc arbo.HashFunction, key, value, proof, root []byte) (bool, error)
VerifyProof checks the proof for the given key, value and root, using the passed hash function
Types ¶
type Options ¶
type Options struct { // DB defines the database that will be used for the tree DB db.Database // MaxLevels that the Tree will have MaxLevels int // HashFunc defines the hash function that the tree will use HashFunc arbo.HashFunction }
Options is used to pass the parameters to load a new Tree
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree defines the struct that implements the MerkleTree functionalities
func (*Tree) AddBatch ¶
AddBatch adds a batch of key-values to the Tree. Returns an array containing the indexes of the keys failed to add. Supports empty values as input parameters, which is equivalent to 0 valued byte array.
func (*Tree) DumpWriter ¶
DumpWriter exports all the Tree leafs in a byte writer.
func (*Tree) FromRoot ¶
FromRoot returns a new read-only Tree for the given root, that uses the same underlying db.
func (*Tree) GenProof ¶
GenProof returns a byte array with the necessary data to verify that the key&value are in a leaf under the current root
func (*Tree) ImportDump ¶
ImportDump imports the leafs (that have been exported with the Dump method) in the Tree.
func (*Tree) Iterate ¶
Iterate over all the database-encoded nodes of the tree. When callback returns true, the iteration is stopped and this function returns.
func (*Tree) IterateLeaves ¶
IterateLeaves iterates over all leafs of the tree. When callback returns true, the iteration is stopped and this function returns.
func (*Tree) Set ¶
Set adds or updates a key. First performs a Get, and if the key does not exist yet it will call Add, while if the key already exists, it will perform an Update. If the non-existence or existence of the key is already known, is more efficient to directly call Add or Update.
Directories ¶
Path | Synopsis |
---|---|
Package arbo implements a Merkle Tree compatible with the circomlib implementation of the MerkleTree, following the specification from https://docs.iden3.io/publications/pdfs/Merkle-Tree.pdf and https://eprint.iacr.org/2018/955.
|
Package arbo implements a Merkle Tree compatible with the circomlib implementation of the MerkleTree, following the specification from https://docs.iden3.io/publications/pdfs/Merkle-Tree.pdf and https://eprint.iacr.org/2018/955. |