]>
Verifiable Random Functions (VRFs)
Boston University
111 Cummington Mall
Boston
MA
02215
USA
goldbe@cs.bu.edu
Boston University and Algorand
111 Cummington Mall
Boston
MA
02215
USA
reyzin@bu.edu
Hong Kong University of Science and Technology
Clearwater Bay
Hong Kong
dipapado@cse.ust.hk
NS1
16 Beaver St
New York
NY
10004
USA
jvcelak@ns1.com
CFRG
public key cryptography
hashing
authenticated denial
A Verifiable Random Function (VRF) is the publickey version of a
keyed cryptographic hash. Only the holder of the private key
can compute the hash, but anyone with public key
can verify the correctness of the hash.
VRFs are useful for preventing enumeration of hashbased data structures.
This document specifies several VRF constructions that are secure in
the cryptographic random oracle model. One VRF uses RSA and the other
VRF uses Elliptic Curves (EC).
Introduction
Rationale
A Verifiable Random Function
(VRF) is the publickey version of a
keyed cryptographic hash. Only the holder of the private VRF key
can compute the hash, but anyone with corresponding public key
can verify the correctness of the hash.
A key application of the VRF is to provide privacy against
offline enumeration (e.g. dictionary attacks) on data stored in a
hashbased data structure.
In this application, a Prover holds the VRF private key and uses the VRF hashing to
construct a hashbased data structure on the input data.
Due to the nature of the VRF, only the Prover can answer queries
about whether or not some data is stored in the data structure. Anyone who
knows the public VRF key can verify that the Prover has answered the queries
correctly. However, no offline inferences (i.e. inferences without querying
the Prover) can be made about the data stored in the data structure.
Requirements
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in
.
Terminology
The following terminology is used through this document:
 SK:

The private key for the VRF.
 PK:

The public key for the VRF.
 alpha or alpha_string:

The input to be hashed by the VRF.
 beta or beta_string:

The VRF hash output.
 pi or pi_string:

The VRF proof.
 Prover:

The Prover holds the private VRF key SK and public VRF key PK.
 Verifier:

The Verifier holds the public VRF key PK.
VRF Algorithms
A VRF comes with a key generation algorithm that generates a public VRF
key PK and private VRF key SK.
The prover hashes an input alpha using the private VRF key SK to obtain a VRF
hash output beta
 beta = VRF_hash(SK, alpha)
The VRF_hash algorithm is deterministic, in
the sense that it always produces the same output beta given the same
pair of inputs (SK, alpha).
The prover also uses the private key SK to construct a
proof pi that beta is the correct hash output
 pi = VRF_prove(SK, alpha)
The VRFs defined in this document allow anyone to deterministically
obtain the VRF hash output beta directly from the proof value pi by using
the function VRF_proof_to_hash:
 beta = VRF_proof_to_hash(pi)
Thus, for VRFs defined in this document, VRF_hash is defined as
 VRF_hash(SK, alpha) = VRF_proof_to_hash(VRF_prove(SK, alpha)),
and therefore this document will specify VRF_prove and VRF_proof_to_hash
rather than VRF_hash.
The proof pi allows a Verifier holding the public key PK
to verify that beta is the correct VRF hash of input alpha
under key PK. Thus, the VRF also comes with an algorithm
 VRF_verify(PK, alpha, pi)
