proof

package
v0.0.0-...-46f88e6 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2023 License: ISC Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PcpHash

func PcpHash(
	annHashes *[4][32]byte,
	annCount uint64,
	annIndexes *[4]uint64,
	pcp *wire.PacketCryptProof,
) (*[32]byte, er.R)

Types

type Flag

type Flag uint16

Flag is a flag which is applied to tree entries to indicate their state

const (

	// FComputable means no information will be provided about this node because
	// it can be fully computed (both child nodes are known)
	FComputable Flag = 1

	// FPadEntry means this is a pad entry (added to make the number of nodes even)
	// no information is provided because it's hard-wired to all ff
	FPadEntry Flag = (1 << 1)

	// FLeaf this node is canadian, it corrisponds to an announcement hash
	// (including the ones which we're proving)
	FLeaf Flag = (1 << 2)

	// FRight means this node is a right-hand node, if this flag is not present then
	// the node is left-hand or is the root
	FRight Flag = (1 << 3)

	// FPadSibling left sibling of a pad entry, in practice this will always be
	// COMPUTABLE and so no information is provided anyway but it is here for completeness.
	FPadSibling Flag = (1 << 4)

	// FFirstEntry means the node is the first node in the layer (index 0), this
	// means the "start" for this node is known, it is 0
	FFirstEntry Flag = (1 << 5)

	// FHasHash is set when we know the hash for a given node, it means the hash
	// value is meaningful
	FHasHash Flag = (1 << 8)

	// FHasRange is set when we know the range for a node
	FHasRange Flag = (1 << 9)

	// FHasStart is set when we know the start for a node.
	FHasStart Flag = (1 << 10)

	// FHasEnd means that we know the end of a node's range.
	FHasEnd Flag = (1 << 11)
)

func (Flag) String

func (f Flag) String() string

type Tree

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

func NewTree

func NewTree(annCount uint64, annIdxs *[4]uint64) (*Tree, er.R)

func (*Tree) DumpTree

func (t *Tree) DumpTree()

func (*Tree) GetAnnEntry

func (t *Tree) GetAnnEntry(annNum uint64) *TreeNode

GetAnnEntry gets the table netry corrisponding to a particular announcement.

func (*Tree) GetRoot

func (t *Tree) GetRoot() *TreeNode

GetRoot returns the entry which is at the root of the tree, this one's hash is committed in the coinbase.

type TreeNode

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

func (*TreeNode) End

func (te *TreeNode) End() uint64

End gets the end of the node's range (next entry hash - 1)

func (*TreeNode) Flags

func (te *TreeNode) Flags() Flag

Flags gets the flags for this node

func (*TreeNode) GetParent

func (te *TreeNode) GetParent() *TreeNode

GetParent returns the node's parent, nil for the root node

func (*TreeNode) GetSibling

func (te *TreeNode) GetSibling() *TreeNode

GetSibling returns the node's sibling, nil for the root node

func (*TreeNode) HasExplicitRange

func (te *TreeNode) HasExplicitRange() bool

HasExplicitRange returns true if the entry requires an explicit range in order to validate

func (*TreeNode) Hash

func (te *TreeNode) Hash() []byte

Hash gets the memory location of the entry hash (mutable)

func (*TreeNode) Number

func (te *TreeNode) Number() int

Number gives the id of this node in the tree

func (*TreeNode) Range

func (te *TreeNode) Range() uint64

Range gets the difference between the start and the end if it is not yet known then the result will be 0

func (*TreeNode) SetEnd

func (te *TreeNode) SetEnd(s uint64) bool

SetEnd sets the end of the node's range, if the range is known then the start will be inferred and saved.

func (*TreeNode) SetHash

func (te *TreeNode) SetHash(h []byte) bool

SetHash sets the provided byte array to the entry hash and flags as hash present

func (*TreeNode) SetRange

func (te *TreeNode) SetRange(s uint64) bool

SetRange sets the range for a node, if the start is known then the start and end are computed and saved. If the range has already been set then this function returns false

func (*TreeNode) SetStart

func (te *TreeNode) SetStart(s uint64) bool

SetStart sets the start point of of the node's range

func (*TreeNode) Start

func (te *TreeNode) Start() uint64

Start gets the uint64 representing the start of the node's range

Jump to

Keyboard shortcuts

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