common

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2020 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeCompactValue

func ComputeCompactValue(key []byte, value []byte, nodeHeight int) []byte

ComputeCompactValue computes the value for the node considering the sub tree to only include this value and default values.

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() [257][]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 GetRandomKeysFixedN

func GetRandomKeysFixedN(n int, byteSize int) [][]byte

GetRandomKeysFixedN generates n random (no repetition) fixed sized (byteSize) keys

func GetRandomKeysRandN

func GetRandomKeysRandN(maxN int, byteSize int) [][]byte

GetRandomKeysRandN generate m random keys (key size: byteSize), the number of keys generates, m, is also randomly selected from the range [1, maxN]

func GetRandomValues

func GetRandomValues(n int, maxByteSize int) [][]byte

GetRandomValues generate an slice (len n) of random values (byte slice) of random size from the range [1, maxByteSize]

func HashInterNode

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

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

func HashLeaf

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

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

func IsBitSet

func IsBitSet(b []byte, idx int) (bool, error)

IsBitSet returns if the bit at index `idx` in the byte array `b` is set to 1 (big endian) TODO: remove error return

func MaxUint16

func MaxUint16(a, b uint16) uint16

MaxUint16 returns the max value of two uint16

func SetBit

func SetBit(b []byte, i int) error

SetBit sets the bit at position i in the byte array b to 1 TODO: remove error return

func SplitKeyValues

func SplitKeyValues(keys [][]byte, values [][]byte, bitIndex int) ([][]byte, [][]byte, [][]byte, [][]byte, error)

SplitKeyValues splits a set of unordered key value pairs based on the value of bit (bitIndex) TODO: remove error return

func SplitSortedKeys

func SplitSortedKeys(keys [][]byte, bitIndex int) ([][]byte, [][]byte, error)

SplitSortedKeys splits a set of ordered keys based on the value of bit (bitIndex)

Types

This section is empty.

Jump to

Keyboard shortcuts

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