ecvrf

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2021 License: MIT Imports: 7 Imported by: 4

Documentation

Overview

Package ecvrf implements ECVRF-EDWARDS25519-SHA512-TAI, a verifiable random function described in draft-irtf-cfrg-vrf-10. This VRF uses the Edwards form of Curve25519, SHA512 and the try-and-increment hash-to-curve function. See: https://datatracker.ietf.org/doc/draft-irtf-cfrg-vrf/

Index

Constants

View Source
const (
	PublicKeySize  = pointSize
	PrivateKeySize = scalarSize + pointSize
	ProofSize      = pointSize + intermediateSize + scalarSize
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PrivateKey

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

PrivateKey contains the VRF private key, a standard ed25519 key and the precomputed secret scalar.

func GenerateKey

func GenerateKey(rnd io.Reader) (sk *PrivateKey, err error)

GenerateKey creates a public/private key pair using rnd for randomness. If rnd is nil, crypto/rand is used.

func NewPrivateKey

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

NewPrivateKey generates a PrivateKey object from a standard RFC8032 Ed25519 64-byte private key.

func (*PrivateKey) Bytes

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

Bytes serialises the private VRF key in a bytearray.

func (*PrivateKey) Prove

func (sk *PrivateKey) Prove(message []byte) (vrf, proof []byte, err error)

Prove returns a proof such that Verify(pk, message, vrf, proof) == true for a given message and public key pair sk/pk. This function is defined in section 5.1 of draft-irtf-cfrg-vrf-10.

func (*PrivateKey) Public

func (sk *PrivateKey) Public() (*PublicKey, error)

Public extracts the public VRF key from the underlying private-key.

type PublicKey

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

PublicKey contains the VRF public key, the canonical representation of a point on the ed25519 curve.

func NewPublicKey

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

NewPublicKey generates a PublicKey object from a standard RFC8032 Ed25519 32-byte public key.

func (*PublicKey) Bytes

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

Bytes serialises the private VRF key in a bytearray.

func (*PublicKey) Verify

func (pk *PublicKey) Verify(message, proof []byte) (verified bool, vrf []byte, err error)

Verify verifies that the given proof matches the message and the public key pk. When true it also returns the expected VRF string. This function is defined in section 5.3 of draft-irtf-cfrg-vrf-10.

Jump to

Keyboard shortcuts

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