Internet-Draft VRF February 2022
Goldberg, et al. Expires 10 August 2022 [Page]
Workgroup:
CFRG
Internet-Draft:
draft-irtf-cfrg-vrf-11
Published:
Intended Status:
Standards Track
Expires:
Authors:
S. Goldberg
Boston University
L. Reyzin
Boston University and Algorand
D. Papadopoulos
Hong Kong University of Science and Technology
J. Vcelak
NS1

Verifiable Random Functions (VRFs)

Abstract

A Verifiable Random Function (VRF) is the public-key version of a keyed cryptographic hash. Only the holder of the private 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 hash-based data structures. This document specifies several VRF constructions based on RSA and Elliptic Curves that are secure in the cryptographic random oracle model.

Status of This Memo

This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.

Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

This Internet-Draft will expire on 10 August 2022.

Table of Contents

1. Introduction

1.1. Rationale

A Verifiable Random Function (VRF) [MRV99] is the public-key version of a keyed cryptographic hash. Only the holder of the private VRF 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 hash-based data structure. In this application, a Prover holds the VRF private key and uses the VRF hashing to construct a hash-based 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.

1.2. 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 [RFC2119].

1.3. 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.

2. 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

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

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:

Thus, for VRFs defined in this document, VRF_hash is defined as

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

that outputs (VALID, beta = VRF_proof_to_hash(pi)) if pi is valid, and INVALID otherwise.

3. VRF Security Properties

VRFs are designed to ensure the following security properties.

3.1. 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 computationally-bounded 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 Section 7.1.1, 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.

3.2. 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 Section 7.1.1, 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.

3.3. 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 adversarially-chosen "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 Section 7.3, 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 a 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.)

3.4. Some VRFs: Unpredictability Under Malicious Key Generation

As explained in Section 3.3, 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 hard-coded 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 [GHMVZ17] and [DGKR18]), 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 uniform, no matter how the VRF keys are generated.

A formal definition of this property appears in Section 3.2 of [DGKR18]. The RSA-FDH-VRF presented in this document does not satisfy this property. The ECVRF presented in this document satisfies this property if validate_key parameter given to the ECVRF_verify is TRUE.

4. RSA Full Domain Hash VRF (RSA-FDH-VRF)

The RSA Full Domain Hash VRF (RSA-FDH-VRF) is a VRF that, for suitable key lengths, satisfies the "trusted uniqueness", "trusted collision resistance", and "full pseudorandomness" properties defined in Section 3, as further discussed in Section 7. Its security follows from the standard RSA assumption in the random oracle model. Formal security proofs are in [PWHVNRG17].

The VRF computes the proof pi as a deterministic RSA signature on input alpha using the RSA Full Domain Hash Algorithm [RFC8017] 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 RSA-FDH-VRF MUST be generated in a way that it satisfies the conditions specified in Section 3 of [RFC8017].

In this section, the notation from [RFC8017] is used.

Parameters used:

Fixed options (specified in Section 4.4):

Primitives used:

4.1. RSA-FDH-VRF 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:

  1. mgf_domain_separator = 0x01
  2. EM = MGF1(suite_string || mgf_domain_separator || MGF_salt || alpha_string, k - 1)
  3. m = OS2IP(EM)
  4. s = RSASP1(K, m)
  5. pi_string = I2OSP(s, k)
  6. Output pi_string

4.2. RSA-FDH-VRF 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 Section 4.3.

Steps:

  1. proof_to_hash_domain_separator = 0x02
  2. beta_string = Hash(suite_string || proof_to_hash_domain_separator || pi_string)
  3. Output beta_string

4.3. RSA-FDH-VRF 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:

Output:

  • ("VALID", beta_string), where beta_string is the VRF hash output, an octet string of length hLen; or

    "INVALID"

