-
Notifications
You must be signed in to change notification settings - Fork 2
/
vrf.xml
1952 lines (1687 loc) · 92.1 KB
/
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="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
]>
<?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 category="std" docName="draft-irtf-cfrg-vrf-08" ipr="trust200902">
<front>
<title abbrev="VRF">Verifiable Random Functions (VRFs)</title>
<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>goldbe@cs.bu.edu</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>reyzin@bu.edu</email>
</address>
</author>
<author fullname="Dimitrios Papadopoulos" initials="D." surname="Papadopoulos">
<organization>Hong Kong University of Science and Techology</organization>
<address>
<postal>
<street>Clearwater Bay</street>
<country>Hong Kong</country>
</postal>
<email>dipapado@cse.ust.hk</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>jvcelak@ns1.com</email>
</address>
</author>
<date year="2020" />
<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 private key
can compute the hash, but anyone with public key
can verify the correctness of the hash.
VRFs are useful for preventing enumeration of hash-based data structures.
This document specifies several VRF constructions that are secure in
the cryptographic random oracle model. One VRF uses RSA and the other
VRF uses Eliptic Curves (EC).
</t>
</abstract>
</front>
<middle>
<section title="Introduction" anchor="intro">
<section title="Rationale">
<t>
A Verifiable Random Function
(VRF) <xref target="MRV99"></xref> 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 corresponding public key
can verify the correctness of the hash.
</t>
<t>
A key application of the VRF is to provide privacy against
offline enumeration (e.g. dictionary 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 strucuture.
</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>
<section title="Requirements">
<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="RFC2119" />.
</t>
</section>
<section title="Terminology">
<t>
The following terminology is used through this document:
</t>
<t>
<list style="hanging">
<t hangText="SK:">
The private key for the VRF.
</t>
<t hangText="PK:">
The public key for the VRF.
</t>
<t hangText="alpha or alpha_string:">
The input to be hashed by the VRF.
</t>
<t hangText="beta or beta_string:">
The VRF hash output.
</t>
<t hangText="pi or pi_string:">
The VRF proof.
</t>
<t hangText="Prover:">
The Prover holds the private VRF key SK and public VRF key PK.
</t>
<t hangText="Verifier:">
The Verifier holds the public VRF key PK.
</t>
</list>
</t>
</section>
</section>
<section title="VRF Algorithms">
<t>
A VRF comes with a key generation algorithm that generates a public VRF
key PK and private VRF key SK.
</t>
<t>
The prover hashes an input alpha using the private VRF key SK to obtain a VRF
hash output beta
<list>
<t> beta = VRF_hash(SK, alpha) </t>
</list>
The VRF_hash algorithm is deterministic, in
the sense that it always produces the same output beta given a
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
<list>
<t>pi = VRF_prove(SK, alpha)</t>
</list>
The VRFs defined in this document allow anyone to deterministically
obtain the VRF hash output beta directly from the proof value pi as
<list>
<t> beta = VRF_proof_to_hash(pi)</t>
</list>
Notice that this means that
<list>
<t> VRF_hash(SK, alpha) = VRF_proof_to_hash(VRF_prove(SK, alpha))</t>
</list>
and thus 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 VRF also comes with an algorithm
<list>
<t> VRF_verify(PK, alpha, pi)</t>
</list>
that outputs (VALID, beta = VRF_proof_to_hash(pi)) if pi is valid,
and INVALID otherwise.
</t>
</section>
<section title="VRF Security Properties" anchor="secdef">
<t> VRFs are designed to ensure the following security properties.
</t>
<section title= "Full Uniqueness or Trusted Uniqueness">
<t> 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.
</t>
<t>
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.
</t>
<t>
A slightly weaker security
property called "trusted uniqueness" sufficies for many applications.
Trusted uniqueness is the same as full uniqueness, but it must hold
only if the VRF keys PK and SK were generated in a trustworthy
manner. In other words, uniqueness might not hold if keys were
generated in an invalid manner or with bad randomness.
</t>
</section>
<section title="Full Collison Resistance or Trusted Collision Resistance">
<t>Like any cryprographic hash function, VRFs need to be
collision resistant. Collison resistance must hold
even for an adversarial Prover that knows the VRF private key SK.
</t>
<t> 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.
</t>
<t>
For most applications, a slightly weaker security property
called "trusted collision resistance" suffices.
Trusted collision resistance is the same as collision resistance,
but it holds only if PK and SK were generated in a trustworthy manner.
</t>
</section>
<section title="Full Pseudorandomness or Selective Pseudorandomness" anchor="pseudodef">
<t> 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.
</t>
<t> 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'.
</t>
<t>
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'.
</t>
<t>
"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.
</t>
<t>
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).
</t>
<t> Also, the VRF output beta does not look random to any party that
knows 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).
</t>
<t>
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.)
</t>
</section>
<section title="A random-oracle-like unpredictability property">
<t>Pseudorandomness, as defined in <xref target="pseudodef"/>, does not
hold if the VRF keys were generated adversarially. 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.
</t>
<t>There is, however, a different type of unpredictability that is desirable in certain VRF applications (such as <xref target="GHMVZ17" /> and <xref target="DGKR18" />). 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.
</t>
<t>
A formal definition of this property appears in Section 3.2 of <xref target="DGKR18" />. The VRF schemes presented in this specification are believed to satisfy this property if the public key was generated in a trustworthy
manner. Additionally, the ECVRF is believed to also satisify this property even if the public key was not generated in a trustworthy manner, as long as
the public key satisfies the key validation
procedure in <xref target="keycheck"/>.</t>
</section>
</section>
<section title="RSA Full Domain Hash VRF (RSA-FDH-VRF)" anchor="fdh">
<t>
The RSA Full Domain Hash VRF (RSA-FDH-VRF) is a VRF that satisfies
the "trusted uniqueness", "trusted
collision resistance", and "full pseudorandomness" properties defined in <xref target="secdef"/>.
Its security follows from the
standard RSA assumption in the random oracle model. Formal
security proofs are in <xref target="PWHVNRG17" />.
</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" /> 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" />.
</t>
<t>
In this document, the notation from <xref target="RFC8017" /> is used.
</t>
<t>
Parameters used:
<list>
<!-- do not change the names, these are from RFC8017 -->
<t>(n, e) - RSA public key</t>
<t>K - RSA private key</t>
<t>k - length in octets of the RSA modulus n (k must be less than 2^32)</t>
</list>
</t>
<t>
Fixed options:
<list>
<t>Hash - cryptographic hash function</t>
<t>hLen - output length in octets of hash function Hash</t>
</list>
</t>
<t>
Primitives used:
<list>
<t>
I2OSP - Conversion of a nonnegative integer to an octet string as defined in
Section 4.1 of <xref target="RFC8017" />
</t>
<t>
OS2IP - Conversion of an octet string to a nonnegative integer as defined in
Section 4.2 of <xref target="RFC8017" />
</t>
<t>
RSASP1 - RSA signature primitive as defined in
Section 5.2.1 of <xref target="RFC8017" />
</t>
<t>
RSAVP1 - RSA verification primitive as defined in
Section 5.2.2 of <xref target="RFC8017" />
</t>
<t>
MGF1 - Mask Generation Function based on the hash function Hash as defined in
Section B.2.1 of <xref target="RFC8017" />
</t>
<t>
|| - octet string concatenation
</t>
</list>
</t>
<section title="RSA-FDH-VRF Proving">
<t>
RSAFDHVRF_prove(K, alpha_string)
</t>
<t>
Input:
<list>
<t>K - RSA private key</t>
<t>alpha_string - VRF hash input, an octet string</t>
</list>
</t>
<t>
Output:
<list>
<t>pi_string - proof, an octet string of length k</t>
</list>
</t>
<t>
Steps:
<list style="numbers">
<t>one_string = 0x01 = I2OSP(1, 1), a single octet with value 1</t>
<t>EM = MGF1(one_string || I2OSP(k, 4) || I2OSP(n, k) || alpha_string, k - 1)</t>
<t>m = OS2IP(EM)</t>
<t>s = RSASP1(K, m)</t>
<t>pi_string = I2OSP(s, k)</t>
<t>Output pi_string</t>
</list>
</t>
</section>
<section title="RSA-FDH-VRF Proof To Hash">
<t>
RSAFDHVRF_proof_to_hash(pi_string)
</t>
<t>
Input:
<list>
<t>pi_string - proof, an octet string of length k</t>
</list>
</t>
<t>
Output:
<list>
<t>beta_string - VRF hash output, an octet string of length hLen</t>
</list>
</t>
<t>
Important note:
<list>
<t>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"/>.</t>
</list>
</t>
<t>
Steps:
<list style="numbers">
<t>two_string = 0x02 = I2OSP(2, 1), a single octet with value 2</t>
<t>beta_string = Hash(two_string || pi_string)</t>
<t>Output beta_string</t>
</list>
</t>
</section>
<section title="RSA-FDH-VRF Verifying" anchor = "rsaverify">
<t>
RSAFDHVRF_verify((n, e), alpha_string, pi_string)
</t>
<t>
Input:
<list>
<t>(n, e) - RSA public key</t>
<t>alpha_string - VRF hash input, an octet string</t>
<t>pi_string - proof to be verified, an octet string of length n</t>
</list>
</t>
<t>
Output:
<list>
<t>("VALID", beta_string), where beta_string is the VRF hash output, an octet string of length hLen; or
<vspace/>"INVALID"</t>
</list>
</t>
<t>
Steps:
<list style="numbers">
<t>s = OS2IP(pi_string)</t>
<t>m = RSAVP1((n, e), s)</t>
<t>EM = I2OSP(m, k - 1)</t>
<t>one_string = 0x01 = I2OSP(1, 1), a single octet with value 1</t>
<t>EM' = MGF1(one_string || I2OSP(k, 4) || I2OSP(n, k) || alpha_string, k - 1)</t>
<t>
If EM and EM' are equal, output ("VALID", RSAFDHVRF_proof_to_hash(pi_string));
else output "INVALID".
</t>
</list>
</t>
</section>
</section>
<section title="Elliptic Curve VRF (ECVRF)" anchor="ecvrf">
<t>
The Elliptic Curve Verifiable Random Function (ECVRF) is a VRF that
satisfies the trusted uniqueness, trusted collision resistance,
and full pseudorandomness properties defined in <xref target="secdef"/>.
The security of this VRF follows from the decisional
Diffie-Hellman (DDH) assumption in the random oracle model. Formal security proofs are
in <xref target="PWHVNRG17" />.
</t>
<t> To additionally satisfy "full uniqueness" and "full collision resistance",
the Verifier MUST additionally perform the validation procedure specified in
<xref target="keycheck"/> upon receipt of the public
VRF key.
</t>
<t>
Notation used:
<list>
<t>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</t>
<t>x^y - x raised to the power y</t>
<t>x*y - x multiplied by y</t>
<t>s || t - concatenation of octet strings s and t</t>
</list>
</t>
<t>
Fixed options (specified in <xref target="suites"/>):
<list>
<t>F - finite field</t>
<t>2n - length, in octets, of a field element in F, rounded up to the nearest even integer</t>
<t>E - elliptic curve (EC) defined over F</t>
<t>ptLen - length, in octets, of an EC point encoded as an octet string</t>
<t>G - subgroup of E of large prime order</t>
<t>q - prime order of group G</t>
<t>qLen - length of q in octets, i.e., smallest integer such that 2^(8qLen)>q (note that in the typical case, qLen equals 2n or is close to 2n)</t>
<t>cofactor - number of points on E divided by q</t>
<t>B - generator of group G</t>
<t>Hash - cryptographic hash function</t>
<t>hLen - output length in octets of Hash; must be at least 2n</t>
<t>ECVRF_hash_to_curve - a function that hashes strings to an EC point.</t>
<t>ECVRF_nonce_generation - a function that derives a pseudorandom nonce
from SK and the input as part of ECVRF proving.</t>
<t>suite_string - a single nonzero octet specifying the ECVRF
ciphersuite, which determines the above options as well as type conversions and parameter generation </t>
</list>
</t>
<t>
Type conversions (specified in <xref target="suites"/>):
<list>
<t>int_to_string(a, len) - conversion of nonnegative integer a to
to octet string of length len</t>
<t> string_to_int(a_string) - conversion of an octet string a_string
to a nonnegative integer</t>
<t>point_to_string - conversion of EC point to an ptLen-octet string</t>
<t>string_to_point - conversion of an ptLen-octet string to EC point.
string_to_point returns INVALID if the octet string does not convert to a valid EC point.</t>
<t>
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.
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.
</t>
</list>
</t>
<t>
Parameters used (the generation of these parameters is specified in <xref target="suites"/>):
<list>
<t>SK - VRF private key</t>
<t>x - VRF secret scalar, an integer
<list><t>
Note: depending on the ciphersuite used, the VRF secret scalar may be equal
to SK; else, it is derived from SK
</t></list>
</t>
<t>Y = x*B - VRF public key, an EC point</t>
</list>
</t>
<section title="ECVRF Proving" anchor="ecvrfprove">
<t>
ECVRF_prove(SK, alpha_string)
</t>
<t>
Input:
<list>
<t>SK - VRF private key</t>
<t>alpha_string = input alpha, an octet string</t>
</list>
</t>
<t>
Output:
<list>
<t>pi_string - VRF proof, octet string of length ptLen+n+qLen</t>
</list>
</t>
<t>
Steps:
<list style="numbers">
<t>Use SK to derive the VRF secret scalar x and the VRF public key Y = x*B
<vspace/>(this derivation depends on the ciphersuite, as per <xref target="suites"/>;
<vspace/>these values can be cached, for example, after key generation, and need not be rederived each time)</t>
<t>H = ECVRF_hash_to_curve(Y, alpha_string)</t>
<t>h_string = point_to_string(H)</t>
<t>Gamma = x*H</t>
<t>k = ECVRF_nonce_generation(SK, h_string)</t>
<t>c = ECVRF_hash_points(H, Gamma, k*B, k*H) (see <xref target="ecvrfHashPoints"/>)</t>
<t>s = (k + c*x) mod q</t>
<t>pi_string = point_to_string(Gamma) || int_to_string(c, n) || int_to_string(s, qLen)</t>
<t>Output pi_string</t>
</list>
</t>
</section>
<section title="ECVRF Proof To Hash">
<t>
ECVRF_proof_to_hash(pi_string)
</t>
<t>
Input:
<list>
<t>pi_string - VRF proof, octet string of length ptLen+n+qLen</t>
</list>
</t>
<t>
Output:
<list>
<t>"INVALID", or </t>
<t>beta_string - VRF hash output, octet string of length hLen</t>
</list>
</t>
<t>
Important note:
<list>
<t>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"/>.</t>
</list>
</t>
<t>
Steps:
<list style="numbers">
<t>D = ECVRF_decode_proof(pi_string) (see <xref target="ecvrfDecodeProof"/>)</t>
<t>If D is "INVALID", output "INVALID" and stop</t>
<t>(Gamma, c, s) = D</t>
<t>three_string = 0x03 = int_to_string(3, 1), a single octet with value 3 </t>
<t>zero_string = 0x00 = int_to_string(0, 1), a single octet with value 0 </t>
<t>beta_string = Hash(suite_string || three_string || point_to_string(cofactor * Gamma) || zero_string)</t>
<t>Output beta_string</t>
</list>
</t>
</section>
<section title="ECVRF Verifying" anchor="ecverify">
<t>
ECVRF_verify(Y, pi_string, alpha_string)
</t>
<t>
Input:
<list>
<t>Y - public key, an EC point</t>
<t>pi_string - VRF proof, octet string of length ptLen+n+qLen</t>
<t>alpha_string - VRF input, octet string</t>
</list>
</t>
<t>
Output:
<list>
<t>("VALID", beta_string), where beta_string is the VRF hash output, octet string of length hLen; or
<vspace/> "INVALID"</t>
</list>
</t>
<t>
Steps:
<list style="numbers">
<t>D = ECVRF_decode_proof(pi_string) (see <xref target="ecvrfDecodeProof"/>)</t>
<t>If D is "INVALID", output "INVALID" and stop</t>
<t>(Gamma, c, s) = D</t>
<t>H = ECVRF_hash_to_curve(Y, alpha_string)</t>
<t>U = s*B - c*Y</t>
<t>V = s*H - c*Gamma</t>
<t>c' = ECVRF_hash_points(H, Gamma, U, V) (see <xref target="ecvrfHashPoints"/>)</t>
<t>
If c and c' are equal, output ("VALID", ECVRF_proof_to_hash(pi_string));
else output "INVALID"
</t>
</list>
</t>
</section>
<section title="ECVRF Auxiliary Functions">
<section title="ECVRF Hash To Curve" anchor="ecvrfH2C">
<t>The ECVRF_hash_to_curve algorithm takes in the VRF input alpha
and converts it to H, an EC point in G.
This algorithm is the only place the VRF input alpha is used
for proving and verfying. See
<xref target="prehash" /> for further discussion.
</t>
<t>This section specifies a number of such algorithms, which are not compatible with each other. The choice of a particular algorithm from the options specified in this section is made in <xref target="suites"/>.</t>
<section title="ECVRF_hash_to_curve_try_and_increment" anchor="ecvrfH2C1">
<t>
The following ECVRF_hash_to_curve_try_and_increment(Y, alpha_string) algorithm
implements ECVRF_hash_to_curve in a simple and
generic way that works for any elliptic curve.
</t>
<t>
The running time of this algorithm depends on alpha_string.
For the ciphersuites specified
in <xref target="suites"/>, 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_hash_to_try_and_increment(Y, alpha_string)
</t>
<t>
Input:
<list>
<t>Y - public key, an EC point</t>
<t>alpha_string - value to be hashed, an octet string</t>
</list>
</t>
<t>
Output:
<list>
<t>H - hashed value, a finite EC point in G </t>
</list>
</t>
<t>
Fixed option (specified in <xref target="suites"/>):
<list>
<t>arbitrary_string_to_point - conversion of an arbitrary octet string to an
EC point.</t>
</list>
</t>
<t>
Steps:
<list style="numbers">
<t>ctr = 0</t>
<t>PK_string = point_to_string(Y)</t>
<t>one_string = 0x01 = int_to_string(1, 1), a single octet with value 1 </t>
<t>zero_string = 0x00 = int_to_string(0, 1), a single octet with value 0 </t>
<t>H = "INVALID"</t>
<t>While H is "INVALID" or H is EC point at infinity:
<list style="letters">
<t>ctr_string = int_to_string(ctr, 1)</t>
<t>hash_string = Hash(suite_string || one_string || PK_string || alpha_string || ctr_string || zero_string)</t>
<t>H = arbitrary_string_to_point(hash_string)</t>
<t>If H is not "INVALID" and cofactor > 1, set H = cofactor * H</t>
<t>ctr = ctr + 1</t>
</list></t>
<t>Output H</t>
</list>
</t>
</section>
<section title="ECVRF_hash_to_curve_h2c_suite" anchor="h2csuite">
<t>The ECVRF_hash_to_curve_h2c_suite(Y, alpha_string) algorithm
implements ECVRF_hash_to_curve using one of the several
hash-to-curve options defined in
<xref target="I-D.irtf-cfrg-hash-to-curve"/>.
The specific choice of the hash-to-curve option
(called Suite ID in <xref target="I-D.irtf-cfrg-hash-to-curve"/>)
is given by the h2c_suite_ID_string parameter.
</t>
<t>
ECVRF_hash_to_curve_h2c_suite(Y, alpha_string)
</t>
<t>
Input:
<list>
<t>alpha_string - value to be hashed, an octet string</t>
<t>Y - public key, an EC point</t>
</list>
</t>
<t>
Output:
<list>
<t>H - hashed value, a finite EC point in G
</t>
</list>
</t>
<t>
Fixed option (specified in <xref target="suites"/>):
<list>
<t>h2c_suite_ID_string - a hash-to-curve suite ID, encoded in ASCII (see discussion below)</t>
</list>
</t>
<t>
Steps
<list style="numbers">
<t>PK_string = point_to_string(Y)</t>
<t>string_to_hash = PK_string || alpha_string</t>
<t>H = encode(string_to_hash)
<vspace/>(the encode function is discussed below) </t>
<t>Output H</t>
</list>
</t>
<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"/>, Section 8.
The domain separation tag DST, a parameter to the hash-to-curve suite, SHALL be set to
<list>
<t>
"ECVRF_" || h2c_suite_ID_string || suite_string
</t>
</list>
where "ECVRF_" is represented as a 6-byte ASCII encoding (in hexadecimal, octets 45 43 56 52 46 5F).
</t>
</section>
</section>
<section title="ECVRF Nonce Generation" anchor="ecvrfNonceGeneration">
<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 is made in Section 5.5.</t>
<section title = "ECVRF Nonce Generation From RFC 6979" anchor="nonceP256">
<t>
ECVRF_nonce_generation_RFC6979(SK, h_string)
</t>
<t>
Input:
<list>
<t>SK - an ECVRF secret key</t>
<t>h_string - an octet string</t>
</list>
</t>
<t>
Output:
<list>
<t>k - an integer between 1 and q-1</t>
</list>
</t>
<t>
The ECVRF_nonce_generation function is as specified in
<xref target="RFC6979"/> Section 3.2 where
<list>
<t> Input m is set equal to h_string</t>
<t> The "suitable for DSA or ECDSA" check in step h.3 is omitted</t>
<t> The hash function H is Hash and its output length hlen is set as hLen*8</t>
<t> The secret key x is set equal to the VRF secret scalar x </t>
<t> The prime q is the same as in this specification</t>
<t> qlen is the binary length of q, i.e., the smallest integer such that 2^qlen > q</t>
<t> All the other values and primitives as defined in <xref target="RFC6979"/> </t>
</list>
</t>
</section>
<section title = "ECVRF Nonce Generation From RFC 8032" anchor="nonce25519">
<t> The following is from Steps 2-3 of Section 5.1.6
in <xref target="RFC8032"/>.
</t>
<t>
ECVRF_nonce_generation_RFC8032(SK, h_string)
</t>
<t>
Input:
<list>
<t>SK - an ECVRF secret key</t>
<t>h_string - an octet string</t>
</list>
</t>
<t>
Output:
<list>
<t>k - an integer between 0 and q-1</t>
</list>
</t>
<t>
Steps:
<list style="numbers">
<t>hashed_sk_string = Hash(SK)</t>
<t>truncated_hashed_sk_string = hashed_sk_string[32]...hashed_sk_string[63]</t>
<t>k_string = Hash(truncated_hashed_sk_string || h_string)</t>
<t>k = string_to_int(k_string) mod q</t>
</list>
</t>
</section>
</section>
<section title="ECVRF Hash Points" anchor="ecvrfHashPoints">
<t>
ECVRF_hash_points(P1, P2, ..., PM)
</t>
<t>
Input:
<list>
<t>P1...PM - EC points in G</t>
</list>
</t>
<t>
Output:
<list>
<t>c - hash value, integer between 0 and 2^(8n)-1</t>
</list>
</t>
<t>
Steps:
<list style="numbers">
<t>two_string = 0x02 = int_to_string(2, 1), a single octet with value 2 </t>
<t>Initialize str = suite_string || two_string </t>
<t>for PJ in [P1, P2, ... PM]:
<vspace/>str = str || point_to_string(PJ)
</t>
<t>zero_string = 0x00 = int_to_string(0, 1), a single octet with value 0 </t>
<t>str = str || zero_string</t>
<t>c_string = Hash(str)</t>
<t>truncated_c_string = c_string[0]...c_string[n-1]
<!--(first n octets of c_string)--></t>