vrf

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: LGPL-3.0 Imports: 15 Imported by: 24 modules, 37 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Introduction

This package contains an implementation of EC-VRF scheme specified in the IRTF internet draft[1]. And we extends the github.com/google/keytransparency/core/crypto/vrf/p256 package to support elliptic curves of different bitsize such as NIST p224 curve, SM2 p256r1 curve, and so on.

References

[1]. Sharon Goldberg, Jan Vcelak, Dimitrios Papadopoulos, Leonid Reyzin. "Verifiable Random Functions (VRFs)", Internet Draft.

[2]. M. Melara et al. CONIKS: Bringing Key Transparency to End Users.

Documentation

Overview

This package is a wrapper of verifiable random function using curve secp256r1.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyNotSupported = errors.New("only support ECC key")
	ErrEvalVRF         = errors.New("failed to evaluate vrf")
)
View Source
var (
	ErrInvalidVRF  = errors.New("invalid VRF proof")
	ErrInvalidHash = errors.New("hash function does not match elliptic curve bitsize")
)

Functions

func Evaluate

func Evaluate(pri *ecdsa.PrivateKey, h hash.Hash, m []byte) (index [32]byte, proof []byte)

Evaluate returns the verifiable unpredictable(random) function evaluated at m

func ProofToHash

func ProofToHash(pk *ecdsa.PublicKey, h hash.Hash, m, proof []byte) (index [32]byte, err error)

ProofToHash asserts that proof is correct for m and outputs index.

func ValidatePrivateKey

func ValidatePrivateKey(pri keypair.PrivateKey) bool

* ValidatePrivateKey checks two conditions: * - the private key must be of type ec.PrivateKey * - the private key must use curve secp256r1

func ValidatePublicKey

func ValidatePublicKey(pub keypair.PublicKey) bool

* ValidatePublicKey checks two conditions: * - the public key must be of type ec.PublicKey * - the public key must use curve secp256r1

func Verify

func Verify(pub keypair.PublicKey, msg, vrf, nizk []byte) (bool, error)

Verify returns true if vrf and nizk is correct for msg

func Vrf

func Vrf(pri keypair.PrivateKey, msg []byte) (vrf, nizk []byte, err error)

Vrf returns the verifiable random function evaluated m and a NIZK proof

Types

This section is empty.

Jump to

Keyboard shortcuts

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