merklehasher

package
v3.0.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: MIT Imports: 7 Imported by: 4

Documentation

Index

Constants

View Source
const (
	LeafHashPrefix = 0
	NodeHashPrefix = 1
)

Domain separation prefixes.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hasher

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

Hasher implements the hashing algorithm described in the IOTA protocol RFC-12.

func NewHasher

func NewHasher(h crypto.Hash) *Hasher

NewHasher creates a new Hasher using the provided hash function.

func (*Hasher) ComputeProof

func (t *Hasher) ComputeProof(blockIDs iotago.BlockIDs, blockID iotago.BlockID) (*Proof, error)

ComputeProof computes the audit path given the blockIDs and the blockID we want to create the inclusion proof for.

func (*Hasher) ComputeProofForIndex

func (t *Hasher) ComputeProofForIndex(blockIDs iotago.BlockIDs, index int) (*Proof, error)

ComputeProofForIndex computes the audit path given the blockIDs and the index of the blockID we want to create the inclusion proof for.

func (*Hasher) EmptyRoot

func (t *Hasher) EmptyRoot() []byte

EmptyRoot returns a special case for an empty tree. This is equivalent to Hash(nil).

func (*Hasher) Hash

func (t *Hasher) Hash(data [][]byte) []byte

Hash computes the Merkle tree hash of the provided data.

func (*Hasher) HashBlockIDs

func (t *Hasher) HashBlockIDs(blockIDs iotago.BlockIDs) []byte

HashBlockIDs computes the Merkle tree hash of the provided BlockIDs.

func (*Hasher) Size

func (t *Hasher) Size() int

Size returns the length, in bytes, of a digest resulting from the given hash function.

type Proof

type Proof struct {
	Left  hashable
	Right hashable
}

func (*Proof) ContainsValue

func (p *Proof) ContainsValue(value iotago.BlockID) (bool, error)

func (*Proof) Hash

func (p *Proof) Hash(hasher *Hasher) []byte

func (*Proof) MarshalJSON

func (p *Proof) MarshalJSON() ([]byte, error)

func (*Proof) UnmarshalJSON

func (p *Proof) UnmarshalJSON(bytes []byte) error

Jump to

Keyboard shortcuts

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