vrf

package
v0.0.0-...-b10619e Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package vrf implements the ECVRF-EDWARDS25519-SHA512-TAI VRF according to draft-irtf-cfrg-vrf-15.

Index

Constants

View Source
const (
	// PublicKeySize is the size, in bytes, of public keys as used in this package.
	PublicKeySize = 32
	// PrivateKeySize is the size, in bytes, of private keys as used in this package.
	PrivateKeySize = SeedSize + PublicKeySize
	// SeedSize is the size, in bytes, of private key seeds. These are the private key representations used by RFC 8032.
	SeedSize = 32
	// ProofSize is the size, in bytes, of proofs.
	ProofSize = ptLen + cLen + qLen
)

Variables

View Source
var ErrNonCanonical = errors.New("non canonical point encoding")

Functions

func GenerateKey

func GenerateKey(rand io.Reader) (PublicKey, PrivateKey, error)

GenerateKey generates a public/private key pair using entropy from rand. If rand is nil, crypto/rand.Reader will be used. The key generation is 100% compatible with crypto/ed25519.

func NewKeyFromSeed

func NewKeyFromSeed(seed []byte) ed25519.PrivateKey

NewKeyFromSeed calculates a private key from a seed. It will panic if len(seed) is not SeedSize.

func ProofToHash

func ProofToHash(piString []byte) ([]byte, error)

ProofToHash computes the VRF hash output corresponding to a VRF proof. ProofToHash should be run only on piString that is known to have been produced by Prove, or from within Verify.

func Verify

func Verify(publicKey PublicKey, alpha []byte, piString []byte) (bool, []byte)

Verify reports whether piString is a valid proof of alpha by publicKey. If the proof is valid, Verify also returns the VRF hash output.

Types

type PrivateKey

type PrivateKey = ed25519.PrivateKey

type Proof

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

Proof represents a VRF proof.

func Prove

func Prove(privateKey PrivateKey, alpha []byte) *Proof

Prove computes the VRF proof for the input alpha.

func (*Proof) Bytes

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

Bytes returns the canonical 80-byte encoding of p.

func (*Proof) Hash

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

Hash returns the VRF hash output corresponding to p. Hash should be run only on p that is known to have been produced by Prove, or from within Verify.

func (*Proof) MarshalBinary

func (p *Proof) MarshalBinary() ([]byte, error)

func (*Proof) SetBytes

func (p *Proof) SetBytes(x []byte) (*Proof, error)

SetBytes sets p = x, where x is an 80-byte encoding of p. If x does not represent a valid proof, SetBytes returns nil and an error.

func (*Proof) UnmarshalBinary

func (p *Proof) UnmarshalBinary(data []byte) error

type PublicKey

type PublicKey = ed25519.PublicKey

Jump to

Keyboard shortcuts

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