Steps:

  1. s = OS2IP(pi_string)
  2. m = RSAVP1((n, e), s); if RSAVP1 returns "signature representative out of range", output "INVALID" and stop.
  3. mgf_domain_separator = 0x01
  4. EM' = MGF1(suite_string || mgf_domain_separator || MGF_salt || alpha_string, k - 1)
  5. m' = OS2IP(EM')
  6. If m and m' are equal, output ("VALID", RSAFDHVRF_proof_to_hash(pi_string)); else output "INVALID".

4.4. RSA-FDH-VRF Ciphersuites

This document defines RSA-FDH-VRF-SHA256 as follows:

  • suite_string = 0x01
  • The hash function Hash is SHA-256 as specified in [RFC6234], with hLen = 32
  • MGF_salt = I2OSP(k, 4) || I2OSP(n, k)

This document defines RSA-FDH-VRF-SHA384 as follows:

  • suite_string = 0x02
  • The hash function Hash is SHA-384 as specified in [RFC6234], with hLen = 48
  • MGF_salt = I2OSP(k, 4) || I2OSP(n, k)

This document defines RSA-FDH-VRF-SHA512 as follows:

  • suite_string = 0x03
  • The hash function Hash is SHA-512 as specified in [RFC6234], with hLen = 64
  • MGF_salt = I2OSP(k, 4) || I2OSP(n, k)

5. 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 Section 3. If validate_key parameter given to the ECVRF_verify is TRUE, then the ECVRF additionally satisfies "full collision resistance" and "unpredictability under malicious key generation". See Section 7 for further discussion. Formal security proofs are in [PWHVNRG17].

Notation used:

Fixed options (specified in Section 5.5):

Type conversions (specified in Section 5.5):

Parameters used (the generation of these parameters is specified in Section 5.5):

5.1. ECVRF Proving

ECVRF_prove(SK, alpha_string[, encode_to_curve_salt])

Input:

  • SK - VRF private 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, octet string of length ptLen+cLen+qLen

Steps:

  1. 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 Section 5.5;

    these values can be cached, for example, after key generation, and need not be rederived each time)

  2. H = ECVRF_encode_to_curve(encode_to_curve_salt, alpha_string) (see Section 5.4.1)
  3. h_string = point_to_string(H)
  4. Gamma = x*H
  5. k = ECVRF_nonce_generation(SK, h_string) (see Section 5.4.2)
  6. c = ECVRF_challenge_generation(Y, H, Gamma, k*B, k*H) (see Section 5.4.3)
  7. s = (k + c*x) mod q
  8. pi_string = point_to_string(Gamma) || int_to_string(c, cLen) || int_to_string(s, qLen)
  9. Output pi_string

5.2. ECVRF Proof to Hash

ECVRF_proof_to_hash(pi_string)

Input:

  • pi_string - VRF proof, octet string of length ptLen+cLen+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 Section 5.3.

Steps:

  1. D = ECVRF_decode_proof(pi_string) (see Section 5.4.4)
  2. If D is "INVALID", output "INVALID" and stop
  3. (Gamma, c, s) = D
  4. proof_to_hash_domain_separator_front = 0x03
  5. proof_to_hash_domain_separator_back = 0x00
  6. beta_string = Hash(suite_string || proof_to_hash_domain_separator_front || point_to_string(cofactor * Gamma) || proof_to_hash_domain_separator_back)
  7. Output beta_string

5.3. 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, octet string
  • pi_string - VRF proof, 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 is supports.

Output:

  • ("VALID", beta_string), where beta_string is the VRF hash output, octet string of length hLen; or

    "INVALID"

Steps:

  1. Y = string_to_point(PK_string)
  2. If Y is "INVALID", output "INVALID" and stop
  3. If validate_key, run ECVRF_validate_key(Y) (Section 5.4.5); if it outputs "INVALID", output "INVALID" and stop
  4. D = ECVRF_decode_proof(pi_string) (see Section 5.4.4)
  5. If D is "INVALID", output "INVALID" and stop
  6. (Gamma, c, s) = D
  7. H = ECVRF_encode_to_curve(encode_to_curve_salt, alpha_string) (see Section 5.4.1)
  8. U = s*B - c*Y
  9. V = s*H - c*Gamma
  10. c' = ECVRF_challenge_generation(Y, H, Gamma, U, V) (see Section 5.4.3)
  11. 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.