that outputs (VALID, beta = VRF_proof_to_hash(pi)) if pi is valid,
and INVALID otherwise.
VRF Security Properties
VRFs are designed to ensure the following security properties.
Full Uniqueness or Trusted Uniqueness
Uniqueness means that, for any fixed public
VRF key and for any input alpha, there is a unique VRF
output beta that can be proved to be valid. Uniqueness must hold
even for an adversarial Prover that knows the VRF private key SK.
More precisely, "full uniqueness" states that a computationallybounded adversary cannot
choose
a VRF public key PK,
a VRF input alpha,
and two proofs pi1 and pi2 such that
VRF_verify(PK, alpha, pi1) outputs (VALID, beta1),
VRF_verify(PK, alpha, pi2) outputs (VALID, beta2),
and beta1 is not equal to beta2.
For many applications, a slightly weaker security
property called "trusted uniqueness" suffices.
Trusted uniqueness is the same as full uniqueness, but it is guaranteed to hold
only if the VRF keys PK and SK were generated in a trustworthy
manner.
As further discussed in ,
some VRFs specified in this document satisfy only trusted uniqueness, while others satisfy full uniqueness.
VRFs in this document that satisfy only trusted uniqueness but not full uniqueness MUST NOT be used if the key generation
process cannot be trusted.
Full Collison Resistance or Trusted Collision Resistance
Like any cryptographic hash function, VRFs need to be
collision resistant. Collison resistance must hold
even for an adversarial Prover that knows the VRF private key SK.
More precisely, "full collision resistance" states that
it should be computationally
infeasible for an adversary to find two distinct VRF
inputs alpha1 and alpha2 that have the same VRF hash beta,
even if that adversary knows the private VRF key SK.
For many applications, a slightly weaker security property
called "trusted collision resistance" suffices.
Trusted collision resistance is the same as collision resistance,
but it is guaranteed to hold only if the VRF keys PK and SK were generated in a trustworthy manner.
As further discussed in ,
some VRFs specified in this document satisfy only trusted collision resistance, while others satisfy full collision resistance.
VRFs in this document that satisfy only trusted collision resistance but not full collision resistance MUST NOT be used if the key generation
process cannot be trusted.
Full Pseudorandomness or Selective Pseudorandomness
Pseudorandomness ensures that when an adversarial Verifier sees
a VRF hash output beta without its corresponding VRF proof pi,
then beta is indistinguishable from a random value.
More precisely, suppose the public and private VRF keys (PK, SK) were generated
in a trustworthy manner.
Pseudorandomness ensures that the VRF hash output beta
(without its corresponding VRF proof pi) on
any adversariallychosen "target" VRF input alpha
looks indistinguishable from random
for any computationally bounded adversary who does not know the private
VRF key SK. This holds even if the adversary also gets to
choose other VRF inputs alpha' and observe their corresponding
VRF hash outputs beta' and proofs pi'.
With "full pseudorandomness", the adversary is allowed to choose the
"target" VRF input alpha at any time, even after it observes VRF outputs beta'
and proofs pi' on a variety of chosen inputs alpha'.
"Selective pseudorandomness" is a weaker security property
which suffices in many applications. Here, the adversary must choose
the target VRF input alpha independently of the public VRF key PK,
and before it observes VRF outputs beta'
and proofs pi' on inputs alpha' of its choice.
As further discussed in ,
VRFs specified in this document satisfy both full pseudorandomness and selective pseudorandomness,
but their quantitative security against the selective pseudorandomness attack is stronger.
It is important to remember that the VRF output beta does not
look random to the Prover, or to any other party that knows the private
VRF key SK! Such a party can easily distinguish beta from
a random value by comparing beta to the result of VRF_hash(SK, alpha).
Also, the VRF output beta does not look random to any party that
knows the valid VRF proof pi corresponding to the VRF input alpha, even
if this party does not know the private VRF key SK.
Such a party can easily distinguish beta from a random value by
checking whether VRF_verify(PK, alpha, pi) returns (VALID, beta).
Also, the VRF output beta may not look random if VRF key generation
was not done in a trustworthy fashion. (For example, if VRF keys were
generated with bad randomness.)
A randomoraclelike unpredictability property
As explained in , pseudorandomness is guaranteed only
if the VRF keys were generated in a trustworthy fashion.
For instance, if an adversary outputs VRF keys that are deterministically generated (or hardcoded and publicly known), then the outputs are easily derived by anyone and are therefore not pseudorandom.
There is, however, a different type of unpredictability that is desirable in certain VRF applications (such as and ). This property is similar
to the unpredictability achieved by an (ordinary, unkeyed)
cryptographic hash function: if the input has enough entropy (i.e., cannot be predicted), then the correct output is indistinguishable
from uniform.
A formal definition of this property appears in Section 3.2 of . The VRF schemes presented in this specification are believed to satisfy this property if the public key was generated in a trustworthy
manner. Additionally, the ECVRF is believed to also satisfy this property even if the public key was not generated in a trustworthy manner, as long as
the public key satisfies the key validation
procedure in .
RSA Full Domain Hash VRF (RSAFDHVRF)
The RSA Full Domain Hash VRF (RSAFDHVRF) is a VRF that satisfies
the "trusted uniqueness", "trusted
collision resistance", and "full pseudorandomness" properties defined in .
Its security follows from the
standard RSA assumption in the random oracle model. Formal
security proofs are in .
The VRF computes the proof pi as a deterministic RSA signature on
input alpha using the RSA Full Domain Hash Algorithm
parametrized with the selected hash algorithm.
RSA signature verification is used to verify the correctness of the
proof. The VRF hash output beta is simply obtained by hashing
the proof pi with the selected hash algorithm.
The key pair for RSAFDHVRF MUST be generated in a way that it satisfies
the conditions specified in Section 3 of .
In this section, the notation from is used.
Parameters used:
 (n, e)  RSA public key
 K  RSA private key
 k  length in octets of the RSA modulus n (k must be less than 2^32)
Fixed options:
 Hash  cryptographic hash function
 hLen  output length in octets of hash function Hash
Primitives used:

I2OSP  Conversion of a nonnegative integer to an octet string as defined in
Section 4.1 of
(given an integer and a length in octets, produces a bigendian representation of the integer, zeropadded to the desired length)

OS2IP  Conversion of an octet string to a nonnegative integer as defined in
Section 4.2 of
(given a bigendian encoding of an integer, produces the integer)

RSASP1  RSA signature primitive as defined in
Section 5.2.1 of (given a secret key and an input, raises the input to the secret RSA exponent modulo n)

RSAVP1  RSA verification primitive as defined in
Section 5.2.2 of (given a public key and an input, raises the input to the public RSA exponent modulo n)

MGF1  Mask Generation Function based on the hash function Hash as defined in
Section B.2.1 of

  octet string concatenation
RSAFDHVRF Proving
RSAFDHVRF_prove(K, alpha_string)
Input:
 K  RSA private key
 alpha_string  VRF hash input, an octet string
Output:
 pi_string  proof, an octet string of length k
Steps:
 one_string = 0x01
 EM = MGF1(one_string  I2OSP(k, 4)  I2OSP(n, k)  alpha_string, k  1)
 m = OS2IP(EM)
 s = RSASP1(K, m)
 pi_string = I2OSP(s, k)
 Output pi_string
RSAFDHVRF Proof to Hash
RSAFDHVRF_proof_to_hash(pi_string)
Input:
 pi_string  proof, an octet string of length k
Output:
 beta_string  VRF hash output, an octet string of length hLen
Important note:
 RSAFDHVRF_proof_to_hash should be run only on pi_string that is known to have been produced by RSAFDHVRF_prove, or from within RSAFDHVRF_verify as specified in .
