vdf

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateVDF

func GenerateVDF(seed []byte, iterations, int_size_bits uint32) ([]byte, []byte)

func GenerateVDFIteration

func GenerateVDFIteration(seed, x_blob []byte, iterations, int_size_bits uint32) ([]byte, []byte)

func GenerateVDFWithStopChan

func GenerateVDFWithStopChan(seed []byte, iterations, int_size_bits uint32, stop <-chan struct{}) ([]byte, []byte)

func VerifyVDF

func VerifyVDF(seed, proof_blob []byte, iterations, int_size_bits uint32) bool

func VerifyVDFIteration

func VerifyVDFIteration(seed, x_blob, proof_blob []byte, iterations, int_size_bits uint32) bool

Types

type VDF

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

VDF is the struct holding necessary state for a hash chain delay function. Differs from harmony implementation in that difficulty is carried through as an unsigned int, because we can't travel backwards in time (yet ;) )

func New

func New(difficulty uint32, input [32]byte) *VDF

New create a new instance of VDF.

func (*VDF) Execute

func (vdf *VDF) Execute()

Execute runs the VDF until it's finished and put the result into output channel. currently on i7-6700K, it takes about 14 seconds when iteration is set to 10000

func (*VDF) ExecuteIteration

func (vdf *VDF) ExecuteIteration(x_blob []byte)

func (*VDF) GetOutput

func (vdf *VDF) GetOutput() [516]byte

GetOutput returns the vdf output, which can be bytes of 0s is the vdf is not finished.

func (*VDF) GetOutputChannel

func (vdf *VDF) GetOutputChannel() chan [516]byte

GetOutputChannel returns the vdf output channel. VDF output consists of 258 bytes of serialized Y and 258 bytes of serialized Proof

func (*VDF) IsFinished

func (vdf *VDF) IsFinished() bool

IsFinished returns whether the vdf execution is finished or not.

func (*VDF) Verify

func (vdf *VDF) Verify(proof [516]byte) bool

Verify runs the verification of generated proof currently on i7-6700K, verification takes about 350 ms

func (*VDF) VerifyIteration

func (vdf *VDF) VerifyIteration(x_blob [258]byte, proof [516]byte, iterations uint32) bool

Jump to

Keyboard shortcuts

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