common

package
v0.15.3-patch.6 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2021 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const HashLen = hash.HashLenSha3_256

HashLen is the default output hash length in bytes

Variables

View Source
var EmptyHash [HashLen]byte

EmptyHash is a hash with all zeroes, used for padding

Functions

func ComputeCompactValue

func ComputeCompactValue(result *[]byte, path []byte, payload *ledger.Payload, nodeHeight int)

ComputeCompactValue computes the value for the node considering the sub tree to only include this value and default values. It writes the hash result to the result input.

func GetDefaultHashForHeight

func GetDefaultHashForHeight(height int) []byte

GetDefaultHashForHeight returns the default hashes of the SMT at a specified height.

For each tree level N, there is a default hash equal to the chained hashing of the default value N times.

func GetDefaultHashes

func GetDefaultHashes() [defaultHashLen][]byte

GetDefaultHashes returns the default hashes of the SMT.

For each tree level N, there is a default hash equal to the chained hashing of the default value N times.

func HashInterNode

func HashInterNode(hash1 []byte, hash2 []byte) []byte

HashInterNode generates hash value for intermediate nodes (SHA3-256).

hash1 and hash2 must each be a 32 byte slice. TODO: delete this function after refactoring ptrie

func HashInterNodeIn added in v0.16.0

func HashInterNodeIn(result *[]byte, hash1 []byte, hash2 []byte)

HashInterNodeIn generates hash value for intermediate nodes (SHA3-256) and stores the hash value in the provided result slice

result slice can be equal to hash1 or hash2. hash1 and hash2 must each be a 32 byte slice.

func HashLeaf

func HashLeaf(path []byte, value []byte) []byte

HashLeaf generates hash value for leaf nodes (SHA3-256).

path must be a 32 byte slice. note that we don't include the keys here as they are already included in the path TODO: delete this function after refactoring ptrie

func HashLeafIn added in v0.16.0

func HashLeafIn(result *[]byte, path []byte, value []byte)

HashLeafIn generates hash value for leaf nodes (SHA3-256) and stores the hash value in the provided result slice

path must be a 32 byte slice. note that we don't include the keys here as they are already included in the path

func VerifyTrieBatchProof

func VerifyTrieBatchProof(bp *ledger.TrieBatchProof, expectedState ledger.State) bool

VerifyTrieBatchProof verifies all the proof inside the batchproof

func VerifyTrieProof

func VerifyTrieProof(p *ledger.TrieProof, expectedState ledger.State) bool

VerifyTrieProof verifies the proof, by constructing all the hash from the leaf to the root and comparing the rootHash

Types

This section is empty.

Directories

Path Synopsis
Package encoding provides byte serialization and deserialization of trie and ledger structs.
Package encoding provides byte serialization and deserialization of trie and ledger structs.
Package pathfinder computes the trie storage path for any given key/value pair
Package pathfinder computes the trie storage path for any given key/value pair

Jump to

Keyboard shortcuts

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