]>
Verifiable Random Functions (VRFs)
Boston University
665 Commonwealth Avenue
Boston
MA
02215
United States of America
goldbe@cs.bu.edu
Boston University and Algorand
665 Commonwealth Avenue
Boston
MA
02215
United States of America
reyzin@bu.edu
Hong Kong University of Science and Technology
Clearwater Bay
Hong Kong
dipapado@cse.ust.hk
NS1
jvcelak@ns1.com
Crypto Forum
public key cryptography
hashing
authenticated denial
A Verifiable Random Function (VRF) is the public key version of a
keyed cryptographic hash. Only the holder of the secret key
can compute the hash, but anyone with the public key
can verify the correctness of the hash.
VRFs are useful for preventing enumeration of hashbased data structures.
This document specifies VRF constructions based on RSA and elliptic curves that are secure in
the cryptographic random oracle model.
This document is a product of the Crypto Forum Research Group (CFRG) in the IRTF.
Introduction
A Verifiable Random Function
(VRF) is the public key version of a
keyed cryptographic hash. Only the holder of the VRF secret key
can compute the hash, but anyone with the corresponding public key
can verify the correctness of the hash.
A key application of the VRF is to provide privacy against
offline dictionary attacks (also known as enumeration attacks) on data stored in a
hashbased data structure.
In this application, a Prover holds the VRF secret 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 VRF public 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.
This document defines VRFs based on RSA and elliptic curves.
The choices of VRFs for inclusion in this document were based, in part, on synergy with existing RFCs and
commonly available implementations of individual components that are used within the VRFs.
The particular choice of the VRF for a given application depends on the desired security properties, the availability of cryptographically strong implementations, efficiency constraints, and the trust one places in RSA and elliptic curve DiffieHellman assumptions (and the trust in a particular choice of curve in the case of elliptic curves). Differences in the security properties provided by the different options are discussed in Sections and .
This document represents the consensus of the Crypto Forum Research Group (CFRG).
Requirements
The key words "MUST", "MUST NOT",
"REQUIRED", "SHALL",
"SHALL NOT", "SHOULD",
"SHOULD NOT",
"RECOMMENDED", "NOT RECOMMENDED",
"MAY", and "OPTIONAL" in this document
are to be interpreted as described in BCP 14
when, and only
when, they appear in all capitals, as shown here.
Terminology
The following terminology is used throughout this document:
 SK:

The secret key for the VRF. (Note: The secret key is also sometimes called a "private key".)
 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:

Holds the VRF secret key SK and public key PK.
 Verifier:

Holds the VRF public key PK.
 Adversary:

Potential attacker; often used to define a security property.
 Malicious (or adversarial):

Performed by an adversary.
VRF Algorithms
A VRF comes with a key generation algorithm that generates a VRF
public key PK and secret key SK.
The Prover hashes an input alpha using the VRF secret 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 secret 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 the 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 VRFs defined in this document also come 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: uniqueness (full or trusted), collision resistance (full or trusted),
and pseudorandomness (full or selective). Some are designed to also ensure unpredictability under malicious key generation. We now
describe these properties.
Full Uniqueness
Uniqueness means that, for any fixed VRF public
key and for any input alpha, it is infeasible to find proofs for more than one VRF output beta.
More precisely, "full uniqueness" means that an adversary cannot
find
 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.
Full Collision Resistance
Like cryptographic hash functions, VRFs are collision resistant. Collision resistance means
that it is infeasible to find two different inputs alpha1 and alpha2 with the same
output beta.
More precisely, "full collision resistance" means that an adversary cannot
find
 a VRF public key PK,
 two VRF inputs alpha1 and alpha2 that are not equal to each other, and
 two proofs pi1 and pi2
such that
 VRF_verify(PK, alpha1, pi1) outputs ("VALID", beta1),
 VRF_verify(PK, alpha2, pi2) outputs ("VALID", beta2), and
 beta1 is equal to beta2.
