The core protocol of WoopChain
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
woop/crypto/vdf/vdf.go

25 lines
664 B

6 years ago
// Package vdf is a proof-of-concept implementation of a delay function
// and the security properties are not guaranteed.
// A more secure implementation of the VDF by Wesolowski (https://eprint.iacr.org/2018/623.pdf)
// will be done soon.
package vdf
import "golang.org/x/crypto/sha3"
6 years ago
// VDF is the struct holding necessary state for a hash chain delay function.
type VDF struct {
difficulty int
input [32]byte
output [32]byte
finished chan [32]byte
}
func (vdf *VDF) execute() {
tempResult := vdf.input
for i := 0; i < vdf.difficulty; i++ {
tempResult = sha3.Sum256(tempResult[:])
}
vdf.output = tempResult
vdf.finished <- vdf.output
}