p256

package
Version: v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2020 License: Apache-2.0 Imports: 18 Imported by: 5

Documentation

Overview

Package p256 implements a verifiable random function using curve p256.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrPointNotOnCurve occurs when a public key is not on the curve.
	ErrPointNotOnCurve = errors.New("point is not on the P256 curve")
	// ErrWrongKeyType occurs when a key is not an ECDSA key.
	ErrWrongKeyType = errors.New("not an ECDSA key")
	// ErrNoPEMFound occurs when attempting to parse a non PEM data structure.
	ErrNoPEMFound = errors.New("no PEM block found")
	// ErrInvalidVRF occurs when the VRF does not validate.
	ErrInvalidVRF = errors.New("invalid VRF proof")
)

Functions

func GenerateKey

func GenerateKey() (vrf.PrivateKey, vrf.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 NewFromWrappedKey

func NewFromWrappedKey(ctx context.Context, wrapped proto.Message) (vrf.PrivateKey, error)

NewFromWrappedKey creates a VRF signer object from an encrypted private key. The opaque private key must resolve to an `ecdsa.PrivateKey` in order to work.

func NewVRFSigner

func NewVRFSigner(key *ecdsa.PrivateKey) (vrf.PrivateKey, error)

NewVRFSigner creates a signer object from a private key.

func NewVRFSignerFromPEM

func NewVRFSignerFromPEM(b []byte) (vrf.PrivateKey, error)

NewVRFSignerFromPEM creates a vrf private key from a PEM data structure.

func NewVRFSignerFromRawKey

func NewVRFSignerFromRawKey(b []byte) (vrf.PrivateKey, error)

NewVRFSignerFromRawKey returns the private key from a raw private key bytes.

func NewVRFVerifier

func NewVRFVerifier(pubkey *ecdsa.PublicKey) (vrf.PublicKey, error)

NewVRFVerifier creates a verifier object from a public key.

func NewVRFVerifierFromPEM

func NewVRFVerifierFromPEM(b []byte) (vrf.PublicKey, error)

NewVRFVerifierFromPEM creates a vrf public key from a PEM data structure.

func NewVRFVerifierFromRawKey

func NewVRFVerifierFromRawKey(b []byte) (vrf.PublicKey, error)

NewVRFVerifierFromRawKey returns the public key from a raw public key bytes.

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