Steps:
 two_string = 0x02
 beta_string = Hash(two_string  pi_string)
 Output beta_string
RSAFDHVRF Verifying
RSAFDHVRF_verify((n, e), alpha_string, pi_string)
Input:
 (n, e)  RSA public key
 alpha_string  VRF hash input, an octet string
 pi_string  proof to be verified, an octet string of length n
Output:

("VALID", beta_string), where beta_string is the VRF hash output, an octet string of length hLen; or
"INVALID"
Steps:
 s = OS2IP(pi_string)
 m = RSAVP1((n, e), s)
 EM = I2OSP(m, k  1)
 one_string = 0x01
 EM' = MGF1(one_string  I2OSP(k, 4)  I2OSP(n, k)  alpha_string, k  1)

If EM and EM' are equal, output ("VALID", RSAFDHVRF_proof_to_hash(pi_string));
else output "INVALID".
Elliptic Curve VRF (ECVRF)
The Elliptic Curve Verifiable Random Function (ECVRF) is a VRF that
satisfies the trusted uniqueness, trusted collision resistance,
and full pseudorandomness properties defined in .
The security of this VRF follows from the decisional
DiffieHellman (DDH) assumption in the random oracle model. Formal security proofs are
in .
To additionally satisfy "full uniqueness" and "full collision resistance",
the Verifier MUST additionally perform the validation procedure specified in
upon receipt of the public
VRF key.
Notation used:
 Elliptic curve operations are written in additive notation, with P+Q denoting point addition and x*P denoting scalar multiplication of a point P by a scalar x
 x^y  x raised to the power y
 x*y  x multiplied by y
 s  t  concatenation of octet strings s and t
 0xMN (where M and N are hexadecimal digits)  a single octet with value M*16+N; equivalently, int_to_string(M*16+N, 1), where int_to_string is as defined below.
Fixed options (specified in ):
 F  finite field
 2n  length, in octets, of a field element in F, rounded up to the nearest even integer
 E  elliptic curve (EC) defined over F
 ptLen  length, in octets, of an EC point encoded as an octet string
 G  subgroup of E of large prime order
 q  prime order of group G
 qLen  length of q in octets, i.e., smallest integer such that 2^(8qLen)>q (note that in the typical case, qLen equals 2n or is close to 2n)
 cofactor  number of points on E divided by q
 B  generator of group G
 Hash  cryptographic hash function
 hLen  output length in octets of Hash; must be at least 2n
 ECVRF_hash_to_curve  a function that hashes strings to an EC point.
 ECVRF_nonce_generation  a function that derives a pseudorandom nonce
from SK and the input as part of ECVRF proving.
 suite_string  a single nonzero octet specifying the ECVRF
ciphersuite, which determines the above options as well as type conversions and parameter generation
Type conversions (specified in ):
 int_to_string(a, len)  conversion of nonnegative integer a
to octet string of length len
 string_to_int(a_string)  conversion of an octet string a_string
to a nonnegative integer
 point_to_string  conversion of EC point to an ptLenoctet string
 string_to_point  conversion of an ptLenoctet string to EC point.
string_to_point returns INVALID if the octet string does not convert to a valid EC point.

Note that with certain software libraries
(for big integer and elliptic curve arithmetic),
the int_to_string and point_to_string conversions are not needed, when
the libraries encode integers and EC points in the same way as required
by the ciphersuites.
For example, in some implementations, EC point
operations will take octet strings as inputs and
produce octet strings as outputs, without introducing
a separate elliptic curve point type.
Parameters used (the generation of these parameters is specified in ):
 SK  VRF private key

x  VRF secret scalar, an integer

Note: depending on the ciphersuite used, the VRF secret scalar may be equal
to SK; else, it is derived from SK
 Y = x*B  VRF public key, an EC point
ECVRF Proving
ECVRF_prove(SK, alpha_string)
Input:
 SK  VRF private key
 alpha_string = input alpha, an octet string
Output:
 pi_string  VRF proof, octet string of length ptLen+n+qLen
Steps:

Use SK to derive the VRF secret scalar x and the VRF public key Y = x*B
(this derivation depends on the ciphersuite, as per ;
these values can be cached, for example, after key generation, and need not be rederived each time)
 H = ECVRF_hash_to_curve(Y, alpha_string)
 h_string = point_to_string(H)
 Gamma = x*H
 k = ECVRF_nonce_generation(SK, h_string)
 c = ECVRF_hash_points(H, Gamma, k*B, k*H) (see )
 s = (k + c*x) mod q
 pi_string = point_to_string(Gamma)  int_to_string(c, n)  int_to_string(s, qLen)
 Output pi_string
ECVRF Proof to Hash
ECVRF_proof_to_hash(pi_string)
Input:
 pi_string  VRF proof, octet string of length ptLen+n+qLen
Output:
 "INVALID", or
 beta_string  VRF hash output, octet string of length hLen
Important note:
 ECVRF_proof_to_hash should be run only on pi_string that is known to have been produced by ECVRF_prove, or
from within ECVRF_verify as specified in .
Steps:
 D = ECVRF_decode_proof(pi_string) (see )
 If D is "INVALID", output "INVALID" and stop
 (Gamma, c, s) = D
 three_string = 0x03
 zero_string = 0x00
 beta_string = Hash(suite_string  three_string  point_to_string(cofactor * Gamma)  zero_string)
 Output beta_string
