Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ECVRF ¶
type ECVRF interface { Params() *ECVRFParams // Prove returns proof pi that beta is the correct hash output. // beta is deterministic in the sense that it always // produces the same output beta given a pair of inputs (sk, alpha). Prove(sk *PrivateKey, alpha []byte) (pi []byte) // ProofToHash allows anyone to deterministically obtain the VRF hash // output beta directly from the proof value pi. // // ProofToHash should be run only on pi that is known to have been produced by Prove // Clients attempting to verify untrusted inputs should use Verify. ProofToHash(pi []byte) (beta []byte, err error) // Verify that beta is the correct VRF hash of alpha using PublicKey pub. Verify(pub *PublicKey, pi, alpha []byte) (beta []byte, err error) }
func ECVRFP256SHA256SWU ¶
func ECVRFP256SHA256SWU() ECVRF
ECVRFP256SHA256SWU returns a elliptic curve based VRF instantiated with P256, SHA256, and the Simplified SWU strategy for hashing to the curve.
func ECVRFP256SHA256TAI ¶
func ECVRFP256SHA256TAI() ECVRF
ECVRFP256SHA256TAI returns a elliptic curve based VRF instantiated with P256, SHA256, and the "Try And Increment" strategy for hashing to the curve.
type ECVRFAux ¶
type ECVRFAux interface { // PointToString converts an EC point to an octet string. PointToString(Px, Py *big.Int) []byte // StringToPoint converts an octet string to an EC point. // This function MUST output INVALID if the octet string does not decode to an EC point. StringToPoint(h []byte) (Px, Py *big.Int, err error) // IntToString converts a nonnegative integer a to to octet string of length rLen. IntToString(x *big.Int, rLen uint) []byte // ArbitraryStringToPoint converts an arbitrary 32 byte string s to an EC point. ArbitraryStringToPoint(s []byte) (Px, Py *big.Int, err error) // HashToCurve is a collision resistant hash of VRF input alpha to H, an EC point in G. HashToCurve(Y *PublicKey, alpha []byte) (Hx, Hy *big.Int) // GenerateNonoce generates the nonce value k in a deterministic, pseudorandom fashion. GenerateNonce(sk *PrivateKey, h []byte) (k *big.Int) }
ECVRFAux contains auxiliary functions necesary for the computation of ECVRF.
type ECVRFParams ¶
type ECVRFParams struct {
// contains filtered or unexported fields
}
ECVRFParams holds shared values across ECVRF implementations. ECVRFParams also has generic algorithms that rely on ECVRFAux for specific sub algorithms.
func (ECVRFParams) ProofToHash ¶
func (p ECVRFParams) ProofToHash(pi []byte) (beta []byte, err error)
ProofToHash returns VRF hash output beta from VRF proof pi.
Input: pi - VRF proof, octet string of length ptLen+n+qLen Output: beta - VRF hash output, octet string of length hLen or "INVALID"
ProofToHash should be run only on pi that is known to have been produced by Prove, or from within Verify.
https://tools.ietf.org/html/draft-irtf-cfrg-vrf-06#section-5.2
func (ECVRFParams) Prove ¶
func (p ECVRFParams) Prove(sk *PrivateKey, alpha []byte) []byte
Prove returns proof pi that beta is the correct hash output. sk - VRF private key alpha - input alpha, an octet string Returns pi - VRF proof, octet string of length ptLen+n+qLen
func (ECVRFParams) Verify ¶
func (p ECVRFParams) Verify(pub *PublicKey, pi, alpha []byte) (beta []byte, err error)
Verify that beta is the correct VRF hash of alpha using PublicKey pub.
Input:
pub - public key, an EC point pi_string - VRF proof, octet string of length ptLen+n+qLen alpha_string - VRF input, octet string
Output:
beta, the VRF hash output, octet string of length hLen; or "INVALID"
type PrivateKey ¶
type PrivateKey struct { PublicKey // contains filtered or unexported fields }
PrivateKey holds a private VRF key.
func (*PrivateKey) Public ¶
func (priv *PrivateKey) Public() *PublicKey
Public returns the public key corresponding to priv.