vrf

package module
v0.0.0-...-55bdf52 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 4 Imported by: 3

Documentation

Overview

Package vrf implements the ECVRF-RISTRETTO255-SHA512 ciphersuite for RFC 9381 Verifiable Random Functions.

Index

Constants

This section is empty.

Variables

View Source
var ErrFailedVerification = errors.New("proof verification failed")

ErrFailedVerification indicates that proof verification failed.

Functions

This section is empty.

Types

type PrivateKey

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

PrivateKey can be used to compute a VRF hash of an input and a Proof that it is correct.

func GenerateKey

func GenerateKey() *PrivateKey

GenerateKey generates a new random PrivateKey.

func NewPrivateKey

func NewPrivateKey(sk []byte) (*PrivateKey, error)

NewPrivateKey returns a PrivateKey from its byte encoding.

func (*PrivateKey) Bytes

func (x *PrivateKey) Bytes() []byte

Bytes returns the byte encoding of x.

func (*PrivateKey) Prove

func (x *PrivateKey) Prove(alpha []byte) (pi *Proof)

Prove computes a VRF hash of the input alpha, and returns a proof that it was computed correctly.

The actual hash can be retrieved with Proof.Hash.

func (*PrivateKey) PublicKey

func (x *PrivateKey) PublicKey() *PublicKey

PublicKey returns the PublicKey for x.

type Proof

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

Proof is a proof that a VRF hash was computed correctly.

The actual hash can be computed from the proof with Proof.Hash.

func NewProof

func NewProof(pi []byte) (*Proof, error)

NewProof returns a Proof from its byte encoding.

func (*Proof) Bytes

func (p *Proof) Bytes() (pi []byte)

Bytes returns the byte encoding of p.

func (*Proof) Hash

func (p *Proof) Hash() (beta []byte)

Hash returns the actual VRF hash proven by p.

type PublicKey

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

PublicKey can be used to verify a Proof that the corresponding Proof.Hash is the correct VRF hash of an input.

func NewPublicKey

func NewPublicKey(pk []byte) (*PublicKey, error)

func (*PublicKey) Bytes

func (y *PublicKey) Bytes() []byte

Bytes returns the byte encoding of y.

func (*PublicKey) Verify

func (y *PublicKey) Verify(p *Proof, alpha []byte) (beta []byte, err error)

Verify verifies that p is a valid proof for the generation of its associated VRF hash of the input alpha.

Jump to

Keyboard shortcuts

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