ECVRF Verifying
ECVRF_verify(Y, pi_string, alpha_string)
Input:
 Y  public key, an EC point
 pi_string  VRF proof, octet string of length ptLen+n+qLen
 alpha_string  VRF input, octet string
Output:

("VALID", beta_string), where beta_string is the VRF hash output, octet string of length hLen; or
"INVALID"
Steps:
 D = ECVRF_decode_proof(pi_string) (see )
 If D is "INVALID", output "INVALID" and stop
 (Gamma, c, s) = D
 H = ECVRF_hash_to_curve(Y, alpha_string)
 U = s*B  c*Y
 V = s*H  c*Gamma
 c' = ECVRF_hash_points(H, Gamma, U, V) (see )

If c and c' are equal, output ("VALID", ECVRF_proof_to_hash(pi_string));
else output "INVALID"
ECVRF Auxiliary Functions
ECVRF Hash to Curve
The ECVRF_hash_to_curve algorithm takes in the VRF input alpha
and converts it to H, an EC point in G.
This algorithm is the only place the VRF input alpha is used
for proving and verifying. See
for further discussion.
This section specifies a number of such algorithms, which are not compatible with each other. The choice of a particular algorithm from the options specified in this section is made in .
ECVRF_hash_to_curve_try_and_increment
The following ECVRF_hash_to_curve_try_and_increment(Y, alpha_string) algorithm
implements ECVRF_hash_to_curve in a simple and
generic way that works for any elliptic curve.
The running time of this algorithm depends on alpha_string.
For the ciphersuites specified
in , this algorithm
is expected to find a valid curve point after approximately two attempts
(i.e., when ctr=1) on average.
However, because the running time of algorithm depends on alpha_string,
this algorithm SHOULD be avoided in
applications where it is important that
the VRF input alpha remain secret.
ECVRF_hash_to_try_and_increment(Y, alpha_string)
Input:
 Y  public key, an EC point
 alpha_string  value to be hashed, an octet string
Output:
 H  hashed value, a finite EC point in G
Fixed option (specified in ):
 arbitrary_string_to_point  conversion of an arbitrary octet string to an
EC point.
Steps:
 ctr = 0
 PK_string = point_to_string(Y)
 one_string = 0x01
 zero_string = 0x00
 H = "INVALID"

While H is "INVALID" or H is the identity element of the elliptic curve group:
 ctr_string = int_to_string(ctr, 1)
 hash_string = Hash(suite_string  one_string  PK_string  alpha_string  ctr_string  zero_string)
 H = arbitrary_string_to_point(hash_string)
 If H is not "INVALID" and cofactor > 1, set H = cofactor * H
 ctr = ctr + 1
 Output H
ECVRF_hash_to_curve_h2c_suite
The ECVRF_hash_to_curve_h2c_suite(Y, alpha_string) algorithm
implements ECVRF_hash_to_curve using one of the several
hashtocurve options defined in
.
The specific choice of the hashtocurve option
(called Suite ID in )
is given by the h2c_suite_ID_string parameter.
ECVRF_hash_to_curve_h2c_suite(Y, alpha_string)
Input:
 alpha_string  value to be hashed, an octet string
 Y  public key, an EC point
Output:
 H  hashed value, a finite EC point in G
Fixed option (specified in ):
 h2c_suite_ID_string  a hashtocurve suite ID, encoded in ASCII (see discussion below)
Steps
 PK_string = point_to_string(Y)
 string_to_hash = PK_string  alpha_string

H = encode(string_to_hash)
(the encode function is discussed below)
 Output H
The encode function is provided by the hashtocurve suite whose ID is h2c_suite_ID_string, as specified in
, Section 8.
The domain separation tag DST, a parameter to the hashtocurve suite, SHALL be set to

"ECVRF_"  h2c_suite_ID_string  suite_string
where "ECVRF_" is represented as a 6byte ASCII encoding (in hexadecimal, octets 45 43 56 52 46 5F).
ECVRF Nonce Generation
The following algorithms generate the
nonce value k in a deterministic pseudorandom fashion.
This section specifies a number of such algorithms, which are not compatible with each other.
The choice of a particular algorithm from the options specified in this section is made in Section 5.5.
ECVRF Nonce Generation from RFC 6979
ECVRF_nonce_generation_RFC6979(SK, h_string)
Input:
 SK  an ECVRF secret key
 h_string  an octet string
Output:
 k  an integer between 1 and q1
The ECVRF_nonce_generation function is as specified in
Section 3.2 where
 Input m is set equal to h_string
 The "suitable for DSA or ECDSA" check in step h.3 is omitted
 The hash function H is Hash and its output length hlen is set as hLen*8
 The secret key x is set equal to the VRF secret scalar x
 The prime q is the same as in this specification
 qlen is the binary length of q, i.e., the smallest integer such that 2^qlen > q
 All the other values and primitives as defined in
ECVRF Nonce Generation from RFC 8032
The following is from Steps 23 of Section 5.1.6
in .
ECVRF_nonce_generation_RFC8032(SK, h_string)
Input:
 SK  an ECVRF secret key
 h_string  an octet string
Output:
 k  an integer between 0 and q1
Steps:
 hashed_sk_string = Hash(SK)
 truncated_hashed_sk_string = hashed_sk_string[32]...hashed_sk_string[63]
 k_string = Hash(truncated_hashed_sk_string  h_string)
 k = string_to_int(k_string) mod q
ECVRF Hash Points
ECVRF_hash_points(P1, P2, ..., PM)
Input:
Output:
 c  hash value, integer between 0 and 2^(8n)1
Steps:
 two_string = 0x02
 Initialize str = suite_string  two_string

