-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdraft-irtf-cfrg-vrf.xml
2208 lines (2109 loc) · 137 KB
/
draft-irtf-cfrg-vrf.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE rfc [
<!ENTITY nbsp " ">
<!ENTITY zwsp "​">
<!ENTITY nbhy "‑">
<!ENTITY wj "⁠">
]>
<?rfc toc="yes"?>
<?rfc symrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<?rfc strict="no"?>
<?rfc rfcedstyle="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" category="info" docName="draft-irtf-cfrg-vrf-15" ipr="trust200902" obsoletes="" updates="" submissionType="IETF" xml:lang="en" tocInclude="true" symRefs="true" version="3">
<!-- xml2rfc v2v3 conversion 3.11.1 -->
<front>
<title abbrev="VRF">Verifiable Random Functions (VRFs)</title>
<seriesInfo name="Internet-Draft" value="draft-irtf-cfrg-vrf-15"/>
<author fullname="Sharon Goldberg" initials="S." surname="Goldberg">
<organization>Boston University</organization>
<address>
<postal>
<street>111 Cummington Mall</street>
<city>Boston</city>
<region>MA</region>
<code>02215</code>
<country>USA</country>
</postal>
<email>[email protected]</email>
</address>
</author>
<author fullname="Leonid Reyzin" initials="L." surname="Reyzin">
<organization>Boston University and Algorand</organization>
<address>
<postal>
<street>111 Cummington Mall</street>
<city>Boston</city>
<region>MA</region>
<code>02215</code>
<country>USA</country>
</postal>
<email>[email protected]</email>
</address>
</author>
<author fullname="Dimitrios Papadopoulos" initials="D." surname="Papadopoulos">
<organization>Hong Kong University of Science and Technology</organization>
<address>
<postal>
<street>Clearwater Bay</street>
<country>Hong Kong</country>
</postal>
<email>[email protected]</email>
</address>
</author>
<author fullname="Jan Vcelak" initials="J." surname="Vcelak">
<organization>NS1</organization>
<address>
<postal>
<street>16 Beaver St</street>
<city>New York</city>
<region>NY</region>
<code>10004</code>
<country>USA</country>
</postal>
<email>[email protected]</email>
</address>
</author>
<date year="2022"/>
<workgroup>CFRG</workgroup>
<keyword>public key cryptography</keyword>
<keyword>hashing</keyword>
<keyword>authenticated denial</keyword>
<abstract>
<t>
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 hash-based data structures.
This document specifies VRF constructions based on RSA and elliptic curves that are secure in
the cryptographic random oracle model.
</t>
<t>
This document is a product of the Crypto Forum Research Group (CFRG) in the IRTF.
</t>
</abstract>
</front>
<middle>
<section anchor="intro" numbered="true" toc="default">
<name>Introduction</name>
<t>
A Verifiable Random Function
(VRF) <xref target="MRV99" format="default"/> 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.
</t>
<t>
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 secret key and uses the VRF hashing to
construct a hash-based data structure on the input data.
</t>
<t>
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.
</t>
<t>This document defines VRFs based on RSA and elliptic curves.
The choices of VRFs for inclusion into this document were based, in part, on synergy with existing RFCs and
commonly available implementations of individual components that are used within the VRFs.
</t>
<t>
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 Diffie-Hellman assumptions (and the trust in a particular choice of curve in case of elliptic curves). Differences in the security properties provided by the different options are discussed in <xref target="secdef" format="default"/> and <xref target="securitycons" format="default"/>.</t>
<t>
This document represents the consensus of the Crypto Forum Research Group (CFRG).
</t>
<!--
<t>
VRFs are used for this purpose to prevent zone content enumeration in
Domain Name System Security Extensions (DNSSEC) with NSEC5 Authenticated
Denial of Existence <xref target="I-D.vcelak-nsec5"/>.
</t>
-->
<section numbered="true" toc="default">
<name>Requirements</name>
<t>
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
<xref target="RFC8174" format="default"/>.
</t>
</section>
<section numbered="true" toc="default">
<name>Terminology</name>
<t>
The following terminology is used through this document:
</t>
<dl newline="false" spacing="normal">
<dt>SK:</dt>
<dd>
The secret key for the VRF. (Note: the secret key is also sometimes called "private key".)
</dd>
<dt>PK:</dt>
<dd>
The public key for the VRF.
</dd>
<dt>alpha or alpha_string:</dt>
<dd>
The input to be hashed by the VRF.
</dd>
<dt>beta or beta_string:</dt>
<dd>
The VRF hash output.
</dd>
<dt>pi or pi_string:</dt>
<dd>
The VRF proof.
</dd>
<dt>Prover:</dt>
<dd>
The Prover holds the VRF secret key SK and public key PK.
</dd>
<dt>Verifier:</dt>
<dd>
The Verifier holds the VRF public key PK.
</dd>
<dt>Adversary:</dt>
<dd>
Potential attacker; often used to define a security property.
</dd>
<dt>Malicious (or adversarial):</dt>
<dd>
Performed by an adversary.
</dd>
</dl>
</section>
</section>
<section numbered="true" toc="default">
<name>VRF Algorithms</name>
<t>
A VRF comes with a key generation algorithm that generates a VRF
public key PK and secret key SK.
</t>
<t>
The prover hashes an input alpha using the VRF secret key SK to obtain a VRF
hash output beta
</t>
<ul empty="true" spacing="normal">
<li> beta = VRF_hash(SK, alpha) </li>
</ul>
<t>
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).
</t>
<t>
The prover also uses the secret key SK to construct a
proof pi that beta is the correct hash output
</t>
<ul empty="true" spacing="normal">
<li>pi = VRF_prove(SK, alpha)</li>
</ul>
<t>
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:
</t>
<ul empty="true" spacing="normal">
<li> beta = VRF_proof_to_hash(pi)</li>
</ul>
<t>
Thus, for VRFs defined in this document, VRF_hash is defined as
</t>
<ul empty="true" spacing="normal">
<li> VRF_hash(SK, alpha) = VRF_proof_to_hash(VRF_prove(SK, alpha)),</li>
</ul>
<t>
and therefore this document will specify VRF_prove and VRF_proof_to_hash
rather than VRF_hash.
</t>
<t>
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
</t>
<ul empty="true" spacing="normal">
<li> VRF_verify(PK, alpha, pi)</li>
</ul>
<t>
that outputs (VALID, beta = VRF_proof_to_hash(pi)) if pi is valid,
and INVALID otherwise.
</t>
</section>
<section anchor="secdef" numbered="true" toc="default">
<name>VRF Security Properties</name>
<t> 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.
</t>
<section anchor="uniqueness" numbered="true" toc="default">
<name>Full Uniqueness</name>
<t> 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.
</t>
<t>
More precisely, "full uniqueness" means that an adversary cannot
find</t>
<ul spacing="normal">
<li>a VRF public key PK,</li>
<li>a VRF input alpha,</li>
<li>and two proofs pi1 and pi2</li>
</ul>
<t>such that</t>
<ul spacing="normal">
<li>VRF_verify(PK, alpha, pi1) outputs (VALID, beta1),</li>
<li>VRF_verify(PK, alpha, pi2) outputs (VALID, beta2),</li>
<li>and beta1 is not equal to beta2.</li>
</ul>
</section>
<section anchor="collisionresistance" numbered="true" toc="default">
<name>Full Collison Resistance</name>
<t>Like cryptographic hash functions, VRFs are collision resistant. Collison resistance means
that it is infeasible to find two different inputs alpha1 and alpha2 with the same
output beta.
</t>
<t>
More precisely, "full collision resistance" means that an adversary cannot
find</t>
<ul spacing="normal">
<li>a VRF public key PK,</li>
<li>two VRF inputs alpha1 and alpha2 that are not equal to each other,</li>
<li>and two proofs pi1 and pi2</li>
</ul>
<t>such that</t>
<ul spacing="normal">
<li>VRF_verify(PK, alpha1, pi1) outputs (VALID, beta1),</li>
<li>VRF_verify(PK, alpha2, pi2) outputs (VALID, beta2),</li>
<li>and beta1 is equal to beta2.</li>
</ul>
</section>
<section anchor="trustedversions" numbered="true" toc="default">
<name>Trusted Uniqueness and Trusted Collision Resistance</name>
<t>
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, called "trusted uniqueness"
and "trusted collision resistance".
These properties 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 the knowledge of SK and PK, but not guaranteed to hold if the adversary has the ability to choose SK and PK.
</t>
<t>
As further discussed in <xref target="untrustedkeys" format="default"/>,
some 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.
</t>
</section>
<section anchor="pseudodef" numbered="true" toc="default">
<name>Full Pseudorandomness or Selective Pseudorandomness</name>
<t> Pseudorandomness ensures that when someone who does not know SK sees
a VRF hash output beta without its corresponding VRF proof pi,
then beta is indistinguishable from a random value.
</t>
<t> More precisely, suppose 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).
</t>
<t>
"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'.
</t>
<t>
"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.
</t>
<t>
As further discussed in <xref target="prsecurity" format="default"/>,
VRFs specified in this document satisfy both full pseudorandomness and selective pseudorandomness,
but their quantitative security against the selective pseudorandomness attack is stronger.
</t>
<t>
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).
</t>
<t> 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 whether VRF_verify(PK, alpha, pi) returns (VALID, beta).
</t>
<t>
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.)
</t>
</section>
<section anchor="unpreddef" numbered="true" toc="default">
<name>Unpredictability Under Malicious Key Generation</name>
<t>As explained in <xref target="pseudodef" format="default"/>, pseudorandomness cannot hold against malicious key generation.
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.
</t>
<t>There is, however, a different type of unpredictability that is desirable in certain VRF applications (such as leader selection in the consensus protocols of <xref target="GHMVZ17" format="default"/> and <xref target="DGKR18" format="default"/>), 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.
</t>
<t>
A formal definition of this property appears in Section 3.2 of <xref target="DGKR18" format="default"/>. As further discussed in <xref target="unpredres" format="default"/>, only some VRFs specified in this document satisfy this property.
</t>
</section>
</section>
<section anchor="fdh" numbered="true" toc="default">
<name>RSA Full Domain Hash VRF (RSA-FDH-VRF)</name>
<t>
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 <xref target="secdef" format="default"/>, as further discussed in <xref target="securitycons" format="default"/>.
Its security follows from the
standard RSA assumption in the random oracle model. Formal
security proofs are in <xref target="PWHVNRG17" format="default"/>.
</t>
<t>
The VRF computes the proof pi as a deterministic RSA signature on
input alpha using the RSA Full Domain Hash Algorithm
<xref target="RFC8017" format="default"/> 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.
</t>
<t>
The key pair for RSA-FDH-VRF MUST be generated in a way that it satisfies
the conditions specified in Section 3 of <xref target="RFC8017" format="default"/>.
</t>
<t>
In this section, the notation from <xref target="RFC8017" format="default"/> is used.
</t>
<t>
Parameters used:
</t>
<ul empty="true" spacing="normal">
<!-- do not change the names, these are from RFC8017 -->
<li>(n, e) - RSA public key</li>
<li>K - RSA private key (its representation is implementation-dependent)</li>
<li>k - length in octets of the RSA modulus n (k must be less than 2^32)</li>
</ul>
<t>
Fixed options (specified in <xref target="rsavrfSuites" format="default"/>):
</t>
<ul empty="true" spacing="normal">
<li>Hash - cryptographic hash function</li>
<li>hLen - output length in octets of hash function Hash</li>
<li>suite_string - an octet string specifying the RSA-FDH-VRF
ciphersuite, which determines the above options</li>
</ul>
<t>
Primitives used:
</t>
<ul empty="true" spacing="normal">
<li>
I2OSP - Conversion of a nonnegative integer to an octet string as defined in
Section 4.1 of <xref target="RFC8017" format="default"/>
(given an integer and a length in octets, produces a big-endian representation of the integer, zero-padded to the desired length)
</li>
<li>
OS2IP - Conversion of an octet string to a nonnegative integer as defined in
Section 4.2 of <xref target="RFC8017" format="default"/>
(given a big-endian encoding of an integer, produces the integer)
</li>
<li>
RSASP1 - RSA signature primitive as defined in
Section 5.2.1 of <xref target="RFC8017" format="default"/> (given a private key and an input, raises the input to the private RSA exponent modulo n)
</li>
<li>
RSAVP1 - RSA verification primitive as defined in
Section 5.2.2 of <xref target="RFC8017" format="default"/> (given a public key and an input, raises the input to the public RSA exponent modulo n)
</li>
<li>
MGF1 - Mask Generation Function based on the hash function Hash as defined in
Section B.2.1 of <xref target="RFC8017" format="default"/> (given an input, produces a random-oracle-like output of desired length)
</li>
<li>
|| - octet string concatenation
</li>
</ul>
<section numbered="true" toc="default">
<name>RSA-FDH-VRF Proving</name>
<t>
RSAFDHVRF_prove(K, alpha_string[, MGF_salt])
</t>
<t>
Input:
</t>
<ul empty="true" spacing="normal">
<li>K - RSA private key</li>
<li>alpha_string - VRF hash input, an octet string</li>
</ul>
<t>
Optional Input:
</t>
<ul empty="true" spacing="normal">
<li>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</li>
</ul>
<t>
Output:
</t>
<ul empty="true" spacing="normal">
<li>pi_string - proof, an octet string of length k</li>
</ul>
<t>
Steps:
</t>
<ol spacing="normal" type="1"><li>mgf_domain_separator = 0x01</li>
<li>EM = MGF1(suite_string || mgf_domain_separator || MGF_salt || alpha_string, k - 1)</li>
<li>m = OS2IP(EM)</li>
<li>s = RSASP1(K, m)</li>
<li>pi_string = I2OSP(s, k)</li>
<li>Output pi_string</li>
</ol>
</section>
<section numbered="true" toc="default">
<name>RSA-FDH-VRF Proof to Hash</name>
<t>
RSAFDHVRF_proof_to_hash(pi_string)
</t>
<t>
Input:
</t>
<ul empty="true" spacing="normal">
<li>pi_string - proof, an octet string of length k</li>
</ul>
<t>
Output:
</t>
<ul empty="true" spacing="normal">
<li>beta_string - VRF hash output, an octet string of length hLen</li>
</ul>
<t>
Important note:
</t>
<ul empty="true" spacing="normal">
<li>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 <xref target="rsaverify" format="default"/>.</li>
</ul>
<t>
Steps:
</t>
<ol spacing="normal" type="1"><li>proof_to_hash_domain_separator = 0x02</li>
<li>beta_string = Hash(suite_string || proof_to_hash_domain_separator || pi_string)</li>
<li>Output beta_string</li>
</ol>
</section>
<section anchor="rsaverify" numbered="true" toc="default">
<name>RSA-FDH-VRF Verifying</name>
<t>
RSAFDHVRF_verify((n, e), alpha_string, pi_string[, MGF_salt])
</t>
<t>
Input:
</t>
<ul empty="true" spacing="normal">
<li>(n, e) - RSA public key</li>
<li>alpha_string - VRF hash input, an octet string</li>
<li>pi_string - proof to be verified, an octet string of length k</li>
</ul>
<t>
Optional Input:
</t>
<ul empty="true" spacing="normal">
<li>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</li>
</ul>
<t>
Output:
</t>
<t>
Output:
</t>
<ul empty="true" spacing="normal">
<li>
<t>("VALID", beta_string), where beta_string is the VRF hash output, an octet string of length hLen; or
</t>
<t>"INVALID"</t>
</li>
</ul>
<t>
Steps:
</t>
<ol spacing="normal" type="1"><li>s = OS2IP(pi_string)</li>
<li>m = RSAVP1((n, e), s); if RSAVP1 returns "signature representative out of range", output "INVALID" and stop.</li>
<li>mgf_domain_separator = 0x01</li>
<li>EM' = MGF1(suite_string || mgf_domain_separator || MGF_salt || alpha_string, k - 1)</li>
<li>m' = OS2IP(EM')</li>
<li>
If m and m' are equal, output ("VALID", RSAFDHVRF_proof_to_hash(pi_string));
else output "INVALID".
</li>
</ol>
</section>
<section anchor="rsavrfSuites" numbered="true" toc="default">
<name>RSA-FDH-VRF Ciphersuites</name>
<t>This document defines RSA-FDH-VRF-SHA256 as follows:</t>
<ul spacing="normal">
<li>suite_string = 0x01</li>
<li>The hash function Hash is SHA-256 as specified in <xref target="RFC6234" format="default"/>, with hLen = 32</li>
<li>MGF_salt = I2OSP(k, 4) || I2OSP(n, k)</li>
</ul>
<t>This document defines RSA-FDH-VRF-SHA384 as follows:</t>
<ul spacing="normal">
<li>suite_string = 0x02</li>
<li>The hash function Hash is SHA-384 as specified in <xref target="RFC6234" format="default"/>, with hLen = 48</li>
<li>MGF_salt = I2OSP(k, 4) || I2OSP(n, k)</li>
</ul>
<t>This document defines RSA-FDH-VRF-SHA512 as follows:</t>
<ul spacing="normal">
<li>suite_string = 0x03</li>
<li>The hash function Hash is SHA-512 as specified in <xref target="RFC6234" format="default"/>, with hLen = 64</li>
<li>MGF_salt = I2OSP(k, 4) || I2OSP(n, k)</li>
</ul>
</section>
</section>
<section anchor="ecvrf" numbered="true" toc="default">
<name>Elliptic Curve VRF (ECVRF)</name>
<t>
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 <xref target="secdef" format="default"/>.
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 <xref target="securitycons" format="default"/>
for further discussion. Formal security proofs are
in <xref target="PWHVNRG17" format="default"/>.
</t>
<t>
Notation used:
</t>
<ul empty="true" spacing="normal">
<li>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</li>
<li>x^y - x raised to the power y</li>
<li>x*y - x multiplied by y</li>
<li>s || t - concatenation of octet strings s and t</li>
<li>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.</li>
</ul>
<t>
Fixed options (specified in <xref target="ecvrfSuites" format="default"/>):
</t>
<ul empty="true" spacing="normal">
<li>F - finite field</li>
<li>fLen - length, in octets, of an element in F encoded as an octet string</li>
<li>E - elliptic curve (EC) defined over F</li>
<li>ptLen - length, in octets, of a point on E encoded as an octet string</li>
<li>G - subgroup of E of large prime order</li>
<li>q - prime order of group G</li>
<li>qLen - length of q in octets, i.e., smallest integer such that 2^(8qLen)>q</li>
<li>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)</li>
<li>cofactor - number of points on E divided by q</li>
<li>B - generator of group G</li>
<li>Hash - cryptographic hash function</li>
<li>hLen - output length in octets of Hash (hLen must be at least cLen; in the typical case, it is at least qLen)</li>
<li>ECVRF_encode_to_curve - a function that hashes strings to points on E.</li>
<li>ECVRF_nonce_generation - a function that derives a pseudorandom nonce
from SK and the input as part of ECVRF proving.</li>
<li>suite_string - an octet string specifying the ECVRF
ciphersuite, which determines the above options as well as type conversions and parameter generation </li>
</ul>
<t>
Type conversions (specified in <xref target="ecvrfSuites" format="default"/>):
</t>
<ul empty="true" spacing="normal">
<li>int_to_string(a, len) - conversion of nonnegative integer a
to octet string of length len</li>
<li> string_to_int(a_string) - conversion of an octet string a_string
to a nonnegative integer</li>
<li>point_to_string - conversion of a point on E to an ptLen-octet string</li>
<li>string_to_point - conversion of an ptLen-octet 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.</li>
<li>
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.
</li>
</ul>
<t>
Parameters used (the generation of these parameters is specified in <xref target="ecvrfSuites" format="default"/>):
</t>
<ul empty="true" spacing="normal">
<li>SK - VRF secret key</li>
<li>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
</li>
<li>Y = x*B - VRF public key, an point on E</li>
<li>PK_string = point_to_string(Y) - VRF public key represented as an octet string</li>
<li>encode_to_curve_salt - a public value used as a hash function salt</li>
</ul>
<section anchor="ecvrfprove" numbered="true" toc="default">
<name>ECVRF Proving</name>
<t>
ECVRF_prove(SK, alpha_string[, encode_to_curve_salt])
</t>
<t>
Input:
</t>
<ul empty="true" spacing="normal">
<li>SK - VRF secret key</li>
<li>alpha_string - input alpha, an octet string</li>
</ul>
<t>
Optional input:
</t>
<ul empty="true" spacing="normal">
<li>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</li>
</ul>
<t>
Output:
</t>
<ul empty="true" spacing="normal">
<li>pi_string - VRF proof, octet string of length ptLen+cLen+qLen</li>
</ul>
<t>
Steps:
</t>
<ol spacing="normal" type="1"><li>
<t>Use SK to derive the VRF secret scalar x and the VRF public key Y = x*B
</t>
<t>(this derivation depends on the ciphersuite, as per <xref target="ecvrfSuites" format="default"/>;
</t>
<t>these values can be cached, for example, after key generation, and need not be rederived each time)</t>
</li>
<li>H = ECVRF_encode_to_curve(encode_to_curve_salt, alpha_string) (see <xref target="ecvrfH2C" format="default"/>)</li>
<li>h_string = point_to_string(H)</li>
<li>Gamma = x*H</li>
<li>k = ECVRF_nonce_generation(SK, h_string) (see <xref target="ecvrfNonceGeneration" format="default"/>)</li>
<li>c = ECVRF_challenge_generation(Y, H, Gamma, k*B, k*H) (see <xref target="ecvrfChallengeGeneration" format="default"/>)</li>
<li>s = (k + c*x) mod q</li>
<li>pi_string = point_to_string(Gamma) || int_to_string(c, cLen) || int_to_string(s, qLen)</li>
<li>Output pi_string</li>
</ol>
</section>
<section numbered="true" toc="default">
<name>ECVRF Proof to Hash</name>
<t>
ECVRF_proof_to_hash(pi_string)
</t>
<t>
Input:
</t>
<ul empty="true" spacing="normal">
<li>pi_string - VRF proof, octet string of length ptLen+cLen+qLen</li>
</ul>
<t>
Output:
</t>
<ul empty="true" spacing="normal">
<li>"INVALID", or </li>
<li>beta_string - VRF hash output, octet string of length hLen</li>
</ul>
<t>
Important note:
</t>
<ul empty="true" spacing="normal">
<li>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 <xref target="ecverify" format="default"/>.</li>
</ul>
<t>
Steps:
</t>
<ol spacing="normal" type="1"><li>D = ECVRF_decode_proof(pi_string) (see <xref target="ecvrfDecodeProof" format="default"/>)</li>
<li>If D is "INVALID", output "INVALID" and stop</li>
<li>(Gamma, c, s) = D</li>
<li>proof_to_hash_domain_separator_front = 0x03</li>
<li>proof_to_hash_domain_separator_back = 0x00</li>
<li>beta_string = Hash(suite_string || proof_to_hash_domain_separator_front || point_to_string(cofactor * Gamma) || proof_to_hash_domain_separator_back)</li>
<li>Output beta_string</li>
</ol>
</section>
<section anchor="ecverify" numbered="true" toc="default">
<name>ECVRF Verifying</name>
<t>
ECVRF_verify(PK_string, alpha_string, pi_string[, encode_to_curve_salt, validate_key])
</t>
<t>
Input:
</t>
<ul empty="true" spacing="normal">
<li>PK_string - public key, an octet string</li>
<li>alpha_string - VRF input, octet string</li>
<li>pi_string - VRF proof, octet string of length ptLen+cLen+qLen</li>
</ul>
<t>
Optional input:
</t>
<ul empty="true" spacing="normal">
<li>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</li>
<li>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.</li>
</ul>
<t>
Output:
</t>
<ul empty="true" spacing="normal">
<li>
<t>("VALID", beta_string), where beta_string is the VRF hash output, octet string of length hLen; or
</t>
<t> "INVALID"</t>
</li>
</ul>
<t>
Steps:
</t>
<ol spacing="normal" type="1">
<li>Y = string_to_point(PK_string)</li>
<li>If Y is "INVALID", output "INVALID" and stop</li>
<li>If validate_key, run ECVRF_validate_key(Y) (<xref target="keycheck" format="default"/>); if it outputs "INVALID", output "INVALID" and stop
</li>
<li>D = ECVRF_decode_proof(pi_string) (see <xref target="ecvrfDecodeProof" format="default"/>)</li>
<li>If D is "INVALID", output "INVALID" and stop</li>
<li>(Gamma, c, s) = D</li>
<li>H = ECVRF_encode_to_curve(encode_to_curve_salt, alpha_string) (see <xref target="ecvrfH2C" format="default"/>)</li>
<li>U = s*B - c*Y</li>
<li>V = s*H - c*Gamma</li>
<li>c' = ECVRF_challenge_generation(Y, H, Gamma, U, V) (see <xref target="ecvrfChallengeGeneration" format="default"/>)</li>
<li>
If c and c' are equal, output ("VALID", ECVRF_proof_to_hash(pi_string));
else output "INVALID"
</li>
</ol>
<t>Note that the first three steps need to be performed only once for a given public key.</t>
</section>
<section numbered="true" toc="default">
<name>ECVRF Auxiliary Functions</name>
<section anchor="ecvrfH2C" numbered="true" toc="default">
<name>ECVRF Encode to Curve</name>
<t>The ECVRF_encode_to_curve algorithm takes a public salt (see <xref target="salt" format="default"/>) 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
<xref target="prehash" format="default"/> for further discussion.
</t>
<t>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 <xref target="ecvrfSuites" format="default"/>.</t>
<t>
Input:
</t>
<ul empty="true" spacing="normal">
<li>encode_to_curve_salt - public salt value, an octet string</li>
<li>alpha_string - value to be hashed, an octet string</li>
</ul>
<t>
Output:
</t>
<ul empty="true" spacing="normal">
<li>H - hashed value, a point in G </li>
</ul>
<section anchor="ecvrfH2C1" numbered="true" toc="default">
<name>ECVRF_encode_to_curve_try_and_increment</name>
<t>
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.
</t>
<t>
The running time of this algorithm depends on alpha_string.
For the ciphersuites specified
in <xref target="ecvrfSuites" format="default"/>, this algorithm
is expected to find a valid curve point after approximately two attempts
(i.e., when ctr=1) on average.
</t>
<t>
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.
</t>
<t>
ECVRF_encode_to_curve_try_and_increment(encode_to_curve_salt, alpha_string)
</t>
<t>
Fixed option (specified in <xref target="ecvrfSuites" format="default"/>):
</t>
<ul empty="true" spacing="normal">
<li>interpret_hash_value_as_a_point - a function that attempts to convert a cryptographic hash value to a point on E; may output INVALID.</li>
</ul>
<t>
Steps:
</t>
<ol spacing="normal" type="1"><li>ctr = 0</li>
<li>encode_to_curve_domain_separator_front = 0x01</li>
<li>encode_to_curve_domain_separator_back = 0x00</li>
<li>H = "INVALID"</li>
<li>
<t>While H is "INVALID" or H is the identity element of the elliptic curve group:
</t>
<ol spacing="normal" type="a"><li>ctr_string = int_to_string(ctr, 1)</li>
<li>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)</li>
<li>H = interpret_hash_value_as_a_point(hash_string)</li>
<li>If H is not "INVALID" and cofactor > 1, set H = cofactor * H</li>
<li>ctr = ctr + 1</li>
</ol>
</li>
<li>Output H</li>
</ol>
<t>
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 <xref target="ecvrfSuites" format="default"/>
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.
</t>
</section>
<section anchor="h2csuite" numbered="true" toc="default">
<name>ECVRF_encode_to_curve_h2c_suite</name>
<t>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
<xref target="I-D.irtf-cfrg-hash-to-curve" format="default"/>.
The specific choice of the hash-to-curve option
(called Suite ID in <xref target="I-D.irtf-cfrg-hash-to-curve" format="default"/>)
is given by the h2c_suite_ID_string parameter.
</t>
<t>
ECVRF_encode_to_curve_h2c_suite(encode_to_curve_salt, alpha_string)
</t>
<t>
Fixed option (specified in <xref target="ecvrfSuites" format="default"/>):
</t>
<ul empty="true" spacing="normal">
<li>h2c_suite_ID_string - a hash-to-curve suite ID, encoded in ASCII (see discussion below)</li>
</ul>
<t>
Steps:
</t>
<ol spacing="normal" type="1">
<li>string_to_be_hashed = encode_to_curve_salt || alpha_string</li>
<li>
<t>H = encode(string_to_be_hashed)
</t>
<t>(the encode function is discussed below) </t>
</li>
<li>Output H</li>
</ol>
<t>The encode function is provided by the hash-to-curve suite whose ID is h2c_suite_ID_string, as specified in
<xref target="I-D.irtf-cfrg-hash-to-curve" format="default"/>, Section 8.
The domain separation tag DST, a parameter to the hash-to-curve suite, SHALL be set to
</t>
<ul empty="true" spacing="normal">
<li>
"ECVRF_" || h2c_suite_ID_string || suite_string
</li>
</ul>
<t>
where "ECVRF_" is represented as a 6-byte ASCII encoding (in hexadecimal, octets 45 43 56 52 46 5F).
</t>
</section>
</section>
<section anchor="ecvrfNonceGeneration" numbered="true" toc="default">
<name>ECVRF Nonce Generation</name>
<t>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 <xref target="ecvrfSuites" format="default"/>.</t>
<section anchor="nonceP256" numbered="true" toc="default">
<name>ECVRF Nonce Generation from RFC 6979</name>
<t>
ECVRF_nonce_generation_RFC6979(SK, h_string)
</t>
<t>
Input:
</t>
<ul empty="true" spacing="normal">
<li>SK - an ECVRF secret key</li>
<li>h_string - an octet string</li>
</ul>
<t>
Output:
</t>
<ul empty="true" spacing="normal">
<li>k - an integer nonce between 1 and q-1</li>
</ul>
<t>
The ECVRF_nonce_generation function is as specified in
<xref target="RFC6979" format="default"/> Section 3.2 where
</t>
<ul empty="true" spacing="normal">
<li> Input m is set equal to h_string</li>
<li> The "suitable for DSA or ECDSA" check in step h.3 is omitted</li>
<li> The hash function H is Hash and its output length hlen (in bits) is set as hLen*8</li>
<li> The secret key x is set equal to the VRF secret scalar x </li>
<li> The prime q is the same as in this specification</li>
<li> 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)</li>
<li> All the other values and primitives as defined in <xref target="RFC6979" format="default"/> </li>
</ul>
</section>
<section anchor="nonce25519" numbered="true" toc="default">
<name>ECVRF Nonce Generation from RFC 8032</name>
<t> The following is from Steps 2-3 of Section 5.1.6
in <xref target="RFC8032" format="default"/>. To use this algorithm, hLen MUST be at least 64.
</t>
<t>
ECVRF_nonce_generation_RFC8032(SK, h_string)
</t>
<t>
Input:
</t>
<ul empty="true" spacing="normal">
<li>SK - an ECVRF secret key</li>
<li>h_string - an octet string</li>
</ul>
<t>
Output:
</t>
<ul empty="true" spacing="normal">
<li>k - an integer nonce between 0 and q-1</li>
</ul>
<t>
Steps:
</t>