Documentation ¶
Overview ¶
Package vrf implements the ECVRF-EDWARDS25519-SHA512-TAI VRF according to draft-irtf-cfrg-vrf-15.
Index ¶
- Constants
- Variables
- func GenerateKey(rand io.Reader) (PublicKey, PrivateKey, error)
- func NewKeyFromSeed(seed []byte) ed25519.PrivateKey
- func ProofToHash(piString []byte) ([]byte, error)
- func Verify(publicKey PublicKey, alpha []byte, piString []byte) (bool, []byte)
- type PrivateKey
- type Proof
- type PublicKey
Constants ¶
const ( // PublicKeySize is the size, in bytes, of public keys as used in this package. PublicKeySize = 32 // PrivateKeySize is the size, in bytes, of private keys as used in this package. PrivateKeySize = SeedSize + PublicKeySize // SeedSize is the size, in bytes, of private key seeds. These are the private key representations used by RFC 8032. SeedSize = 32 // ProofSize is the size, in bytes, of proofs. ProofSize = ptLen + cLen + qLen )
Variables ¶
var ErrNonCanonical = errors.New("non canonical point encoding")
Functions ¶
func GenerateKey ¶
func GenerateKey(rand io.Reader) (PublicKey, PrivateKey, error)
GenerateKey generates a public/private key pair using entropy from rand. If rand is nil, crypto/rand.Reader will be used. The key generation is 100% compatible with crypto/ed25519.
func NewKeyFromSeed ¶
func NewKeyFromSeed(seed []byte) ed25519.PrivateKey
NewKeyFromSeed calculates a private key from a seed. It will panic if len(seed) is not SeedSize.
func ProofToHash ¶
ProofToHash computes the VRF hash output corresponding to a VRF proof. ProofToHash should be run only on piString that is known to have been produced by Prove, or from within Verify.
Types ¶
type PrivateKey ¶
type PrivateKey = ed25519.PrivateKey
type Proof ¶
type Proof struct {
// contains filtered or unexported fields
}
Proof represents a VRF proof.
func Prove ¶
func Prove(privateKey PrivateKey, alpha []byte) *Proof
Prove computes the VRF proof for the input alpha.
func (*Proof) Hash ¶
Hash returns the VRF hash output corresponding to p. Hash should be run only on p that is known to have been produced by Prove, or from within Verify.
func (*Proof) MarshalBinary ¶
func (*Proof) SetBytes ¶
SetBytes sets p = x, where x is an 80-byte encoding of p. If x does not represent a valid proof, SetBytes returns nil and an error.