5.4. ECVRF Auxiliary Functions

5.4.1. ECVRF Encode to Curve

The ECVRF_encode_to_curve algorithm takes a public salt (see Section 7.9) 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 Section 7.7 for further discussion.

This section specifies a number of such algorithms, which are not compatible with each other and are intended to use with various ciphersuites specified in Section 5.5.

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
5.4.1.1. ECVRF_encode_to_curve_try_and_increment

The following 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 Section 5.5, 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_encode_to_curve_try_and_increment(encode_to_curve_salt, alpha_string)

Fixed option (specified in Section 5.5):

  • 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:

  1. ctr = 0
  2. encode_to_curve_domain_separator_front = 0x01
  3. encode_to_curve_domain_separator_back = 0x00
  4. H = "INVALID"
  5. While H is "INVALID" or H is the identity element of the elliptic curve group:

    1. ctr_string = int_to_string(ctr, 1)
    2. 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)
    3. H = interpret_hash_value_as_a_point(hash_string)
    4. If H is not "INVALID" and cofactor > 1, set H = cofactor * H
    5. ctr = ctr + 1
  6. Output H

Note even though the loop is infinite as written, and int_to_string(ctr,1) may fail when ctr reaches 256, interpret_hash_value_as_a_point functions specified in Section 5.5 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.

5.4.1.2. 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 hash-to-curve options defined in [I-D.irtf-cfrg-hash-to-curve]. The specific choice of the hash-to-curve option (called Suite ID in [I-D.irtf-cfrg-hash-to-curve]) 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 Section 5.5):

  • h2c_suite_ID_string - a hash-to-curve suite ID, encoded in ASCII (see discussion below)

Steps:

  1. string_to_be_hashed = encode_to_curve_salt || alpha_string
  2. H = encode(string_to_be_hashed)

    (the encode function is discussed below)

  3. Output H

The encode function is provided by the hash-to-curve suite whose ID is h2c_suite_ID_string, as specified in [I-D.irtf-cfrg-hash-to-curve], Section 8. The domain separation tag DST, a parameter to the hash-to-curve suite, SHALL be set to

  • "ECVRF_" || h2c_suite_ID_string || suite_string

where "ECVRF_" is represented as a 6-byte ASCII encoding (in hexadecimal, octets 45 43 56 52 46 5F).

5.4.2. 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 depends on the ciphersuite, as specified in Section 5.5.

5.4.2.1. 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 q-1

The ECVRF_nonce_generation function is as specified in [RFC6979] 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 (in bits) 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 (this qlen is not to be confused with qLen in this document, which is the length of q in octets)
  • All the other values and primitives as defined in [RFC6979]
5.4.2.2. ECVRF Nonce Generation from RFC 8032

The following is from Steps 2-3 of Section 5.1.6 in [RFC8032]. 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 q-1

Steps:

  1. hashed_sk_string = Hash(SK)
  2. truncated_hashed_sk_string = hashed_sk_string[32]...hashed_sk_string[63]
  3. k_string = Hash(truncated_hashed_sk_string || h_string)
  4. k = string_to_int(k_string) mod q

5.4.3. ECVRF Challenge Generation

ECVRF_challenge_generation(P1, P2, P3, P4, P5)

Input:

  • P1, P2, P3, P4, P5 - EC points

Output:

  • c - challenge value, integer between 0 and 2^(8*cLen)-1

Steps:

  1. challenge_generation_domain_separator_front = 0x02
  2. Initialize str = suite_string || challenge_generation_domain_separator_front
  3. for PJ in [P1, P2, P3, P4, P5]:

    str = str || point_to_string(PJ)

  4. challenge_generation_domain_separator_back = 0x00
  5. str = str || challenge_generation_domain_separator_back
  6. c_string = Hash(str)
  7. truncated_c_string = c_string[0]...c_string[cLen-1]
  8. c = string_to_int(truncated_c_string)
  9. Output c