for PJ in [P1, P2, ... PM]:
str = str  point_to_string(PJ)
 zero_string = 0x00
 str = str  zero_string
 c_string = Hash(str)
 truncated_c_string = c_string[0]...c_string[n1]
 c = string_to_int(truncated_c_string)
 Output c
ECVRF Decode Proof
ECVRF_decode_proof(pi_string)
Input:
 pi_string  VRF proof, octet string (ptLen+n+qLen octets)
Output:
 "INVALID", or
 Gamma  EC point

c  integer between 0 and 2^(8n)1

s  integer between 0 and q1
Steps:
 gamma_string = pi_string[0]...pi_string[ptLen1]
 c_string = pi_string[ptLen]...pi_string[ptLen+n1]
 s_string = pi_string[ptLen+n]...pi_string[ptLen+n+qLen1]
 Gamma = string_to_point(gamma_string)
 if Gamma = "INVALID" output "INVALID" and stop
 c = string_to_int(c_string)
 s = string_to_int(s_string)
 if s >= q output "INVALID" and stop
 Output Gamma, c, and s
ECVRF Ciphersuites
This document defines ECVRFP256SHA256TAI as follows:

suite_string = 0x01

The EC group G is the NIST P256 elliptic curve, with curve parameters
as specified in (Section D.1.2.3)
and (Section 2.6). For this group,
2n = qLen = 32 and cofactor = 1.
 The key pair generation primitive is specified in
Section 3.2.1 of (q, B, SK, and Y in this document
correspond to n, G, d, and Q in Section 3.2.1 of ).
In this ciphersuite, the secret scalar x is equal to the private key SK.
 The ECVRF_nonce_generation function is as specified in .
 The int_to_string function is the I2OSP function specified in Section
4.1 of . (This is bigendian representation.)
 The string_to_int function is the OS2IP function specified in Section
4.2 of . (This is bigendian representation.)

The point_to_string function converts an EC point to an octet string
according to the encoding specified in Section 2.3.3 of
with point compression on.
This implies ptLen = 2n + 1 = 33.
(Note that certain software implementations do not introduce a
separate elliptic curve point type and instead directly treat the
EC point as an octet string per above encoding. When using such
an implementation, the point_to_string function
can be treated as the identity function.)
 The string_to_point function converts an octet string to an
EC point according to the encoding specified in Section 2.3.4 of
. This function MUST output INVALID if
the octet string does not decode to an EC point.

The hash function Hash is SHA256 as specified in , with hLen = 32.

The ECVRF_hash_to_curve function is as specified in , with arbitrary_string_to_point(s) = string_to_point(0x02  s). The input s to arbitrary_string_to_point is a 32octet string
and the output is either an EC point or "INVALID".
This document defines ECVRFP256SHA256SSWU as identical to ECVRFP256SHA256TAI, except that:
 suite_string = 0x02
 the ECVRF_hash_to_curve function is as specified in
with h2c_suite_ID_string = P256_XMD:SHA256_SSWU_NU_
(the suite is defined in Section 8.2)
This document defines ECVRFEDWARDS25519SHA512TAI as follows:

suite_string = 0x03.

The EC group G is the edwards25519
elliptic curve with parameters defined in Table 1 of
.
For this group, 2n = qLen = 32 and cofactor = 8.
 The private key and generation of the secret scalar and the public
key are specified in Section 5.1.5 of .
 The ECVRF_nonce_generation function is as specified in .
 The int_to_string function as specified in the first paragraph of
Section 5.1.2 of . (This is littleendian representation.)
 The string_to_int function interprets the string as an integer in littleendian
representation.
 The point_to_string function converts an EC point to an
octet string according to the encoding specified
in Section 5.1.2 of .
This implies ptLen = 2n = 32.
(Note that certain software implementations do not introduce a
separate elliptic curve point type and instead directly treat the
EC point as an octet string per above encoding. When using such
and implementation, the point_to_string
function can be treated as the identity function.)
 The string_to_point function converts an octet string to an EC point
according to the encoding specified in Section 5.1.3
of . This function MUST output INVALID if
the octet string does not decode to an EC point.

The hash function Hash is SHA512 as specified in , with hLen = 64.

The ECVRF_hash_to_curve function is as specified in , with arbitrary_string_to_point(s) = string_to_point(s[0]...s[31]).
This document defines ECVRFEDWARDS25519SHA512ELL2 as identical to ECVRFEDWARDS25519SHA512TAI, except:

suite_string = 0x04;
 the ECVRF_hash_to_curve function is as specified in with
h2c_suite_ID_string = edwards25519_XMD:SHA512_ELL2_NU_
(the suite is defined in
Section 8.5).
When the ECVRF Keys are Untrusted
The ECVRF as specified above is a VRF that satisfies the
"trusted uniqueness", "trusted collision resistance", and
"full pseudorandomness" properties defined in .
In order to obtain "full uniqueness" and "full collision resistance" (which provide
protection against a malicious VRF public key), the Verifier MUST
perform
the following additional validation procedure upon receipt of the public
VRF key. The public VRF key MUST NOT be used if this procedure returns "INVALID".
Note that this procedure is not sufficient if the elliptic curve E
or the point B, the generator of group G, is untrusted. If the prover is untrusted,
the Verifier MUST
obtain E and B from a trusted source, such as a ciphersuite specification, rather
than from the prover.
Ciphersuites in this document specify E and B.
This procedure supposes that the public key provided to the Verifier is an octet
string. The procedure returns "INVALID" if the public key in invalid.
Otherwise, it returns Y, the public key as an EC point.
ECVRF Validate Key
ECVRF_validate_key(PK_string)
Input:
 PK_string  public key, an octet string
