prover

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package prover implements the core proving functionality of PoET implementation.

Index

Constants

View Source
const (
	// MerkleMinCacheLayer set the min layer in which all layers above will be cached, in addition to the base layer.
	MerkleMinCacheLayer = 0

	// LowestMerkleMinMemoryLayer set the lowest-allowed layer in which all layers above will be cached in-memory.
	LowestMerkleMinMemoryLayer = 1
)

Variables

This section is empty.

Functions

func CalcTreeRoot added in v0.5.1

func CalcTreeRoot(leaves [][]byte) ([]byte, error)

Calculate the root of a Merkle Tree with given leaves.

func GenerateProof

func GenerateProof(
	ctx context.Context,
	datadir string,
	labelHashFunc func(data []byte) []byte,
	merkleHashFunc merkle.HashFunc,
	limit time.Time,
	securityParam uint8,
	minMemoryLayer uint,
	persist persistFunc,
) (uint64, *shared.MerkleProof, error)

GenerateProof computes the PoET DAG, uses Fiat-Shamir to derive a challenge from the Merkle root and generates a Merkle proof using the challenge and the DAG.

func GenerateProofRecovery

func GenerateProofRecovery(
	ctx context.Context,
	datadir string,
	labelHashFunc func(data []byte) []byte,
	merkleHashFunc merkle.HashFunc,
	limit time.Time,
	securityParam uint8,
	nextLeafID uint64,
	parkedNodes [][]byte,
	persist persistFunc,
) (uint64, *shared.MerkleProof, error)

GenerateProofRecovery recovers proof generation, from a given 'nextLeafID' and for a given 'parkedNodes' snapshot.

func GenerateProofWithoutPersistency

func GenerateProofWithoutPersistency(
	ctx context.Context,
	datadir string,
	labelHashFunc func(data []byte) []byte,
	merkleHashFunc merkle.HashFunc,
	limit time.Time,
	securityParam uint8,
	minMemoryLayer uint,
) (uint64, *shared.MerkleProof, error)

GenerateProofWithoutPersistency calls GenerateProof with disabled persistency functionality and potential soft/hard-shutdown recovery.

Types

type ReadWriterMetaFactory

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

ReadWriterMetaFactory generates Merkle LayerFactory functions. The functions it creates generate file read-writers starting from the base layer and up to minMemoryLayer-1. From minMemoryLayer and up the functions generate slice read-writers. The MetaFactory tracks the files it creates and removes them when Cleanup() is called.

func NewReadWriterMetaFactory

func NewReadWriterMetaFactory(minMemoryLayer uint, datadir string) *ReadWriterMetaFactory

NewReadWriterMetaFactory returns a new ReadWriterMetaFactory. minMemoryLayer determines the threshold in which lower layers caching is done on-disk, while from this layer up -- in-memory.

func (*ReadWriterMetaFactory) Cleanup

func (mf *ReadWriterMetaFactory) Cleanup() error

Cleanup removes the files that were created by the LayerFactory functions generated by this MetaFactory.

func (*ReadWriterMetaFactory) GetFactory

func (mf *ReadWriterMetaFactory) GetFactory() cache.LayerFactory

GetFactory creates a Merkle LayerFactory function.

Jump to

Keyboard shortcuts

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