vdf_go

package
v0.0.0-...-1199a4d Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDiscriminant

func CreateDiscriminant(seed []byte, length int) *big.Int

Return a discriminant of the given length using the given seed It is a random prime p between 13 - 2^2K return -p, where p % 8 == 7

func EncodeBigIntBigEndian

func EncodeBigIntBigEndian(a *big.Int) []byte

func EntropyFromSeed

func EntropyFromSeed(seed []byte, byte_count int) []byte

func GenerateVDF

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

seed := vdf.input[:]

func GenerateVDFWithStopChan

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

seed : input, more like x in paper

func SolveMod

func SolveMod(a, b, m *big.Int) (s, t *big.Int, solvable bool)

Solve ax == b mod m for x. Return s, t where x = s + k * t for integer k yields all solutions.

func VerifyVDF

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

Types

type ClassGroup

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

func CloneClassGroup

func CloneClassGroup(cg *ClassGroup) *ClassGroup

func IdentityForDiscriminant

func IdentityForDiscriminant(d *big.Int) *ClassGroup

func NewClassGroup

func NewClassGroup(a, b, c *big.Int) *ClassGroup

func NewClassGroupFromAbDiscriminant

func NewClassGroupFromAbDiscriminant(a, b, discriminant *big.Int) *ClassGroup

func NewClassGroupFromBytesDiscriminant

func NewClassGroupFromBytesDiscriminant(buf []byte, discriminant *big.Int) (*ClassGroup, bool)

func (*ClassGroup) BigPow

func (group *ClassGroup) BigPow(n *big.Int) *ClassGroup

func (*ClassGroup) Discriminant

func (group *ClassGroup) Discriminant() *big.Int

func (*ClassGroup) Equal

func (group *ClassGroup) Equal(other *ClassGroup) bool

func (*ClassGroup) Multiply

func (group *ClassGroup) Multiply(other *ClassGroup) *ClassGroup

func (*ClassGroup) Normalized

func (group *ClassGroup) Normalized() *ClassGroup

func (*ClassGroup) Pow

func (group *ClassGroup) Pow(n int64) *ClassGroup

func (*ClassGroup) Reduced

func (group *ClassGroup) Reduced() *ClassGroup

func (*ClassGroup) Serialize

func (group *ClassGroup) Serialize() []byte

Serialize encodes a, b based on discriminant's size using one more byte for sign if nessesary

func (*ClassGroup) Square

func (group *ClassGroup) Square() *ClassGroup

func (*ClassGroup) SquareUsingMultiply

func (group *ClassGroup) SquareUsingMultiply() *ClassGroup

type Pair

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

type VDF

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

VDF is the struct holding necessary state for a hash chain delay function.

func New

func New(difficulty int, 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) 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

Jump to

Keyboard shortcuts

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