proof

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: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeBatchProof

func EncodeBatchProof(bp *BatchProof) ([][]byte, int)

EncodeBatchProof encodes all the content of a batch proof into an array of byte arrays

func SplitKeyProofs

func SplitKeyProofs(keys [][]byte, proofs []*Proof, bitIndex int) ([][]byte, []*Proof, [][]byte, []*Proof, error)

SplitKeyProofs splits a set of unordered key and proof pairs based on the value of bit (bitIndex)

Types

type BatchProof

type BatchProof struct {
	Proofs []*Proof
}

BatchProof is a struct that holds the proofs for several keys

TODO (add key values to batch proof and make it self-included), so there is no need for two calls (read, proofs)

func DecodeBatchProof

func DecodeBatchProof(proofs [][]byte) (*BatchProof, error)

DecodeBatchProof takes in an encodes array of byte arrays an converts them into a BatchProof

func NewBatchProof

func NewBatchProof() *BatchProof

NewBatchProof creates a new instance of BatchProof

func NewBatchProofWithEmptyProofs

func NewBatchProofWithEmptyProofs(numberOfProofs int) *BatchProof

NewBatchProofWithEmptyProofs creates an instance of Batchproof filled with n newly created proofs (empty)

func (*BatchProof) AppendProof

func (bp *BatchProof) AppendProof(p *Proof)

AppendProof adds a proof to the batch proof

func (*BatchProof) MergeInto

func (bp *BatchProof) MergeInto(dest *BatchProof)

MergeInto adds all of its proofs into the dest batch proof

func (*BatchProof) Size

func (bp *BatchProof) Size() int

Size returns the number of proofs

func (*BatchProof) String

func (bp *BatchProof) String() string

func (*BatchProof) Verify

func (bp *BatchProof) Verify(keys [][]byte, values [][]byte, expectedRootHash []byte, expectedKeySize int) bool

Verify verifies all the proof inside the batchproof

type Proof

type Proof struct {
	Values    [][]byte // the non-default intermediate nodes in the proof
	Inclusion bool     // flag indicating if this is an inclusion or exclusion
	Flags     []byte   // The flags of the proofs (is set if an intermediate node has a non-default)
	Steps     uint8    // number of steps for the proof (path len) // TODO: should this be a type allowing for larger values?
}

Proof includes all the information needed to walk through a trie branch from an specific leaf node (key) up to the root of the trie.

func NewProof

func NewProof() *Proof

NewProof creates a new instance of Proof

func (*Proof) Export

func (p *Proof) Export() ([]byte, [][]byte, bool, uint8)

Export return the flag, proofs, inclusion, an size of the proof

func (*Proof) String

func (p *Proof) String() string

func (*Proof) Verify

func (p *Proof) Verify(key []byte, value []byte, expectedRootHash []byte, expectedKeySize int) bool

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

Jump to

Keyboard shortcuts

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