5.4.4. ECVRF Decode Proof

ECVRF_decode_proof(pi_string)

Input:

  • pi_string - VRF proof, octet string (ptLen+cLen+qLen octets)

Output:

  • "INVALID", or
  • Gamma - a point on E
  • c - integer between 0 and 2^(8*cLen)-1
  • s - integer between 0 and q-1

Steps:

  1. gamma_string = pi_string[0]...pi_string[ptLen-1]
  2. c_string = pi_string[ptLen]...pi_string[ptLen+cLen-1]
  3. s_string = pi_string[ptLen+cLen]...pi_string[ptLen+cLen+qLen-1]
  4. Gamma = string_to_point(gamma_string)
  5. if Gamma = "INVALID" output "INVALID" and stop
  6. c = string_to_int(c_string)
  7. s = string_to_int(s_string)
  8. if s >= q output "INVALID" and stop
  9. Output Gamma, c, and s

5.4.5. 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 given to this procedure MUST be a valid point on E.

Steps:

  1. Let Y' = cofactor*Y
  2. If Y' is the identity element of the elliptic curve group, output "INVALID" and stop
  3. Output "VALID"

Note that if the cofactor = 1, then Step 1 simply sets Y'=Y. In particular, for the P-256 curve, ECVRF_validate_key simply ensures that Y is not the point at infinity.

Also note that if the cofactor is small, the total number of Y values that could cause Step 2 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:

  1. PK_string = point_to_string(Y)
  2. oneTwentySeven_string = 0x7F
  3. y_string[31] = y_string[31] & oneTwentySeven_string

    (this step clears the high-order bit of octet 31)

  4. bad_pk[0] = int_to_string(0, 32)
  5. bad_pk[1] = int_to_string(1, 32)
  6. bad_y2 = 2707385501144840649318225287225658788936804267575313519463743609750303402022
  7. bad_pk[2] = int_to_string(bad_y2, 32)
  8. bad_pk[3] = int_to_string(p-bad_y2, 32)
  9. bad_pk[4] = int_to_string(p-1, 32)
  10. bad_pk[5] = int_to_string(p, 32)
  11. bad_pk[6] = int_to_string(p+1, 32)
  12. If y_string is in the list [bad_pk[0],...,bad_pk[6]], output "INVALID" and stop
  13. Output Y

(bad_pk[0], bad_pk[2], bad_pk[3] each match two bad public keys, depending on the sign of the x-coordinate, 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 x-coordinate 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 y-coordinate 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 [X25519] to Edwards coordinates.)

5.5. ECVRF Ciphersuites