Trusted Uniqueness and Trusted Collision Resistance
Full uniqueness and full collision resistance hold even if the VRF keys are generated maliciously.
For some applications, it is sufficient for a VRF to possess weaker security
properties than full uniqueness and full collision resistance. These properties are called "trusted uniqueness"
and "trusted collision resistance"; they are the same as full uniqueness and full collision resistance, respectively, but
are not guaranteed to hold if the adversary gets to choose the VRF public key PK.
Instead, they are guaranteed to hold
only if the VRF keys PK and SK are generated as specified
by the VRF key generation algorithm and then given to the adversary. In other words,
they are guaranteed to hold even if the adversary
has knowledge of SK and PK but are not guaranteed to hold if the adversary has the ability to choose SK and PK.
As further discussed in ,
some of the VRFs specified in this document satisfy only trusted uniqueness and trusted collision resistance.
VRFs in this document that satisfy only trusted uniqueness and trusted collision resistance MUST NOT be used in applications
that need protection against adversarial VRF key generation.
Full Pseudorandomness or Selective Pseudorandomness
Pseudorandomness ensures that when someone who does not know SK sees
a VRF hash output beta without its corresponding VRF proof pi,
beta is indistinguishable from a random value.
More precisely, suppose that the public and secret VRF keys (PK, SK) were generated
correctly.
Pseudorandomness ensures that the VRF hash output beta
(without its corresponding VRF proof pi) on
any adversarially chosen "target" VRF input alpha
looks indistinguishable from random
for any adversary who does not know the VRF secret
key SK. This holds even if the adversary sees VRF hash outputs beta' and proofs
pi' for multiple other inputs alpha' (and even if those other inputs alpha' are chosen by the adversary).
The "full pseudorandomness" security property holds even against an adversary who 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
that suffices in many applications. This security property holds
against an adversary who chooses
the target VRF input alpha first, before it learns the VRF public key PK
and obtains VRF outputs beta'
and proofs pi' on other inputs alpha' of its choice.
As further discussed in ,
the 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 is always distinguishable from
random by the Prover or by any other party that knows the VRF
secret key SK. Such a party can easily distinguish beta from
a random value by comparing beta to the result of VRF_hash(SK, alpha). In particular, if the key is generated maliciously, even parties other than the Prover may know SK, and thus pseudorandomness cannot be guaranteed.
Similarly, the VRF output beta is always distinguishable from random by any party that
knows a valid VRF proof pi corresponding to the VRF input alpha, even
if this party does not know the VRF secret key SK.
Such a party can easily distinguish beta from a random value by
checking to see whether VRF_verify(PK, alpha, pi) returns ("VALID", beta).
Additionally, the VRF output beta may be distinguishable from random if VRF key generation
was not done correctly (for example, if VRF keys were
generated with bad randomness).
Unpredictability under Malicious Key Generation
As explained in , pseudorandomness cannot hold against malicious key generation.
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 leader selection in the consensus protocols of and ), called "unpredictability under malicious key generation". 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 uniformly random, no matter how the VRF keys are generated.
A formal definition of this property appears in Section 3.2 of . As further discussed in , only some of the VRFs specified in this document satisfy this property.
RSA Full Domain Hash VRF (RSAFDHVRF)
The RSA Full Domain Hash VRF (RSAFDHVRF) is a VRF that, for suitable key lengths, satisfies
the "trusted uniqueness", "trusted
collision resistance", and "full pseudorandomness" properties defined in , as further discussed in .
Its security follows from the
standard RSA assumption in the random oracle model. Formal
security proofs are provided in .
The VRF computes the proof pi as a deterministic RSA signature on
input alpha using the RSA Full Domain Hashing algorithm
parameterized 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 the RSAFDHVRF MUST satisfy
the conditions specified in .
In this section, the notation from is used.
 Parameters used:
 (n, e):
 RSA public key
 K:
 RSA private key (its representation is implementation dependent)
 k:
 length, in octets, of the RSA modulus n (k must be less than 2^32)
 Fixed options (specified in ):
 Hash:
 cryptographic hash function
 hLen:
 output length, in octets, of hash function Hash
 suite_string:
 an octet string specifying the RSAFDHVRF
ciphersuite, which determines the above options
 Primitives used:
 I2OSP:
 Conversion of a nonnegative integer to an octet
