vrf

package
v0.0.0-...-d0adbf8 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2019 License: LGPL-3.0 Imports: 15 Imported by: 2

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