shared

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 8 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// T is the security param which determines the number of leaves
	// to be included in a non-interactive proof.
	T uint8 = 150
)

Variables

This section is empty.

Functions

func CalcSubmitPowHash added in v0.7.0

func CalcSubmitPowHash(powChallenge, poetChallenge, nodeID, output []byte, nonce uint64) []byte

CalcSubmitPowHash calculates the hash for the Submit PoW. The hash is ripemd256(powChallenge || nodeID || poetChallenge || nonce).

func CheckLeadingZeroBits added in v0.7.0

func CheckLeadingZeroBits(data []byte, expected uint) bool

CheckLeadingZeroBits checks if the first 'expected' bits of the byte array are all zero.

func DecodeSliceOfByteSliceWithLimit added in v0.6.6

func DecodeSliceOfByteSliceWithLimit(d *scale.Decoder, outerLimit, innerLimit uint32) ([][]byte, int, error)

func FiatShamir

func FiatShamir(challenge []byte, spaceSize uint64, securityParam uint8) map[uint64]bool

FiatShamir generates a set of indices to include in a non-interactive proof.

func FindSubmitPowNonce added in v0.7.0

func FindSubmitPowNonce(
	ctx context.Context,
	powChallenge, poetChallenge, nodeID []byte,
	difficulty uint,
) (uint64, error)

FindSubmitPowNonce finds the nonce that solves the PoW challenge.

func HashMembershipTreeNode added in v0.8.2

func HashMembershipTreeNode(buf, lChild, rChild []byte) []byte

HashMembershipTreeNode calculates internal node of the membership merkle tree.

func MakeLabelFunc added in v0.2.0

func MakeLabelFunc() func(hash LabelHash, labelID uint64, leftSiblings [][]byte) []byte

MakeLabelFunc returns a function which generates a PoET DAG label by concatenating a representation of the labelID with the list of left siblings and then hashing the result using the provided hash function.

⚠️ The resulting function is NOT thread-safe, however different generated instances are independent. The code is optimized for performance and memory allocations.

Types

type LabelHash added in v0.5.0

type LabelHash func(data []byte) []byte

type MerkleProof

type MerkleProof struct {
	Root         []byte   `scale:"max=32"`
	ProvenLeaves [][]byte `scale:"max=150"`  // the max. size of this slice is T (security param), and each element is exactly 32 bytes
	ProofNodes   [][]byte `scale:"max=5400"` // 36 nodes per leaf and each node is exactly 32 bytes
}

MerkleProof is a non-interactive proof of inclusion in a Merkle tree. Scale encoding is implemented by hand to be able to limit [][]byte slices to a maximum size (inner and outer slices).

func (*MerkleProof) DecodeScale added in v0.2.0

func (t *MerkleProof) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*MerkleProof) EncodeScale added in v0.2.0

func (t *MerkleProof) EncodeScale(enc *scale.Encoder) (total int, err error)

type NIP added in v0.9.2

type NIP struct {
	MerkleProof
	Epoch  uint
	Leaves uint64
}

Non-Interactive proof of sequential work.

Jump to

Keyboard shortcuts

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