string as defined in (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
(given a bigendian encoding of an integer, produces the integer)
 RSASP1:
 RSA signature primitive as defined in (given
a private key and an input, raises the input to the
private RSA exponent modulo n)
 RSAVP1:
 RSA verification primitive as defined in (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 (given an input, produces a randomoraclelike output of desired length)
 :
 octet string concatenation
RSAFDHVRF Proving
RSAFDHVRF_prove(K, alpha_string[, MGF_salt])
 Input:
 K:
 RSA private key
 alpha_string:
 VRF hash input, an octet string
 Optional input:
 MGF_salt:
 a public octet string used as a hash function salt; this input is not used when MGF_salt is specified as part of the ciphersuite
 Output:

 pi_string:
 proof, an octet string of length k
Steps:
 mgf_domain_separator = 0x01
 EM = MGF1(suite_string  mgf_domain_separator  MGF_salt  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 a pi_string value that is known to have been produced by RSAFDHVRF_prove, or from within RSAFDHVRF_verify as specified in .
Steps:
 proof_to_hash_domain_separator = 0x02
 beta_string = Hash(suite_string  proof_to_hash_domain_separator  pi_string)
 Output beta_string
RSAFDHVRF Verifying
RSAFDHVRF_verify((n, e), alpha_string, pi_string[, MGF_salt])
 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 k
 Optional input:

 MGF_salt:
 a public octet string used as a hash function salt; this input is not used when MGF_salt is specified as part of the ciphersuite
 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); if RSAVP1 returns "signature representative out of range", output "INVALID" and stop
 mgf_domain_separator = 0x01
 EM' = MGF1(suite_string  mgf_domain_separator  MGF_salt  alpha_string, k  1)
 m' = OS2IP(EM')

If m and m' are equal, output ("VALID", RSAFDHVRF_proof_to_hash(pi_string));
else output "INVALID"
RSAFDHVRF Ciphersuites
This document defines RSAFDHVRFSHA256 as follows:
 suite_string = 0x01.
 The hash function Hash is SHA256 as specified in , with hLen = 32.
 MGF_salt = I2OSP(k, 4)  I2OSP(n, k).
This document defines RSAFDHVRFSHA384 as follows:
 suite_string = 0x02.
 The hash function Hash is SHA384 as specified in , with hLen = 48.
 MGF_salt = I2OSP(k, 4)  I2OSP(n, k).
This document defines RSAFDHVRFSHA512 as follows:
 suite_string = 0x03.
 The hash function Hash is SHA512 as specified in , with hLen = 64.
 MGF_salt = I2OSP(k, 4)  I2OSP(n, k).
Elliptic Curve VRF (ECVRF)
The Elliptic Curve Verifiable Random Function (ECVRF) is a VRF that, for suitable parameter choices,
satisfies the "full uniqueness", "trusted collision resistance",
and "full pseudorandomness" properties defined in .
If the validate_key parameter given to ECVRF_verify is TRUE, then
the ECVRF additionally satisfies "full collision resistance" and "unpredictability under malicious key generation". See
for further discussion. Formal security proofs are provided
in .
 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
 fLen:
 length, in octets, of an element in F encoded as an octet string
 E:
 elliptic curve (EC) defined over F
 ptLen:
 length, in octets, of a point on E 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., the smallest integer such that 2^(8qLen) > q
 cLen:
 length, in octets, of a challenge value used by the VRF (note that in the typical case, cLen is qLen/2 or close to it)
 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 (hLen must be at least cLen; in the typical case, it is at least qLen)
 ECVRF_encode_to_curve:
 a function that hashes strings to points on E
 ECVRF_nonce_generation:
 a function that derives a pseudorandom nonce
from SK and the input as part of ECVRF proving
 suite_string:
 an octet string 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 a point on E to a ptLenoctet string
 string_to_point:
 conversion of a ptLenoctet string to a point on E.
string_to_point returns "INVALID" if the octet string does not convert to a valid EC point on the curve E
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 secret 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, a point on E
 PK_string = point_to_string(Y):
 VRF public key represented as an octet string
 encode_to_curve_salt:
 a public value used as a hash function salt
ECVRF Proving
ECVRF_prove(SK, alpha_string[, encode_to_curve_salt])
 Input:

 SK:
 VRF secret key
 alpha_string:
 input alpha, an octet string
 Optional input:

 encode_to_curve_salt:
 a public salt value, an octet string; this input is not used when encode_to_curve_salt is specified as part of the ciphersuite
 Output:

 pi_string:
 VRF proof, an octet string of length ptLen+cLen+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_encode_to_curve(encode_to_curve_salt, alpha_string) (see )
 h_string = point_to_string(H)
 Gamma = x*H
 k = ECVRF_nonce_generation(SK, h_string) (see )
 c = ECVRF_challenge_generation(Y, H, Gamma, k*B, k*H) (see )
 s = (k + c*x) mod q
 pi_string = point_to_string(Gamma)  int_to_string(c, cLen)  int_to_string(s, qLen)
 Output pi_string
ECVRF Proof to Hash
ECVRF_proof_to_hash(pi_string)
 Input:

 pi_string:
 VRF proof, an octet string of length ptLen+cLen+qLen
 Output:

 "INVALID", or
 beta_string:
 VRF hash output, an octet string of length hLen
Important note:
ECVRF_proof_to_hash should be run only on a pi_string value 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
 proof_to_hash_domain_separator_front = 0x03
 proof_to_hash_domain_separator_back = 0x00
 beta_string = Hash(suite_string  proof_to_hash_domain_separator_front  point_to_string(cofactor * Gamma)  proof_to_hash_domain_separator_back)
 Output beta_string
ECVRF Verifying
ECVRF_verify(PK_string, alpha_string, pi_string[, encode_to_curve_salt, validate_key])
 Input:

 PK_string:
 public key, an octet string
 alpha_string:
 VRF input, an octet string
 pi_string:
 VRF proof, an octet string of length ptLen+cLen+qLen
 Optional input:

 encode_to_curve_salt:
 a public salt value, an octet string; this input is not used when encode_to_curve_salt is specified as part of the ciphersuite
 validate_key:
 a boolean. An implementation MAY support only the option of validate_key = TRUE, or only the option of validate_key = FALSE, in which case this input is not needed. If an implementation supports only one option, it MUST specify which option it supports
 Output:

("VALID", beta_string), where beta_string is the VRF hash output, an octet string of length hLen, or
"INVALID"
Steps:
 Y = string_to_point(PK_string)
 If Y is "INVALID", output "INVALID" and stop
 If validate_key, run ECVRF_validate_key(Y) (); if it outputs "INVALID", output "INVALID" and stop
 D = ECVRF_decode_proof(pi_string) (see )
 If D is "INVALID", output "INVALID" and stop
 (Gamma, c, s) = D
 H = ECVRF_encode_to_curve(encode_to_curve_salt, alpha_string) (see )
 U = s*B  c*Y
 V = s*H  c*Gamma
 c' = ECVRF_challenge_generation(Y, H, Gamma, U, V) (see )

If c and c' are equal, output ("VALID", ECVRF_proof_to_hash(pi_string));
else output "INVALID"
Note that the first three steps need to be performed only once for a given public key.
ECVRF Auxiliary Functions
ECVRF Encode to Curve
The ECVRF_encode_to_curve algorithm takes a public salt (see ) and 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; these algorithms are not compatible with each other and are intended for use with the various ciphersuites specified in .
 Input:

 encode_to_curve_salt:
 public salt value, an octet string
 alpha_string:
 value to be hashed, an octet string
 Output:

 H:
 hashed value, a point in G
ECVRF_encode_to_curve_try_and_increment
The ECVRF_encode_to_curve_try_and_increment(encode_to_curve_salt, alpha_string) algorithm
implements ECVRF_encode_to_curve in a simple and
generic way that works for any elliptic curve. To use this algorithm,
hLen MUST be at least fLen.
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 algorithm's running time depends on alpha_string,
this algorithm SHOULD be avoided in
applications where it is important that
the VRF input alpha remain secret.
ECVRF_encode_to_curve_try_and_increment(encode_to_curve_salt, alpha_string)
 Fixed option (specified in ):

 interpret_hash_value_as_a_point:
 a function that attempts to convert a cryptographic hash value to a point on E; may output "INVALID"
Steps:
 ctr = 0
 encode_to_curve_domain_separator_front = 0x01
 encode_to_curve_domain_separator_back = 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  encode_to_curve_domain_separator_front  encode_to_curve_salt  alpha_string  ctr_string  encode_to_curve_domain_separator_back)
 H = interpret_hash_value_as_a_point(hash_string)
 If H is not "INVALID" and cofactor > 1, set H = cofactor * H
 ctr = ctr + 1
 Output H
