vrf

package
v0.0.1-pre-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

NOTE: At the time of implementation, the VRF library is only used with consensus, but may be extracted into shared/crypto when/if it will be needed elsewhere.

Index

Constants

View Source
const (
	NilPrivateKeyError    = "private key cannot be nil"
	BadAppHashLengthError = "the last block hash must be at least %d bytes in length"
)
View Source
const (
	VRFOutputSize = sha512.Size // See github.com/ProtonMail/go-ecvrf for details
)

Variables

View Source
var (
	ErrNilPrivateKey = errors.New(NilPrivateKeyError)
)

Functions

func CreateVRFRandReader

func CreateVRFRandReader(lastBlockHash string, privKey crypto.PrivateKey) (io.Reader, error)

func ErrBadAppHashLength

func ErrBadAppHashLength(seedSize int) error

func GenerateVRFKeys

func GenerateVRFKeys(reader io.Reader) (*SecretKey, *VerificationKey, error)

Types

type SecretKey

type SecretKey ecvrf.PrivateKey

func (*SecretKey) Bytes

func (key *SecretKey) Bytes() []byte

func (*SecretKey) Prove

func (key *SecretKey) Prove(msg []byte) (vrf VRFOutput, proof VRFProof, err error)

func (*SecretKey) VerificationKey

func (key *SecretKey) VerificationKey() (*VerificationKey, error)

type VRFOutput

type VRFOutput []byte // Uniformally distributed output that can be normalized to be used in a binomial distribution.

type VRFProof

type VRFProof []byte // A proof to verify that VRFOutput belongs to a certain publicKey.

These are slices rather than arrays in order to more easily comply with the underlying `go-ecvrf/ecvrf` library.

type VerificationKey

type VerificationKey ecvrf.PublicKey

func VerificationKeyFromBytes

func VerificationKeyFromBytes(data []byte) (*VerificationKey, error)

func (*VerificationKey) Bytes

func (key *VerificationKey) Bytes() []byte

func (*VerificationKey) Verify

func (key *VerificationKey) Verify(msg []byte, vrfProof VRFProof, vrfOut VRFOutput) (verified bool, err error)

Jump to

Keyboard shortcuts

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