elkrem

package
v0.0.0-...-8c3d3b4 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: MIT Imports: 4 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LeftSha

func LeftSha(in chainhash.Hash) chainhash.Hash

func RightSha

func RightSha(in chainhash.Hash) chainhash.Hash

Types

type ElkremNode

type ElkremNode struct {
	H   uint8           `json:"h"`    // height of this node
	I   uint64          `json:"i"`    // index (i'th node)
	Sha *chainhash.Hash `json:"hash"` // hash
}

You can calculate h from i but I can't figure out how without taking O(i) ops. Feels like there should be a clever O(h) way. 1 byte, whatever.

type ElkremReceiver

type ElkremReceiver struct {
	Nodes []ElkremNode `json:"nodes"` // store of received hashes
}

func ElkremReceiverFromBytes

func ElkremReceiverFromBytes(b []byte) (*ElkremReceiver, error)

func NewElkremReceiver

func NewElkremReceiver() *ElkremReceiver

NewElkremReceiver makes a new empty elkrem receiver.

func (*ElkremReceiver) AddNext

func (e *ElkremReceiver) AddNext(sha *chainhash.Hash) error

AddNext inserts the next hash in the tree. Returns an error if the incoming hash doesn't fit.

func (*ElkremReceiver) AtIndex

func (e *ElkremReceiver) AtIndex(w uint64) (*chainhash.Hash, error)

AtIndex returns the w'th hash in the receiver.

func (*ElkremReceiver) ToBytes

func (e *ElkremReceiver) ToBytes() ([]byte, error)

ToBytes turns the Elkrem Receiver into a bunch of bytes in a slice. first the number of nodes (1 byte), then a series of 41 byte long serialized nodes, which are 1 byte height, 8 byte index, 32 byte hash.

func (*ElkremReceiver) UpTo

func (e *ElkremReceiver) UpTo() uint64

UpTo tells you what the receiver can go up to.

type ElkremSender

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

func NewElkremSender

func NewElkremSender(r chainhash.Hash) *ElkremSender

NewElkremSender makes a new elkrem sender from a root hash.

func (*ElkremSender) AtIndex

func (e *ElkremSender) AtIndex(w uint64) (*chainhash.Hash, error)

AtIndex skips to the requested index should never error; remove error..?

Jump to

Keyboard shortcuts

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