This document defines ECVRF-P256-SHA256-TAI as follows:

  • suite_string = 0x01.
  • The EC group G is the NIST P-256 elliptic curve, with curve parameters as specified in [FIPS-186-4] (Section D.1.2.3) and [RFC5114] (Section 2.6). For this group, fLen = qLen = 32 and cofactor = 1.
  • cLen = 16.
  • The key pair generation primitive is specified in Section 3.2.1 of [SECG1] (q, B, SK, and Y in this document correspond to n, G, d, and Q in Section 3.2.1 of [SECG1]). In this ciphersuite, the secret scalar x is equal to the private key SK.
  • encode_to_curve_salt = PK_string
  • The ECVRF_nonce_generation function is as specified in Section 5.4.2.1.
  • The int_to_string function is the I2OSP function specified in Section 4.1 of [RFC8017]. (This is big-endian representation.)
  • The string_to_int function is the OS2IP function specified in Section 4.2 of [RFC8017]. (This is big-endian 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 [SECG1] with point compression on. This implies 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 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 a point on E according to the encoding specified in Section 2.3.4 of [SECG1]. This function MUST output INVALID if the octet string does not decode to a point on the curve E.
  • The hash function Hash is SHA-256 as specified in [RFC6234], with hLen = 32.
  • The ECVRF_encode_to_curve function is as specified in Section 5.4.1.1, with interpret_hash_value_as_a_point(s) = string_to_point(0x02 || s).

This document defines ECVRF-P256-SHA256-SSWU as identical to ECVRF-P256-SHA256-TAI, except that:

This document defines ECVRF-EDWARDS25519-SHA512-TAI as follows:

  • suite_string = 0x03.
  • The EC group G is the edwards25519 elliptic curve with parameters defined in Table 1 of [RFC8032]. For this group, fLen = qLen = 32 and cofactor = 8.
  • cLen = 16.
  • The private key and generation of the secret scalar and the public key are specified in Section 5.1.5 of [RFC8032].
  • encode_to_curve_salt = PK_string
  • The ECVRF_nonce_generation function is as specified in Section 5.4.2.2.
  • The int_to_string function as specified in the first paragraph of Section 5.1.2 of [RFC8032]. (This is little-endian representation.)
  • The string_to_int function interprets the string as an integer in little-endian representation.
  • The point_to_string function converts an point on E to an octet string according to the encoding specified in Section 5.1.2 of [RFC8032]. This implies 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 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 a point on E according to the encoding specified in Section 5.1.3 of [RFC8032]. This function MUST output INVALID if the octet string does not decode to a point on the curve E.
  • The hash function Hash is SHA-512 as specified in [RFC6234], with hLen = 64.
  • The ECVRF_encode_to_curve function is as specified in Section 5.4.1.1, with interpret_hash_value_as_a_point(s) = string_to_point(s[0]...s[31]).

This document defines ECVRF-EDWARDS25519-SHA512-ELL2 as identical to ECVRF-EDWARDS25519-SHA512-TAI, except:

6. Implementation Status

Note to RFC editor: Remove before publication

A reference C++ implementation of ECVRF-P256-SHA256-TAI, ECVRF-P256-SHA256-SSWU, ECVRF-EDWARDS25519-SHA512-TAI, and ECVRF-EDWARDS25519-SHA512-ELL2 is available at https://github.com/reyzin/ecvrf. This implementation is neither secure nor especially efficient, but can be used to generate test vectors.

A Python implementation of an older version of ECVRF-EDWARDS25519-SHA512-ELL2 from the -05 version of this draft is available at https://github.com/integritychain/draft-irtf-cfrg-vrf-05.

A C implementation of an older version of ECVRF-EDWARDS25519-SHA512-ELL2 from the -03 version of this draft is available at https://github.com/algorand/libsodium/tree/draft-irtf-cfrg-vrf-03/src/libsodium/crypto_vrf/ietfdraft03.

A Rust implementation of an older version of ECVRF-P256-SHA256-TAI from the -05 version of this draft, as well as variants for the sect163k1 and secp256k1 curves, is available at https://crates.io/crates/vrf.

A C implementation of a variant of ECVRF-P256-SHA256-TAI from the -05 version of this draft adapted for the secp256k1 curve is available at https://github.com/aergoio/secp256k1-vrf.

An implementation of an earlier version of RSA-FDH-VRF (SHA-256) and ECVRF-P256-SHA256-TAI was first developed as a part of the NSEC5 project [I-D.vcelak-nsec5] and is available at http://github.com/fcelda/nsec5-crypto.

The Key Transparency project at Google uses a VRF implementation that is similar to the ECVRF-P256-SHA256-TAI, with a few changes including the use of SHA-512 instead of SHA-256. Its implementation is available at https://github.com/google/keytransparency/blob/master/core/crypto/vrf/

An implementation by Ryuji Ishiguro following an older version of ECVRF-EDWARDS25519-SHA512-TAI from the -00 version of this draft is available at https://github.com/r2ishiguro/vrf.

An implementation similar to ECVRF-EDWARDS25519-SHA512-ELL2 (with some changes, including the use of SHA-3) is available as part of the CONIKS implementation in Golang at https://github.com/coniks-sys/coniks-go/tree/master/crypto/vrf.

Open Whisper Systems also uses a VRF similar to ECVRF-EDWARDS25519-SHA512-ELL2, called VXEdDSA, and specified here https://whispersystems.org/docs/specifications/xeddsa/ and here https://moderncrypto.org/mail-archive/curves/2017/000925.html. Implementations in C and Java are available at https://github.com/signalapp/curve25519-java and https://github.com/wavesplatform/curve25519-java.

7. Security Considerations

7.1. Key Generation

Applications that use the VRFs defined in this document MUST ensure that the VRF key is generated correctly, using good randomness.

7.1.1. Uniqueness and collision resistance with untrusted keys

The RSA-FDH-VRF satisfies the "trusted uniqueness" (see Section 3.1) and "trusted collision resistance" (see Section 3.2) properties as long as the VRF keys are generated correctly. 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 not in compliance with the stadnard); thus, RSA-FDH-VRF defined in this document does not have "full uniqueness" and "full collision resistance". Therefore, if adversarial key generation is a concern, the RSA-FDH-VRF has to be enhanced by additional cryptographic checks that its public key has the right form. These enhacements are left for future specification.

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 the "full uniqueness" (see Section 3.1) and "trusted collision resistance" (see Section 3.2) properties. It additonally satisfies "full collision resistance" if validate_key parameter given to the ECVRF_verify is TRUE.