Output:
 "INVALID", or
 Y  public key, an EC point
Steps:
 Y = string_to_point(PK_string)
 If Y is "INVALID", output "INVALID" and stop
 If cofactor*Y is the identity element of the elliptic curve group, output "INVALID" and stop
 Output Y
Note that if the cofactor = 1, then Step 3 need not multiply Y by the cofactor; instead, it suffices
to output "INVALID" if Y is the identity element of the elliptic curve group. Moreover, when cofactor>1, it is not necessary to verify
that Y is in the subgroup G; Step 3 suffices. Therefore, if the cofactor is small, the total number
of points that could cause Step 3 to output "INVALID" may be small, and it may be more efficient to simply
check Y against a fixed list of such points. For example, the following algorithm can be used for the edwards25519 curve:
 Y = string_to_point(PK_string)
 If Y is "INVALID", output "INVALID" and stop
 y_string = PK_string
 oneTwentySeven_string = 0x7F

y_string[31] = y_string[31] & oneTwentySeven_string
(this step clears the highorder bit of octet 31)
 bad_pk[0] = int_to_string(0, 32)
 bad_pk[1] = int_to_string(1, 32)
 bad_y2 = 2707385501144840649318225287225658788936804267575313519463743609750303402022
 bad_pk[2] = int_to_string(bad_y2, 32)
 bad_pk[3] = int_to_string(pbad_y2, 32)
 bad_pk[4] = int_to_string(p1, 32)
 bad_pk[5] = int_to_string(p, 32)
 bad_pk[6] = int_to_string(p+1, 32)
 If y_string is in bad_pk[0]...bad_pk[6], output "INVALID" and stop
 Output Y
(bad_pk[0], bad_pk[2], bad_pk[3] each match two bad public keys, depending on the sign of the xcoordinate, which was cleared in step 5, in order to make sure that it does not affect the comparison. bad_pk[1] and bad_pk[4] each match one bad public key, because xcoordinate is 0 for these two public keys. bad_pk[5] and bad_pk[6] are simply bad_pk[0] and bad_pk[1] shifted by p, in case the ycoordinate had not been modular reduced by p. There is no need to shift the other bad_pk values by p, because they will exceed 2^255. These bad keys, which represent all points of order 1, 2, 4, and 8, have been obtained by converting the points specified in to Edwards coordinates.)
Implementation Status
Note to RFC editor: Remove before publication
A reference C++ implementation of ECVRFP256SHA256TAI, ECVRFP256SHA256SSWU, ECVRFEDWARDS25519SHA512TAI, and ECVRFEDWARDS25519SHA512ELL2
is available at . This implementation is neither secure nor especially efficient, but can be used to generate
test vectors.
A Python implementation of an older version of ECVRFEDWARDS25519SHA512ELL2 from the 05 version of this draft is available at .
A C implementation of an older version of ECVRFEDWARDS25519SHA512ELL2 from the 03 version of this draft is available at .
A Rust implementation of an older version of ECVRFP256SHA256TAI from the 05 version of this draft, as well as variants for the sect163k1 and secp256k1 curves, is available at .
A C implementation of a variant of ECVRFP256SHA256TAI from the 05 version of this draft adapted for the secp256k1 curve is available at .
An implementation of an earlier version of RSAFDHVRF (SHA256) and ECVRFP256SHA256TAI was
first developed
as a part of the NSEC5 project and is available
at .
The Key Transparency project at Google
uses a VRF implementation that is similar to
the ECVRFP256SHA256TAI, with a few changes
including the use of SHA512 instead of SHA256. Its implementation
is available at
An implementation by Ryuji Ishiguro following an older version of ECVRFEDWARDS25519SHA512TAI from the 00 version of this draft is available at
.
An implementation similar to ECVRFEDWARDS25519SHA512ELL2 (with some changes, including the use of SHA3) is available as part of the
CONIKS implementation in Golang at
.
Open Whisper Systems also uses a VRF similar to
ECVRFEDWARDS25519SHA512ELL2, called VXEdDSA, and specified here
and here .
Implementations in C and Java are available at and
.
Security Considerations
Key Generation
Applications that use the VRFs defined in this
document MUST ensure that the VRF key is generated correctly,
using good randomness.
Uniqueness and collision resistance with untrusted keys
The ECVRF as specified in 
satisfies the "trusted uniqueness" (see )
and "trusted collision resistance" (see ) properties
as long as the VRF keys are generated correctly, with good randomness.
If the Verifier trusts the VRF keys are generated correctly, it MAY use
the public key Y as is.
However, if the ECVRF uses keys that could be generated adversarially, then the
Verifier MUST first perform the validation procedure ECVRF_validate_key(PK_string)
(specified in ) upon receipt of the
public key as an octet string. If the validation procedure
outputs "INVALID", then the public key MUST not be used.
Otherwise, the procedure will output a valid public key Y,
and the ECVRF with public key Y satisfies the "full uniqueness" and
"full collision resistance" properties.
The RSAFDHVRF satisfies the "trusted uniqueness" and "trusted collision resistance" properties
as long as the VRF keys are generated correctly, with good randomness.
These properties may not hold if the keys are generated adversarially
(e.g., if the RSA function specified in the public key is not bijective). Meanwhile,
the "full uniqueness" and "full collision resistance" are
properties that hold even if VRF keys are generated by an adversary.
The RSAFDHVRF defined in this document does not have these properties.
However, if adversarial key generation is a concern, the
RSAFDHVRF may be modified to have these
properties by adding additional cryptographic checks
that its public key has the right form. These modifications are left for future specification.
Pseudorandomness with untrusted keys
Without good randomness, the "pseudorandomness"
properties of the VRF may not hold. Note that it is not possible to guarantee
pseudorandomness in the face of adversarially generated VRF keys. This is
because an adversary can always use bad randomness to generate the VRF keys,
and thus, the VRF output may not be pseudorandom.
Selective vs. Full Pseudorandomness
presents cryptographic reductions to an
underlying hard problem (e.g. Decisional DiffieHellman for the ECVRF, or the
standard RSA assumption for RSAFDHVRF) that prove the VRFs specified in this
document possess full pseudorandomness
as well as selective pseudorandomness
(see for an explanation of these notions).
However, the cryptographic reductions are tighter for selective
pseudorandomness than for full pseudorandomness. This means that
the VRFs have quantitively stronger security
guarantees for selective pseudorandomness.
Applications that are concerned about tightness of cryptographic
reductions therefore have two options.
 They may choose to ensure that selective pseudorandomness is sufficient for
