secp256k1

package
v1.65.4 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: BSD-3-Clause Imports: 13 Imported by: 6

Documentation

Overview

Package secp256k1 implements a verifiable random function using curve secp256k1.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrInvalidVRF err
	ErrInvalidVRF = errors.New("invalid VRF proof")
)

Functions

func GenerateKey

func GenerateKey() (vrfp.PrivateKey, vrfp.PublicKey)

GenerateKey generates a fresh keypair for this VRF

func H1

func H1(m []byte) (x, y *big.Int)

H1 hashes m to a curve point

func H2

func H2(m []byte) *big.Int

H2 hashes to an integer [1,N-1]

func Unmarshal

func Unmarshal(curve elliptic.Curve, data []byte) (x, y *big.Int)

Unmarshal a compressed point in the form specified in section 4.3.6 of ANSI X9.62.

Types

type PrivateKey

type PrivateKey struct {
	*ecdsa.PrivateKey
}

PrivateKey holds a private VRF key.

func (PrivateKey) Evaluate

func (k PrivateKey) Evaluate(m []byte) (index [32]byte, proof []byte)

Evaluate returns the verifiable unpredictable function evaluated at m

func (PrivateKey) Public

func (k PrivateKey) Public() crypto.PublicKey

Public returns the corresponding public key as bytes.

type PublicKey

type PublicKey struct {
	*ecdsa.PublicKey
}

PublicKey holds a public VRF key.

func (*PublicKey) ProofToHash

func (pk *PublicKey) ProofToHash(m, proof []byte) (index [32]byte, err error)

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

Jump to

Keyboard shortcuts

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