mta

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HashSize = 32
)

Variables

This section is empty.

Functions

func GetDepthByHeightAndAccLength

func GetDepthByHeightAndAccLength(height, accLength int64) int

func GetHeightFromWitness

func GetHeightFromWitness(ws []Witness, accLength int64) int64

func WitnessesToHashes

func WitnessesToHashes(w []Witness) [][]byte

Types

type Accumulator

type Accumulator struct {
	KeyForState []byte    // key to recover state
	Bucket      db.Bucket // bucket to store all state data
	// contains filtered or unexported fields
}

func (*Accumulator) AddData

func (a *Accumulator) AddData(d []byte) []Witness

func (*Accumulator) AddHash

func (a *Accumulator) AddHash(h []byte) []Witness

func (*Accumulator) AddNode

func (a *Accumulator) AddNode(n Node) []Witness

func (*Accumulator) Flush

func (a *Accumulator) Flush() error

func (*Accumulator) GetNode

func (a *Accumulator) GetNode(idx int64) (Node, error)

func (*Accumulator) Len

func (a *Accumulator) Len() int64

func (*Accumulator) Recover

func (a *Accumulator) Recover() error

func (*Accumulator) String

func (a *Accumulator) String() string

func (*Accumulator) Verify

func (a *Accumulator) Verify(ws []Witness, h []byte) error

func (*Accumulator) VerifyWithAccLength

func (a *Accumulator) VerifyWithAccLength(ws []Witness, h []byte, accLength int64) error

func (*Accumulator) WitnessFor

func (a *Accumulator) WitnessFor(idx int64) (w []Witness, err error)

func (*Accumulator) WitnessForWithAccLength

func (a *Accumulator) WitnessForWithAccLength(idx, accLength int64) (w []Witness, err error)

type Direction

type Direction int
const (
	Left Direction = iota
	Right
)

func (Direction) String

func (d Direction) String() string

type ExtAccumulator

type ExtAccumulator struct {
	Accumulator
	// contains filtered or unexported fields
}

func NewExtAccumulator

func NewExtAccumulator(keyForState []byte, bk db.Bucket, offset int64) *ExtAccumulator

func (*ExtAccumulator) AddData

func (a *ExtAccumulator) AddData(d []byte) []Witness

func (*ExtAccumulator) AddHash

func (a *ExtAccumulator) AddHash(h []byte) []Witness

func (*ExtAccumulator) AddNode

func (a *ExtAccumulator) AddNode(n Node) []Witness

func (*ExtAccumulator) Flush

func (a *ExtAccumulator) Flush() error

func (*ExtAccumulator) GetNode

func (a *ExtAccumulator) GetNode(height int64) (Node, error)

func (*ExtAccumulator) Height

func (a *ExtAccumulator) Height() int64

func (*ExtAccumulator) Offset

func (a *ExtAccumulator) Offset() int64

func (*ExtAccumulator) Recover

func (a *ExtAccumulator) Recover() error

func (*ExtAccumulator) Serialized

func (a *ExtAccumulator) Serialized() []byte

func (*ExtAccumulator) VerifyAt

func (a *ExtAccumulator) VerifyAt(w []Witness, h []byte, at, offset int64) error

func (*ExtAccumulator) WitnessForAt

func (a *ExtAccumulator) WitnessForAt(height, at, offset int64) (int64, []Witness, error)

type Node

type Node interface {
	Hash() []byte
	Flush() error
	WitnessFor(depth int, idx int64, w []Witness) (Node, []Witness, error)
}

func GetNode

func GetNode(p Node, depth int, idx int64) (Node, error)

type State

type State int

type Witness

type Witness struct {
	Direction Direction
	HashValue []byte
}

func HashesToWitness

func HashesToWitness(hvs [][]byte, idx int64) []Witness

func (Witness) String

func (w Witness) String() string

Jump to

Keyboard shortcuts

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