the application. That is, that
pseudorandomness of outputs matters only for inputs that are chosen
independently of the VRF key.
 If full pseudorandomness is required for the application, the application
may increase
security parameters to make up for the loose security reduction.
For RSAFDHVRF, this means increasing the RSA key length. For
ECVRF, this means increasing the cryptographic strength of the EC group
G. For both RSAFDHVRF and ECVRF, the cryptographic strength of the
hash function Hash may also potentially need to be increased.
Proper pseudorandom nonce for ECVRF
The security of the ECVRF defined in this document relies on the
fact that the nonce k used in the ECVRF_prove algorithm is
chosen uniformly and pseudorandomly modulo q, and is unknown to the adversary.
Otherwise, an adversary may be able to recover
the private VRF key x (and thus break pseudorandomness of the VRF)
after observing several valid VRF proofs pi. The nonce generation methods
specified in the ECVRF ciphersuites of
are designed with this requirement in mind.
Sidechannel attacks
Side channel attacks on cryptographic primitives are an important issue.
Implementers should
take care to avoid sidechannel attacks that leak information about
the VRF private key SK (and the nonce k used in the ECVRF), which is
used in VRF_prove.
In most applications, VRF_proof_to_hash and VRF_verify
algorithms take only inputs that are public, and thus side channel
attacks are typically not a concern for these algorithms.
The VRF input alpha may be also a sensitive input to VRF_prove and may
need to be protected against side channel attacks.
Below we discuss one particular class of such attacks: timing attacks that can
be used to leak information about the VRF input alpha.
The ECVRF_hash_to_curve_try_and_increment algorithm defined in
SHOULD NOT be used in applications where
the VRF input alpha is secret and is hashed by the VRF onthefly.
This is because the algorithm's running time depends
on the VRF input alpha, and thus creates a timing channel that
can be used to learn information about alpha.
That said, for most inputs the amount of information obtained from
such a timing attack is likely to be small (1 bit, on average), since the algorithm
is expected to find a valid curve point after only two attempts.
However, there might be inputs which cause the algorithm to make many attempts
before it finds a valid curve point; for such inputs, the information leaked
in a timing attack will be more than 1 bit.
ECVRFP256SHA256SSWU and ECVRFEDWARDS25519SHA512ELL2 can be made to
run in time independent of alpha, following recommendations in .
Proofs provide no secrecy for the VRF input
The VRF proof pi is not designed to provide secrecy and, in general,
may reveal the VRF input alpha.
Anyone who knows PK and pi is able to perform an offline
dictionary attack to search for alpha, by verifying guesses for alpha using VRF_verify.
This is in contrast to the VRF hash output beta which, without the proof, is pseudorandom
and thus is designed to reveal no information about alpha.
Prehashing
The VRFs specified in this document allow for readonce access to
the input alpha for both signing and verifying. Thus, additional
prehashing of alpha (as specified, for example, in
for EdDSA signatures) is not needed,
even for applications that need to handle long alpha or
to support the
InitializedUpdateFinalize (IUF) interface (in such an interface,
alpha is not supplied
all at once, but rather in pieces by a sequence of calls to Update).
The ECVRF, in particular, uses alpha only in
ECVRF_hash_to_curve. The curve point H becomes the representative
of alpha thereafter. Note that the suite_string octet and the public key
are hashed together with alpha in ECVRF_hash_to_curve, which ensures
that the curve (including the generator B) and the public
key are included indirectly into subsequent hashes.
Hash function domain separation and futureproofing
Hashing is used for different purposes in the two VRFs (namely, in the RSAFDHVRF, in MGF1 and in proof_to_hash; in the ECVRF, in hash_to_curve, nonce_generation, hash_points, and proof_to_hash). The
theoretical analysis assumes each of these functions is a separate random oracle.
This analysis still holds even if the same hash function is used, as long as the four
queries made to the hash function for a given SK and alpha are overwhelmingly unlikely
to equal each other or to any queries made to the hash function for the same SK and
different alpha. This is indeed the case for the RSAFDHVRF defined in this document, because the first octets
of the input to the hash function used in MGF1 and in proof_to_hash are different.
This is also the case for the ECVRF ciphersuites defined in this document, because:
 inputs to the hash function used during nonce_generation are unlikely to equal