7.1.2. 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.

7.2. Security Levels

As shown in [PWHVNRG17], RSA-FDH-VRF satifies the trusted uniqueness property unconditionally. The security level of the RSA-FDH-VRF, 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 [PWHVNRG17]).
  • For selective pseudorandomness: approximately as strong as the security, in bits, of the RSA problem for the key (n, e) (as shown in [GNPRVZ15]).

As shown in [PWHVNRG17], 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 trusted uniqueness: approximately 8*min(qLen, cLen).
  • For collision resistance (trusted or full, depending on whether validation is performed as explained in Section 7.1.1): approximately 8*min(qLen/2, hLen/2).
  • For the selective pseudorandomness property: approximately as strong as the security, in bits, of the decisional Diffie-Hellman problem in the group G (which is at most 8*qLen/2).

See Section 3 for the definitions of these security properties. See Section 7.3 for the discussion of full pseudorandomness.

7.3. Selective vs. Full Pseudorandomness

[PWHVNRG17] presents cryptographic reductions to an underlying hard problem (namely, the RSA problem for RSA-FDH-VRF and the Decisional Diffie-Hellman problem for the ECVRF) to prove that the VRFs specified in this document possess not only selective pseudorandomness, but also full pseudorandomness (see Section 3.3 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 Section 7.2) by subtracting the binary logarithm of the number of proofs produced for a given secret key. This holds for both the RSA-FDH-VRF 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. Such applications may consider the following 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.
  • They may increase security parameters to make up for the loose security reduction. For RSA-FDH-VRF, this means increasing the RSA key length. For ECVRF, this means increasing the cryptographic strength of the EC group G by specifying a new ciphersuite.

7.4. 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 Section 5.5 are designed with this requirement in mind.

7.5. Side-channel attacks

Side channel attacks on cryptographic primitives are an important issue. Implementers should take care to avoid side-channel 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_encode_to_curve_try_and_increment algorithm defined in Section 5.4.1.1 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 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.

ECVRF-P256-SHA256-SSWU and ECVRF-EDWARDS25519-SHA512-ELL2 can be made to run in time independent of alpha, following recommendations in [I-D.irtf-cfrg-hash-to-curve].

7.6. 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.

7.7. Prehashing