Note that even though the loop is infinite as written and int_to_string(ctr, 1) may fail when ctr reaches 256,
each of the options for the interpret_hash_value_as_a_point function specified in
will succeed on roughly half hash_string values. Thus, the loop is expected to stop after two iterations, and ctr is overwhelmingly unlikely (probability about 2^256) to reach 256.
ECVRF_encode_to_curve_h2c_suite
The ECVRF_encode_to_curve_h2c_suite(encode_to_curve_salt, alpha_string) algorithm
implements ECVRF_encode_to_curve using one of the several
hashtocurve options defined in
.
The specific choice of the hashtocurve option
(called the Suite ID in )
is given by the h2c_suite_ID_string parameter.
ECVRF_encode_to_curve_h2c_suite(encode_to_curve_salt, alpha_string)
 Fixed option (specified in ):

 h2c_suite_ID_string:
 a hashtocurve Suite ID, encoded in ASCII (see discussion below)
Steps:
 string_to_be_hashed = encode_to_curve_salt  alpha_string

H = encode(string_to_be_hashed)
(the encode function is discussed below)
 Output H
The encode function is provided by the hashtocurve suite (as specified in ) whose ID is h2c_suite_ID_string.
The domain separation tag DST, a parameter in 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; these algorithms are not compatible with each other.
The choice of a particular algorithm from the options specified in this section depends on the ciphersuite, as specified in .
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 nonce between 1 and q1
The ECVRF_nonce_generation function is implemented according to the process specified in
, 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 (in bits) is set as hLen*8 (note that hlen is not to be confused with hLen, which is used in this document to represent the length of the output of Hash in octets).
 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 (this qlen is not to be confused with qLen, which is used in this document to represent the length of q in octets).
 All the other values and primitives are as defined in .