inputs used in hash_to_curve, proof_to_hash, and hash_points. This
follows since nonce_generation inputs a secret to the hash function that is not used by
honest parties as input to any other hash function, and is not available to the adversary.
 the second octets of the inputs to the hash function used in
proof_to_hash, hash_points, and ECVRF_hash_to_curve_try_and_increment
are all different.
 the last octet of the input to the hash function used in
proof_to_hash, hash_points, and ECVRF_hash_to_curve_try_and_increment is always zero,
and therefore different from the last octet of the input to the hash function used in ECVRF_hash_to_curve_h2c_suite,
which is set equal to the nonzero length of the domain separation tag by .
For the RSA VRF, if future designs need to specify variants of the design in this document, such variants should use different first octets in inputs to MGF1 and to the hash function used in proof_to_hash, in order to avoid the possibility
that an adversary can obtain a VRF output under one variant, and then claim it was obtained under
another variant
For the elliptic curve VRF, if future designs need to specify variants (e.g., additional ciphersuites) of the design in this document,
then, to avoid the possibility
that an adversary can obtain a VRF output under one variant, and then claim it was obtained under
another variant,
they should specify a different suite_string constant. This way, the inputs
to the hash_to_curve hash function used in producing H are
guaranteed to be different; since all the other hashing done by the prover
depends on H, inputs all the hash functions used by the prover will also be
different as long as hash_to_curve is collision resistant.
Change Log
Note to RFC Editor: if this document does not obsolete an existing RFC,
please remove this appendix before publication as an RFC.
 00  Forked this document from draftgoldbevrf01.
 01  Minor updates, mostly highlighting TODO items.
 02  Added specification of elligator2 for Curve25519, along
with ciphersuites for ECVRFED25519SHA512Elligator.
Changed
ECVRFED25519SHA256 suite_string to ECVRFED25519SHA512. (This change
made because Ed25519 in signatures
use SHA512 and not SHA256.)
Made ECVRF nonce generation a separate component, so that nonces are deterministic.
In ECVRF proving, changed + to  (and made corresponding
verification changes) in order to be consistent with EdDSA and ECDSA.
Highlighted that ECVRF_hash_to_curve acts like a prehash.
Added "suites" variable to ECVRF for futureproofing.
Ensured domain separation for hash functions by modifying hash_points and added
discussion about domain separation.
Updated todos in the "additional pseudorandomness property"
section. Added a discussion of secrecy into security considerations.
Removed B and PK=Y from ECVRF_hash_points because they are already present
via H, which is computed via hash_to_curve using the suite_string (which identifies B) and Y.
 03  Changed Ed25519 conversions to littleendian, to match RFC 8032; added simple key validation for Ed25519; added Simple SWU cipher suite; clarified Elligator and removed the extra x0 bit, to make Montgomery and Edwards Elligator the same; added domain separation for RSA VRF; improved notation throughout; added nonce generation as a section; changed counter in tryandincrement from four bytes to one, to avoid endian issues; renamed tryandincrement ciphersuites to TAI; added qLen as a separate parameter; changed output length to hLen for ECVRF, to match RSAVRF; made Verify return beta so unverified proofs don't end
up in proof_to_hash; added test vectors.
 04  Clarified handling of optional arguments x and PK in ECVRF_prove. Edited implementation status to bring it up to date.
 05  Renamed ed25519 into the more commonly used edwards25519. Corrected ECVRF_nonce_generation_RFC6979 (thanks to
Gorka Irazoqui Apecechea and Mario Cao Cueto for finding the problem) and corresponding test vectors for the P256 suites. Added a reference to the Rust implementation.
 06  Made some variable names more descriptive. Added a few implementation references.
 07  Incorporated hashtocurve draft by reference to replace our own Elligator2 and Simple SWU. Clarified discussion of EC parameters and functions. Added a 0 octet to all hashing to enforce domain separation from hashing done inside hashtocurve.
 08  Incorporated suggestions from crypto panel review by Chloe Martindale. Changed Reyzin's affiliation. Updated references.
 09  Added a note to remove the implementation page before publication.
 10  Added a check in ECVRF_decode_proof to ensure that s is reduced mod q. Connected security properties (Section 3) and security considerations (Section 7) with more crossreferences.
Contributors
This document also would not be possible without the work of
Moni Naor (Weizmann Institute),
Sachin Vasant (Cisco Systems), and
Asaf Ziv (Facebook).
Shumon Huque, David C. Lawerence, Trevor Perrin, Annie Yousar, Stanislav Smyshlyaev, Liliya Akhmetzyanova,
Tony Arcieri, Sergey Gorbunov, Sam Scott, Nick Sullivan, Christopher Wood, Marek Jankowski, Derek TingHaye Leung, Adam Suhl, Gary Belvinm, Piotr Nojszewski, Gorka Irazoqui Apecechea, and Mario Cao Cueto provided
valuable input to this draft. Riad Wahby was very helpful with the integration of the hashtocurve draft.
References
Normative References
Digital Signature Standard (DSS)
National Institute for Standards and Technology
SEC 1: Elliptic Curve Cryptography
Standards for Efficient Cryptography Group (SECG)
Informative References
Making NSEC5 Practical for DNSSEC
Verifiable Random Functions
How do I validate Curve25519 public keys?
Algorand: Scaling Byzantine Agreements for Cryptocurrencies
Ouroboros Praos: An adaptivelysecure, semisynchronous proofofstake protocol
Public Key Cryptography for the Financial Services Industry: The Elliptic Curve Digital Signature Algorithm (ECDSA)