Documentation ¶
Overview ¶
Package p256 implements a verifiable random function using curve p256.
Index ¶
- Variables
- func GenerateKey() (vrf.PrivateKey, vrf.PublicKey)
- func H1(m []byte) (x, y *big.Int)
- func H2(m []byte) *big.Int
- func NewVRFSigner(key *ecdsa.PrivateKey) (vrf.PrivateKey, error)
- func NewVRFSignerFromPEM(b []byte) (vrf.PrivateKey, error)
- func NewVRFSignerFromRawKey(b []byte) (vrf.PrivateKey, error)
- func NewVRFVerifier(pubkey *ecdsa.PublicKey) (vrf.PublicKey, error)
- func NewVRFVerifierFromPEM(b []byte) (vrf.PublicKey, error)
- func NewVRFVerifierFromRawKey(b []byte) (vrf.PublicKey, error)
- func Unmarshal(curve elliptic.Curve, data []byte) (x, y *big.Int)
- type PrivateKey
- type PublicKey
Constants ¶
This section is empty.
Variables ¶
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 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 ¶
NewVRFVerifier creates a verifier object from a public key.
func NewVRFVerifierFromPEM ¶
NewVRFVerifierFromPEM creates a vrf public key from a PEM data structure.
func NewVRFVerifierFromRawKey ¶
NewVRFVerifierFromRawKey returns the public key from a raw public key bytes.
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 ¶
PublicKey holds a public VRF key.
func (*PublicKey) Deserialize ¶
Deserialize de-serialize bytes into public key
func (*PublicKey) ProofToHash ¶
ProofToHash asserts that proof is correct for m and outputs index.