ECVRF Nonce Generation from RFC 8032
The following is derived from Steps 2 and 3 in
. To use this algorithm, hLen MUST be at least 64.
ECVRF_nonce_generation_RFC8032(SK, h_string)
 Input:

 SK:
 an ECVRF secret key
 h_string:
 an octet string
 Output:

 k:
 an integer nonce 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 Challenge Generation
ECVRF_challenge_generation(P1, P2, P3, P4, P5)
 Input:

 P1, P2, P3, P4, P5:
 EC points
 Output:

 c:
 challenge value, an integer between 0 and 2^(8*cLen)1
Steps:
 challenge_generation_domain_separator_front = 0x02
 Initialize str = suite_string  challenge_generation_domain_separator_front

For PJ in [P1, P2, P3, P4, P5]:
str = str  point_to_string(PJ)
 challenge_generation_domain_separator_back = 0x00
 str = str  challenge_generation_domain_separator_back
 c_string = Hash(str)
 truncated_c_string = c_string[0]...c_string[cLen1]
 c = string_to_int(truncated_c_string)
 Output c
ECVRF Decode Proof
ECVRF_decode_proof(pi_string)
 Input:

 pi_string:
 VRF proof, an octet string (ptLen+cLen+qLen octets)
 Output:

 "INVALID", or
 Gamma:
 a point on E
 c:
 an integer between 0 and 2^(8*cLen)1
 s:
 an integer between 0 and q1
