Documentation ¶
Index ¶
- Constants
- func BytesToBig(data []byte) *big.Int
- type BranchElement
- type BranchNode
- type BranchTree
- type DagData
- type DagTree
- type ElementData
- type Hash
- type MerkleTree
- func (mt MerkleTree) Branches() map[uint32]BranchTree
- func (mt MerkleTree) ExportNodes() []NodeData
- func (mt *MerkleTree) Finalize()
- func (mt MerkleTree) Indices() []uint32
- func (mt *MerkleTree) Insert(data ElementData, index uint32)
- func (mt *MerkleTree) RegisterIndex(indexes ...uint32)
- func (mt *MerkleTree) RegisterStoredLevel(depth, level uint32)
- func (mt MerkleTree) Root() NodeData
- func (mt *MerkleTree) SetElementHashFunction(_h elementHashFunc)
- func (mt *MerkleTree) SetHashFunction(_h hashFunc)
- func (mt *MerkleTree) StoredLevel() uint32
- type NodeData
- type Word
Constants ¶
View Source
const ( HashLength = 16 // bytes WordLength = 128 // bytes BranchElementLength = 32 // bytes )
Variables ¶
This section is empty.
Functions ¶
func BytesToBig ¶
Types ¶
type BranchElement ¶
type BranchElement [BranchElementLength]byte
func BranchElementFromHash ¶
func BranchElementFromHash(a, b Hash) BranchElement
func HashesToBranchesArray ¶
func HashesToBranchesArray(hashes []Hash) []BranchElement
func (BranchElement) Big ¶
func (h BranchElement) Big() *big.Int
func (BranchElement) Bytes ¶
func (h BranchElement) Bytes() []byte
func (BranchElement) Hex ¶
func (h BranchElement) Hex() string
func (BranchElement) String ¶
func (h BranchElement) String() string
type BranchNode ¶
type BranchNode struct { Hash NodeData Left *BranchNode Right *BranchNode ElementOnTheLeft bool }
func AcceptLeftSibling ¶
func AcceptLeftSibling(b *BranchNode, h NodeData) *BranchNode
explain the operation
func AcceptRightSibling ¶
func AcceptRightSibling(b *BranchNode, h NodeData) *BranchNode
func (BranchNode) ToNodeArray ¶
func (b BranchNode) ToNodeArray() []NodeData
type BranchTree ¶
type BranchTree struct { RawData ElementData HashedData NodeData Root *BranchNode }
func (BranchTree) ToNodeArray ¶
func (t BranchTree) ToNodeArray() []NodeData
type DagTree ¶
type DagTree struct {
MerkleTree
}
func NewKeccak256DagTree ¶
func NewKeccak256DagTree() *DagTree
func NewSHA256DagTree ¶
func NewSHA256DagTree() *DagTree
func (DagTree) AllBranchesArray ¶
func (dt DagTree) AllBranchesArray() []BranchElement
return only one array with necessary hashes for each index in order. Element's hash and root are not included eg. registered indexes are 1, 2, each needs 2 hashes then the function return an array of 4 hashes [a1, a2, b1, b2] where a1, a2 are proof branch for element at index 1 b1, b2 are proof branch for element at index 2
func (DagTree) AllDAGElements ¶
func (DagTree) ProofsForRegisteredIndices ¶
type ElementData ¶
type ElementData interface{}
type Hash ¶
type Hash [HashLength]byte
type MerkleTree ¶
type MerkleTree struct {
// contains filtered or unexported fields
}
func (MerkleTree) Branches ¶
func (mt MerkleTree) Branches() map[uint32]BranchTree
func (MerkleTree) ExportNodes ¶
func (mt MerkleTree) ExportNodes() []NodeData
func (*MerkleTree) Finalize ¶
func (mt *MerkleTree) Finalize()
func (MerkleTree) Indices ¶
func (mt MerkleTree) Indices() []uint32
func (*MerkleTree) Insert ¶
func (mt *MerkleTree) Insert(data ElementData, index uint32)
func (*MerkleTree) RegisterIndex ¶
func (mt *MerkleTree) RegisterIndex(indexes ...uint32)
register indexes to build branches
func (*MerkleTree) RegisterStoredLevel ¶
func (mt *MerkleTree) RegisterStoredLevel(depth, level uint32)
func (MerkleTree) Root ¶
func (mt MerkleTree) Root() NodeData
func (*MerkleTree) SetElementHashFunction ¶
func (mt *MerkleTree) SetElementHashFunction(_h elementHashFunc)
func (*MerkleTree) SetHashFunction ¶
func (mt *MerkleTree) SetHashFunction(_h hashFunc)
func (*MerkleTree) StoredLevel ¶
func (mt *MerkleTree) StoredLevel() uint32
Click to show internal directories.
Click to hide internal directories.