Documentation ¶
Overview ¶
Package prover implements the core proving functionality of PoET implementation.
Index ¶
- Constants
- func CalcTreeRoot(leaves [][]byte) ([]byte, error)
- func GenerateProof(ctx context.Context, treeCfg TreeConfig, ...) (uint64, *shared.MerkleProof, error)
- func GenerateProofRecovery(ctx context.Context, treeCfg TreeConfig, ...) (uint64, *shared.MerkleProof, error)
- func GenerateProofWithoutPersistency(ctx context.Context, treeCfg TreeConfig, ...) (uint64, *shared.MerkleProof, error)
- type ReadWriterMetaFactory
- type TreeConfig
Constants ¶
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
Calculate the root of a Merkle Tree with given leaves.
func GenerateProof ¶
func GenerateProof( ctx context.Context, treeCfg TreeConfig, labelHashFunc func(data []byte) []byte, merkleHashFunc merkle.HashFunc, limit time.Time, securityParam uint8, 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, treeCfg TreeConfig, 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, treeCfg TreeConfig, labelHashFunc func(data []byte) []byte, merkleHashFunc merkle.HashFunc, limit time.Time, securityParam uint8, ) (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, fileWriterBufSize uint) *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.