The VRFs specified in this document allow for read-once access to the input alpha for both signing and verifying. Thus, additional prehashing of alpha (as specified, for example, in [RFC8032] for EdDSA signatures) is not needed, even for applications that need to handle long alpha or to support the Initialize-Update-Finalize (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.

7.8. Hash function domain separation

Hashing is used for different purposes in the two VRFs (namely, in the RSA-FDH-VRF, in MGF1 and in proof_to_hash; in the ECVRF, 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 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 RSA-FDH-VRF defined in this document, because the second 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 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 input to the hash function used in proof_to_hash, challenge_generation, and encode_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_encode_to_curve_h2c_suite, which is set equal to the nonzero length of the domain separation tag by [I-D.irtf-cfrg-hash-to-curve].

7.9. Hash function salting

In case 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 RSA-FDH-VRF and ECVRF_encode_to_curve function for the ECVRF use a public value in addition to alpha (as a so-called 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 Section 7.10) MAY use a different salt. For example, if a group of public keys to share the same salt, then the hash of the VRF input alpha will be the same for the entire group of public keys, which may aid in some protocol that uses the VRF.

7.10. Futureproofing

if future designs need to specify variants (e.g., additional ciphersuites) of the RSA-FDH-VRF or the ECVRF 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 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 in this document. Then, for the RSA-FDH-VRF, the inputs to the hash function used in MGF1 and proof_to_hash will be different from other ciphersuites. For the ECVRF, the inputs 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.

8. Change Log

Note to RFC Editor: if this document does not obsolete an existing RFC, please remove this appendix before publication as an RFC.

9. Contributors

This document also would not be possible without the work of Moni Naor, Sachin Vasant, and Asaf Ziv. Chloe Martindale provided a thorough cryptographer's review. Liliya Akhmetzyanova, Tony Arcieri, Gary Belvin, Mario Cao Cueto, Brian Chen, Sergey Gorbunov, Shumon Huque, Gorka Irazoqui Apecechea, Marek Jankowski, Burt Kaliski, David C. Lawerence, Derek Ting-Haye Leung, Antonio Marcedone, Piotr Nojszewski, Chris Peikert, Trevor Perrin, Sam Scott, Stanislav Smyshlyaev, Adam Suhl, Nick Sullivan, Christopher Wood, Jiayu Xu, and Annie Yousar provided valuable input to this draft. Riad Wahby helped this document align with draft-irtf-cfrg-hash-to-curve.

10. References

10.1. Normative References

[RFC2119]
Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, , <https://www.rfc-editor.org/info/rfc2119>.
[RFC8017]
Moriarty, K., Ed., Kaliski, B., Jonsson, J., and A. Rusch, "PKCS #1: RSA Cryptography Specifications Version 2.2", RFC 8017, DOI 10.17487/RFC8017, , <https://www.rfc-editor.org/info/rfc8017>.
[RFC5114]
Lepinski, M. and S. Kent, "Additional Diffie-Hellman Groups for Use with IETF Standards", RFC 5114, DOI 10.17487/RFC5114, , <https://www.rfc-editor.org/info/rfc5114>.
[RFC6234]
Eastlake 3rd, D. and T. Hansen, "US Secure Hash Algorithms (SHA and SHA-based HMAC and HKDF)", RFC 6234, DOI 10.17487/RFC6234, , <https://www.rfc-editor.org/info/rfc6234>.
[RFC8032]
Josefsson, S. and I. Liusvaara, "Edwards-Curve Digital Signature Algorithm (EdDSA)", RFC 8032, DOI 10.17487/RFC8032, , <https://www.rfc-editor.org/info/rfc8032>.
[RFC6979]
Pornin, T., "Deterministic Usage of the Digital Signature Algorithm (DSA) and Elliptic Curve Digital Signature Algorithm (ECDSA)", RFC 6979, DOI 10.17487/RFC6979, , <https://www.rfc-editor.org/info/rfc6979>.
[I-D.irtf-cfrg-hash-to-curve]
Faz-Hernandez, A., Scott, S., Sullivan, N., Wahby, R. S., and C. A. Wood, "Hashing to Elliptic Curves", Work in Progress, Internet-Draft, draft-irtf-cfrg-hash-to-curve-13, , <https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-13>.
[FIPS-186-4]
National Institute for Standards and Technology, "Digital Signature Standard (DSS)", FIPS PUB 186-4, , <https://csrc.nist.gov/publications/detail/fips/186/4/final>.
[SECG1]
Standards for Efficient Cryptography Group (SECG), "SEC 1: Elliptic Curve Cryptography", Version 2.0, , <http://www.secg.org/sec1-v2.pdf>.

10.2. Informative References

[ANSI.X9-62-2005]
"Public Key Cryptography for the Financial Services Industry: The Elliptic Curve Digital Signature Algorithm (ECDSA)", ANSI X9.62, .
[DGKR18]
David, B., Gazi, P., Kiayias, A., and A. Russell, "Ouroboros Praos: An adaptively-secure, semi-synchronous proof-of-stake protocol", in Advances in Cryptology - EUROCRYPT, , <https://eprint.iacr.org/2017/573>.
[GHMVZ17]
Gilad, Y., Hemo, R., Micali, Y., Vlachos, Y., and Y. Zeldovich, "Algorand: Scaling Byzantine Agreements for Cryptocurrencies", in Proceedings of the 26th Symposium on Operating Systems Principles (SOSP), , <https://eprint.iacr.org/2017/454>.
[GNPRVZ15]
Goldberg, S., Naor, M., Papadopoulos, D., Reyzin, L., Vasant, S., and A. Ziv, "NSEC5: Provably Preventing DNSSEC Zone Enumeration", in NDSS, , <https://eprint.iacr.org/2014/582.pdf>.
[I-D.vcelak-nsec5]
Vcelak, J., Goldberg, S., Papadopoulos, D., Huque, S., and D. C. Lawrence, "NSEC5, DNSSEC Authenticated Denial of Existence", Work in Progress, Internet-Draft, draft-vcelak-nsec5-08, , <https://datatracker.ietf.org/doc/html/draft-vcelak-nsec5-08>.
[MRV99]
Micali, S., Rabin, M., and S. Vadhan, "Verifiable Random Functions", in FOCS, , <https://dash.harvard.edu/handle/1/5028196>.
[PWHVNRG17]
Papadopoulos, D., Wessels, D., Huque, S., Vcelak, J., Naor, M., Reyzin, L., and S. Goldberg, "Making NSEC5 Practical for DNSSEC", in ePrint Cryptology Archive 2017/099, , <https://eprint.iacr.org/2017/099>.
[X25519]
Bernstein, D.J., "How do I validate Curve25519 public keys?", , <https://cr.yp.to/ecdh.html#validate>.

Appendix A. Test Vectors for the ECVRFs

The test vectors in this section were generated using the reference implementation at https://github.com/reyzin/ecvrf.

A.1. ECVRF-P256-SHA256-TAI

The example secret keys and messages in Examples 1 and 2 are taken from Appendix A.2.5 of [RFC6979].

Example 1:

Example 2:

The example secret key in Example 3 is taken from Appendix L.4.2 of [ANSI.X9-62-2005].

Example 3:

A.2. ECVRF-P256-SHA256-SSWU

The example secret keys and messages in Examples 4 and 5 are taken from Appendix A.2.5 of [RFC6979].

Example 4:

Example 5:

The example secret key in Example 6 is taken from Appendix L.4.2 of [ANSI.X9-62-2005].

Example 6:

A.3. ECVRF-EDWARDS25519-SHA512-TAI

The example secret keys and messages in Examples 7, 8, and 9 are taken from Section 7.1 of [RFC8032].

Example 7:

Example 8:

Example 9:

A.4. ECVRF-EDWARDS25519-SHA512-ELL2

The example secret keys and messages in Examples 10, 11, and 12 are taken from Section 7.1 of [RFC8032].

Example 10:

Example 11:

Example 12:

Authors' Addresses

Sharon Goldberg
Boston University
111 Cummington Mall
Boston, MA 02215
United States of America
Leonid Reyzin
Boston University and Algorand
111 Cummington Mall
Boston, MA 02215
United States of America
Dimitrios Papadopoulos
Hong Kong University of Science and Technology
Clearwater Bay
Hong Kong
Jan Vcelak
NS1
16 Beaver St
New York, NY 10004
United States of America