Steps:
 gamma_string = pi_string[0]...pi_string[ptLen1]
 c_string = pi_string[ptLen]...pi_string[ptLen+cLen1]
 s_string = pi_string[ptLen+cLen]...pi_string[ptLen+cLen+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 Validate Key
ECVRF_validate_key(Y)
 Input:

 Y:
 public key, a point on E
 Output:

"VALID" or "INVALID"
Important note:
The public key Y provided as input to this procedure MUST be a valid point on E.
Steps:
 Let Y' = cofactor*Y
 If Y' is the identity element of the elliptic curve group, output "INVALID" and stop
 Output "VALID"
Note that if the cofactor = 1, then Step 1 simply sets Y'=Y. In particular, for the P256 curve, ECVRF_validate_key simply ensures that Y is not the point at infinity.
Any algorithm with identical inputoutput behavior MAY be used in place of the above steps. For example, if the total number
of Y values that could cause Step 2 to output "INVALID" is small, it may be more efficient to simply
check Y against a fixed list of such values. For example, the following algorithm MAY be used for the edwards25519 curve:
 PK_string = point_to_string(Y)
 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 the list [bad_pk[0],...,bad_pk[6]], output "INVALID" and stop
 Output "VALID"
(This algorithm works for the following reason. Note that there are eight bad points  namely, the points whose order is 1, 2, 4, or 8  on the edwards25519 curve. Their ycoordinates happen to be 0 (two points of order 4), 1 (one point of order 1), bad_y2 (two points of order 8), pbad_y2 (two points of order 8), and p1 (one point of order 2). They can be obtained by converting the points specified in to Edwards coordinates. Thus, bad_pk[0] (of order 4), bad_pk[2] (of order 8), and bad_pk[3] (of order 8) each match two bad points, depending on the sign of the xcoordinate. This sign is cleared in Step 3 in order to make sure that it does not affect the comparison. bad_pk[1] (of order 1) and bad_pk[4] (of order 2) each match one bad point, because the xcoordinate is 0 for these two points. Note that the first five list elements cover the eight bad points. However, to cover the case when the ycoordinate of the public key Y has not been modular reduced by p, the list also includes bad_pk[5] and bad_pk[6], which are simply bad_pk[0] and bad_pk[1] shifted by p. There is no need to shift the other bad_pk values by p (or any bad_pk values by a larger multiple of p), because their ycoordinates would exceed 2^255, and the algorithm ensures that y_string corresponds to an integer less than 2^255 in Step 3.)
ECVRF Ciphersuites
This document defines ECVRFP256SHA256TAI as follows:

suite_string = 0x01.

The EC group G is the NIST P256 elliptic curve, with the finite field and curve parameters
as specified in Section 3.2.1.3 of
and . For this group,
fLen = qLen = 32 and cofactor = 1.

cLen = 16.
 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 secret key SK.
 encode_to_curve_salt = PK_string.
 The ECVRF_nonce_generation function is as specified in .
 The int_to_string function is the I2OSP function specified in . (This is bigendian representation.)
 The string_to_int function is the OS2IP function specified in . (This is bigendian representation.)

The point_to_string function converts a point on E to an octet string
according to the encoding specified in Section 2.3.3 of
with point compression on.
This implies that ptLen = fLen + 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 the 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
a point on E according to the encoding specified in Section 2.3.4 of
. This function MUST output "INVALID" if
the octet string does not decode to a point on the curve E.

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

The ECVRF_encode_to_curve function is as specified in , with interpret_hash_value_as_a_point(s) = string_to_point(0x02  s).
This document defines ECVRFP256SHA256SSWU as identical to ECVRFP256SHA256TAI, except that
 suite_string = 0x02.
 The ECVRF_encode_to_curve function is as specified in ,
with h2c_suite_ID_string = P256_XMD:SHA256_SSWU_NU_
(the suite is defined in
).
This document defines ECVRFEDWARDS25519SHA512TAI as follows:

suite_string = 0x03.

The EC group G is the edwards25519
elliptic curve, with the finite field and curve parameters as defined in
Table 1 in .
For this group, fLen = qLen = 32 and cofactor = 8.

cLen = 16.
 The secret key and generation of the secret scalar and the public
key are specified in .
 encode_to_curve_salt = PK_string.
 The ECVRF_nonce_generation function is as specified in .
 The int_to_string function is implemented as specified in the first paragraph 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 a point on E to an
octet string according to the encoding specified
in .
This implies that ptLen = fLen = 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 the 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 a point on E
according to the encoding specified in . This function MUST output "INVALID" if
the octet string does not decode to a point on the curve E.

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

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

suite_string = 0x04.
 The ECVRF_encode_to_curve function is as specified in , with
h2c_suite_ID_string = edwards25519_XMD:SHA512_ELL2_NU_
(the suite is defined in
).
IANA Considerations
This document has no IANA actions.
Security Considerations
Key Generation
Implementations of the VRFs defined in this
document MUST ensure that they generate VRF keys correctly and
use good randomness. However, in some applications, keys may be generated by an adversary who
does not necessarily implement this document. We now discuss the implications of this possibility.
Uniqueness and Collision Resistance under Malicious Key Generation
See for definitions of uniqueness and collision resistance properties.
The RSAFDHVRF satisfies only the "trusted" variants of uniqueness
and collision resistance.
Thus, for the RSAFDHVRF, uniqueness and collision resistance may not hold if the keys are generated adversarially
(specifically, if the RSA function specified in the public key is not bijective because the modulus n or the exponent e are chosen without complying with ); thus, the
RSAFDHVRF as defined in this document does not have "full uniqueness" and "full collision resistance".
Therefore, if malicious key generation is a concern, the
RSAFDHVRF has to be enhanced by additional cryptographic checks (such as zeroknowledge proofs) to ensure
that its public key has the right form. These enhancements are left for future specifications.
For the ECVRF, the Verifier MUST obtain E and B from a trusted source, such as a ciphersuite specification, rather than from the Prover. If the Verifier does so, then the
ECVRF
satisfies "full uniqueness", ensuring uniqueness even under malicious key generation. The ECVRF also satisfies "trusted collision resistance".
It additionally satisfies "full collision resistance" if the validate_key parameter given to ECVRF_verify is TRUE. This setting of ECVRF_verify ensures collision resistance under malicious key generation.
Pseudorandomness under Malicious Key Generation
Without good randomness, the "pseudorandomness"
properties of the VRF (defined in ) 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.
Unpredictability under Malicious Key Generation
Unpredictability under malicious key generation (defined in ) does not hold for the RSAFDHVRF. (Specifically, the VRF output may be predictable if the RSA function specified in the public key is far from bijective because the modulus n or the exponent e are chosen without complying with .) If unpredictability under malicious key generation is desired, the
RSAFDHVRF has to be enhanced by additional cryptographic checks (such as zeroknowledge proofs) to ensure
that its public key has the right form. These enhancements are left for future specifications.
Unpredictability under malicious key generation holds for the ECVRF if the validate_key parameter given to ECVRF_verify is TRUE.
Security Levels
As shown in , the RSAFDHVRF satisfies the trusted uniqueness property unconditionally. The security level of the RSAFDHVRF, measured in bits, for the other two properties is as follows (in the random oracle model for the functions MGF1 and Hash):
 For trusted collision resistance:
 approximately 8*min(k/2, hLen/2) (as shown in ).
 For selective pseudorandomness:
 approximately as strong as the security, in bits, of the RSA problem for the key (n, e) (as shown in ).
As shown in , the security level of the ECVRF, measured in bits, is as follows (in the random oracle model for the functions Hash and ECVRF_encode_to_curve):
 For uniqueness (both trusted and full):
 approximately 8*min(qLen, cLen).
 For collision resistance (trusted or full, depending on whether validation is performed as explained in ):
approximately 8*min(qLen/2, hLen/2).
 For selective pseudorandomness:
 approximately as strong as the security, in bits, of the decisional DiffieHellman problem in the group G (which is at most 8*qLen/2).
See for the definitions of these security properties and for the discussion of full pseudorandomness.
Selective vs. Full Pseudorandomness
presents cryptographic reductions to an
underlying hard problem (namely, the RSA problem for the RSAFDHVRF
and the decisional DiffieHellman problem for the ECVRF)
to prove that the VRFs specified in this
document possess not only selective pseudorandomness but also
full pseudorandomness
(see for an explanation of these notions).
However, the cryptographic reductions are tighter for selective
pseudorandomness than for full pseudorandomness. Specifically, the approximate provable security level, measured in bits,
for full pseudorandomness may be obtained from the provable security level for selective pseudorandomness (given in ) by subtracting the binary logarithm
of the number of proofs produced for a given secret key. This holds for both the RSAFDHVRF and the ECVRF.
While no known attacks against full pseudorandomness are stronger than similar attacks against selective pseudorandomness, some applications may be concerned about tightness of cryptographic
reductions to ensure specific levels of provable security. Such applications may consider the following three options:
 They may limit the number of proofs produced for a given secret key, to reduce the loss in the provable security level.
 They may work to ensure that selective pseudorandomness is sufficient for
the application. That is, they may design the application such that
pseudorandomness of outputs matters only for inputs that are chosen
independently of the VRF key.
 They
may increase
security parameters to make up for lossy security reductions.
For the RSAFDHVRF, this means increasing the RSA key length. For the
ECVRF, this means increasing the cryptographic strength of the EC group
G by specifying a new ciphersuite.
Proper Pseudorandom Nonce for the 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 VRF secret scalar x (and thus break pseudorandomness of the VRF)
after observing several valid VRF proofs pi, using, for example, techniques described in
. The nonce generation methods
specified in the ECVRF ciphersuites of
are designed with this requirement in mind.
SideChannel Attacks
Sidechannel attacks on cryptographic primitives are an important issue.
Implementers should
take care to avoid sidechannel attacks that leak information about
the VRF secret key SK (and the nonce k used in the ECVRF), which is
used in VRF_prove.
In most applications, the VRF_proof_to_hash and VRF_verify
algorithms take only inputs that are public, and thus sidechannel
attacks are typically not a concern for these algorithms.
The VRF input alpha may also be a sensitive input to VRF_prove and may
need to be protected against sidechannel 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_encode_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 on the fly.
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 that 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 that is 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 Edwardscurve Digital Signature Algorithm (EdDSA) signatures) is not needed,
even for applications that need to handle long alpha or
to support the
InitializeUpdateFinalize (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_encode_to_curve. The curve point H becomes the representative
of alpha thereafter.
Hash Function Domain Separation
Hashing is used for different purposes in the two VRFs. Specifically, in the RSAFDHVRF, hashing is used in MGF1 and in proof_to_hash; in the ECVRF, hashing is used in encode_to_curve, nonce_generation, challenge_generation, and proof_to_hash. The
theoretical analysis treats each of these functions as a separate hash function, modeled as a random oracle.
This analysis still holds even if the same hash function is used, as long as the
inputs given to the hash function for a given SK and alpha are overwhelmingly unlikely
to be equal to each other or to any inputs given 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 second octets
of the inputs 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 in nonce_generation are unlikely to equal
inputs used in encode_to_curve, proof_to_hash, and challenge_generation. 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, challenge_generation, and encode_to_curve_try_and_increment
are all different.
 The last octet of the inputs to the hash function used in
proof_to_hash, challenge_generation, and encode_to_curve_try_and_increment is always zero
and is therefore different from the last octet of the input to the hash function used in ECVRF_encode_to_curve_h2c_suite,
which is set equal to the nonzero length of the domain separation tag per .
Hash Function Salting
If a hash collision is found, in order to make it more difficult for the adversary to exploit such a collision, the MGF1 function for the RSAFDHVRF and the ECVRF_encode_to_curve function for the ECVRF use a public value in addition to alpha (as a socalled salt). This value is determined by the ciphersuite. For the ciphersuites defined in this document, it is set equal to the string representation of the RSA modulus and EC public key, respectively. Implementations that do not use one of the ciphersuites (see ) MAY use a different salt. For example, if a group of public keys shares the same salt, then the hash of the VRF input alpha will be the same for the entire group of public keys; this can be helpful for some protocols that use the VRF.
Futureproofing
If future designs need to specify variants (e.g., additional ciphersuites) of the RSAFDHVRF or the ECVRF as defined 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. The suite_string constants discussed in this document are all single octets; if a future suite_string constant is longer than one octet, then it should start with a different octet than the suite_string constants discussed in this document. Then, for the RSAFDHVRF, the inputs to the hash function used in MGF1 and proof_to_hash will be different from other ciphersuites.
For the ECVRF, the inputs to the
ECVRF_encode_to_curve hash function used in producing H are then guaranteed to be different from other
ciphersuites; since all the other hashing done by the Prover
depends on H, inputs to all the hash functions used by the Prover will also be
different from other ciphersuites as long as ECVRF_encode_to_curve is collision resistant.
References
Normative References
Recommendations for Discrete
Logarithmbased Cryptography:
Elliptic Curve Domain Parameters
National Institute for Standards and Technology (NIST)
NIST SP 800186
SEC 1: Elliptic Curve Cryptography
Standards for Efficient Cryptography Group (SECG)
Version 2.0
Informative References
Public Key Cryptography for the Financial Services Industry: the Elliptic Curve Digital Signature Algorithm (ECDSA)
American National Standards Institute (ANSI)
ANSI X9.62
Biased Nonce Sense: Lattice Attacks against
Weak ECDSA Signatures in Cryptocurrencies
Cryptology ePrint Archive, Paper 2019/023
Ouroboros Praos: An adaptivelysecure, semisynchronous proofofstake blockchain
Cryptology ePrint Archive, Paper 2017/573
Algorand: Scaling Byzantine Agreements for Cryptocurrencies
Cryptology ePrint Archive, Paper 2017/454
NSEC5: Provably Preventing
DNSSEC Zone Enumeration
Cryptology ePrint Archive, Paper 2014/582
Verifiable Random Functions
FOCS '99: Proceedings of the 40th Annual Symposium on Foundations of Computer Science, pp. 120130
Making NSEC5 Practical for DNSSEC
Cryptology ePrint Archive, Paper 2017/099
How do I validate Curve25519 public keys?
Test Vectors for the RSAFDHVRF Ciphersuites
The test vectors in this section were generated using code provided at .
There are three keys used in the nine examples below. First, we provide the keys. They are shown in hexadecimal bigendian notation.
2048bit key:
3072bit key:
4096bit key:
RSAFDHVRFSHA256
Example 1, using the 2048bit key above:
Example 2, using the 3072bit key above:
Example 3, using the 4096bit key above:
RSAFDHVRFSHA384
Example 4, using the 2048bit key above:
Example 5, using the 3072bit key above:
Example 6, using the 4096bit key above:
RSAFDHVRFSHA512
Example 7, using the 2048bit key above:
Example 8, using the 3072bit key above:
Example 9, using the 4096bit key above:
Test Vectors for the ECVRF Ciphersuites
The test vectors in this section were generated using code provided at .
ECVRFP256SHA256TAI
The example secret keys and messages in Examples 10 and 11 are taken from .
Example 10:
Example 11:
The example secret key in Example 12 is taken from Appendix L.4.2 of .
Example 12:
ECVRFP256SHA256SSWU
The example secret keys and messages in Examples 13 and 14 are taken from .
Example 13:
Example 14:
The example secret key in Example 15 is taken from Appendix L.4.2 of .
Example 15:
ECVRFEDWARDS25519SHA512TAI
The example secret keys and messages in Examples 16, 17, and 18 are taken from .
Example 16:
Example 17:
Example 18:
ECVRFEDWARDS25519SHA512ELL2
The example secret keys and messages in Examples 19, 20, and 21 are taken from .
Example 19:
Example 20:
Example 21:
Contributors
This document would not be possible without the work of , , and
. provided a thorough cryptographer's review.
, , ,
, , , , , , , ,
, , ,
, , , , ,
, , ,
, , and provided valuable
input to this document. ,
, , and
provided independent verification of the test vectors.
helped this document align with .