Documentation
¶
Overview ¶
Package ecvrf is the Elliptic Curve Verifiable Random Function (VRF) library.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Secp256k1Sha256Tai is the pre-configured VRF object with secp256k1/SHA256 and hash_to_curve_try_and_increment algorithm. Secp256k1Sha256Tai = New(&Config{ Curve: secp256k1.S256(), SuiteString: 0xfe, Cofactor: 0x01, NewHasher: sha256.New, Decompress: func(c elliptic.Curve, pk []byte) (x, y *big.Int) { var fx, fy secp256k1.FieldVal format := pk[0] switch format { case secp256k1.PubKeyFormatCompressedEven, secp256k1.PubKeyFormatCompressedOdd: default: return } if overflow := fx.SetByteSlice(pk[1:33]); overflow { return } wantOddY := format == secp256k1.PubKeyFormatCompressedOdd if !secp256k1.DecompressY(&fx, wantOddY, &fy) { return } fy.Normalize() return new(big.Int).SetBytes(fx.Bytes()[:]), new(big.Int).SetBytes(fy.Bytes()[:]) }, }) // P256Sha256Tai is the pre-configured VRF object with P256/SHA256 and hash_to_curve_try_and_increment algorithm. P256Sha256Tai = New(&Config{ Curve: elliptic.P256(), SuiteString: 0x01, Cofactor: 0x01, NewHasher: sha256.New, Decompress: elliptic.UnmarshalCompressed, }) )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // the elliptic curve. Curve elliptic.Curve // a single nonzero octet specifying the ECVRF ciphersuite. SuiteString byte // number of points on curve divided by group order. Cofactor byte // create cryptographic hash function. NewHasher func() hash.Hash // decompress the compressed public key into x and y coordinate. Decompress func(c elliptic.Curve, pk []byte) (x, y *big.Int) }
Config contains VRF parameters.
type VRF ¶
type VRF interface { // Prove constructs a VRF proof `pi` for the given input `alpha`, // using the private key `sk`. The hash output is returned as `beta`. Prove(sk *ecdsa.PrivateKey, alpha []byte) (beta, pi []byte, err error) ProveSecp256k1(sk *ecdsa.PrivateKey, alpha []byte) (beta, pi []byte, err error) // Verify checks the proof `pi` of the message `alpha` against the given // public key `pk`. The hash output is returned as `beta`. Verify(pk *ecdsa.PublicKey, alpha, pi []byte) (beta []byte, err error) VerifySecp256k1(pk *ecdsa.PublicKey, alpha, pi []byte) (beta []byte, err error) }
VRF is the interface that wraps VRF methods.
Click to show internal directories.
Click to hide internal directories.