-
Notifications
You must be signed in to change notification settings - Fork 4
/
Hacl_Ed25519.c
2826 lines (2670 loc) · 87.9 KB
/
Hacl_Ed25519.c
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
/* MIT License
*
* Copyright (c) 2016-2017 INRIA and Microsoft Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "Hacl_Ed25519.h"
static void Hacl_Bignum_Modulo_carry_top(uint64_t *b)
{
uint64_t b4 = b[4U];
uint64_t b0 = b[0U];
uint64_t b4_ = b4 & (uint64_t)0x7ffffffffffffU;
uint64_t b0_ = b0 + (uint64_t)19U * (b4 >> (uint32_t)51U);
b[4U] = b4_;
b[0U] = b0_;
}
inline static void
Hacl_Bignum_Fproduct_copy_from_wide_(uint64_t *output, FStar_UInt128_t *input)
{
{
FStar_UInt128_t xi = input[0U];
output[0U] = FStar_UInt128_uint128_to_uint64(xi);
}
{
FStar_UInt128_t xi = input[1U];
output[1U] = FStar_UInt128_uint128_to_uint64(xi);
}
{
FStar_UInt128_t xi = input[2U];
output[2U] = FStar_UInt128_uint128_to_uint64(xi);
}
{
FStar_UInt128_t xi = input[3U];
output[3U] = FStar_UInt128_uint128_to_uint64(xi);
}
{
FStar_UInt128_t xi = input[4U];
output[4U] = FStar_UInt128_uint128_to_uint64(xi);
}
}
inline static void
Hacl_Bignum_Fproduct_sum_scalar_multiplication_(
FStar_UInt128_t *output,
uint64_t *input,
uint64_t s
)
{
{
FStar_UInt128_t xi = output[0U];
uint64_t yi = input[0U];
output[0U] = FStar_UInt128_add_mod(xi, FStar_UInt128_mul_wide(yi, s));
}
{
FStar_UInt128_t xi = output[1U];
uint64_t yi = input[1U];
output[1U] = FStar_UInt128_add_mod(xi, FStar_UInt128_mul_wide(yi, s));
}
{
FStar_UInt128_t xi = output[2U];
uint64_t yi = input[2U];
output[2U] = FStar_UInt128_add_mod(xi, FStar_UInt128_mul_wide(yi, s));
}
{
FStar_UInt128_t xi = output[3U];
uint64_t yi = input[3U];
output[3U] = FStar_UInt128_add_mod(xi, FStar_UInt128_mul_wide(yi, s));
}
{
FStar_UInt128_t xi = output[4U];
uint64_t yi = input[4U];
output[4U] = FStar_UInt128_add_mod(xi, FStar_UInt128_mul_wide(yi, s));
}
}
inline static void Hacl_Bignum_Fproduct_carry_wide_(FStar_UInt128_t *tmp)
{
{
uint32_t ctr = (uint32_t)0U;
FStar_UInt128_t tctr = tmp[ctr];
FStar_UInt128_t tctrp1 = tmp[ctr + (uint32_t)1U];
uint64_t r0 = FStar_UInt128_uint128_to_uint64(tctr) & (uint64_t)0x7ffffffffffffU;
FStar_UInt128_t c = FStar_UInt128_shift_right(tctr, (uint32_t)51U);
tmp[ctr] = FStar_UInt128_uint64_to_uint128(r0);
tmp[ctr + (uint32_t)1U] = FStar_UInt128_add(tctrp1, c);
}
{
uint32_t ctr = (uint32_t)1U;
FStar_UInt128_t tctr = tmp[ctr];
FStar_UInt128_t tctrp1 = tmp[ctr + (uint32_t)1U];
uint64_t r0 = FStar_UInt128_uint128_to_uint64(tctr) & (uint64_t)0x7ffffffffffffU;
FStar_UInt128_t c = FStar_UInt128_shift_right(tctr, (uint32_t)51U);
tmp[ctr] = FStar_UInt128_uint64_to_uint128(r0);
tmp[ctr + (uint32_t)1U] = FStar_UInt128_add(tctrp1, c);
}
{
uint32_t ctr = (uint32_t)2U;
FStar_UInt128_t tctr = tmp[ctr];
FStar_UInt128_t tctrp1 = tmp[ctr + (uint32_t)1U];
uint64_t r0 = FStar_UInt128_uint128_to_uint64(tctr) & (uint64_t)0x7ffffffffffffU;
FStar_UInt128_t c = FStar_UInt128_shift_right(tctr, (uint32_t)51U);
tmp[ctr] = FStar_UInt128_uint64_to_uint128(r0);
tmp[ctr + (uint32_t)1U] = FStar_UInt128_add(tctrp1, c);
}
{
uint32_t ctr = (uint32_t)3U;
FStar_UInt128_t tctr = tmp[ctr];
FStar_UInt128_t tctrp1 = tmp[ctr + (uint32_t)1U];
uint64_t r0 = FStar_UInt128_uint128_to_uint64(tctr) & (uint64_t)0x7ffffffffffffU;
FStar_UInt128_t c = FStar_UInt128_shift_right(tctr, (uint32_t)51U);
tmp[ctr] = FStar_UInt128_uint64_to_uint128(r0);
tmp[ctr + (uint32_t)1U] = FStar_UInt128_add(tctrp1, c);
}
}
inline static void Hacl_Bignum_Fmul_shift_reduce(uint64_t *output)
{
uint64_t tmp = output[4U];
{
uint32_t ctr = (uint32_t)5U - (uint32_t)0U - (uint32_t)1U;
uint64_t z = output[ctr - (uint32_t)1U];
output[ctr] = z;
}
{
uint32_t ctr = (uint32_t)5U - (uint32_t)1U - (uint32_t)1U;
uint64_t z = output[ctr - (uint32_t)1U];
output[ctr] = z;
}
{
uint32_t ctr = (uint32_t)5U - (uint32_t)2U - (uint32_t)1U;
uint64_t z = output[ctr - (uint32_t)1U];
output[ctr] = z;
}
{
uint32_t ctr = (uint32_t)5U - (uint32_t)3U - (uint32_t)1U;
uint64_t z = output[ctr - (uint32_t)1U];
output[ctr] = z;
}
output[0U] = tmp;
uint64_t b0 = output[0U];
output[0U] = (uint64_t)19U * b0;
}
static void
Hacl_Bignum_Fmul_mul_shift_reduce_(FStar_UInt128_t *output, uint64_t *input, uint64_t *input21)
{
{
uint64_t input2i = input21[0U];
Hacl_Bignum_Fproduct_sum_scalar_multiplication_(output, input, input2i);
Hacl_Bignum_Fmul_shift_reduce(input);
}
{
uint64_t input2i = input21[1U];
Hacl_Bignum_Fproduct_sum_scalar_multiplication_(output, input, input2i);
Hacl_Bignum_Fmul_shift_reduce(input);
}
{
uint64_t input2i = input21[2U];
Hacl_Bignum_Fproduct_sum_scalar_multiplication_(output, input, input2i);
Hacl_Bignum_Fmul_shift_reduce(input);
}
{
uint64_t input2i = input21[3U];
Hacl_Bignum_Fproduct_sum_scalar_multiplication_(output, input, input2i);
Hacl_Bignum_Fmul_shift_reduce(input);
}
uint32_t i = (uint32_t)4U;
uint64_t input2i = input21[i];
Hacl_Bignum_Fproduct_sum_scalar_multiplication_(output, input, input2i);
}
inline static void Hacl_Bignum_Fmul_fmul(uint64_t *output, uint64_t *input, uint64_t *input21)
{
uint64_t tmp[5U] = { 0U };
memcpy(tmp, input, (uint32_t)5U * sizeof input[0U]);
KRML_CHECK_SIZE(FStar_UInt128_uint64_to_uint128((uint64_t)0U), (uint32_t)5U);
FStar_UInt128_t t[5U];
for (uint32_t _i = 0U; _i < (uint32_t)5U; ++_i)
t[_i] = FStar_UInt128_uint64_to_uint128((uint64_t)0U);
Hacl_Bignum_Fmul_mul_shift_reduce_(t, tmp, input21);
Hacl_Bignum_Fproduct_carry_wide_(t);
FStar_UInt128_t b4 = t[4U];
FStar_UInt128_t b0 = t[0U];
FStar_UInt128_t
b4_ = FStar_UInt128_logand(b4, FStar_UInt128_uint64_to_uint128((uint64_t)0x7ffffffffffffU));
FStar_UInt128_t
b0_ =
FStar_UInt128_add(b0,
FStar_UInt128_mul_wide((uint64_t)19U,
FStar_UInt128_uint128_to_uint64(FStar_UInt128_shift_right(b4, (uint32_t)51U))));
t[4U] = b4_;
t[0U] = b0_;
Hacl_Bignum_Fproduct_copy_from_wide_(output, t);
uint64_t i0 = output[0U];
uint64_t i1 = output[1U];
uint64_t i0_ = i0 & (uint64_t)0x7ffffffffffffU;
uint64_t i1_ = i1 + (i0 >> (uint32_t)51U);
output[0U] = i0_;
output[1U] = i1_;
}
inline static void Hacl_Bignum_Fsquare_fsquare__(FStar_UInt128_t *tmp, uint64_t *output)
{
uint64_t r0 = output[0U];
uint64_t r1 = output[1U];
uint64_t r2 = output[2U];
uint64_t r3 = output[3U];
uint64_t r4 = output[4U];
uint64_t d0 = r0 * (uint64_t)2U;
uint64_t d1 = r1 * (uint64_t)2U;
uint64_t d2 = r2 * (uint64_t)2U * (uint64_t)19U;
uint64_t d419 = r4 * (uint64_t)19U;
uint64_t d4 = d419 * (uint64_t)2U;
FStar_UInt128_t
s0 =
FStar_UInt128_add(FStar_UInt128_add(FStar_UInt128_mul_wide(r0, r0),
FStar_UInt128_mul_wide(d4, r1)),
FStar_UInt128_mul_wide(d2, r3));
FStar_UInt128_t
s1 =
FStar_UInt128_add(FStar_UInt128_add(FStar_UInt128_mul_wide(d0, r1),
FStar_UInt128_mul_wide(d4, r2)),
FStar_UInt128_mul_wide(r3 * (uint64_t)19U, r3));
FStar_UInt128_t
s2 =
FStar_UInt128_add(FStar_UInt128_add(FStar_UInt128_mul_wide(d0, r2),
FStar_UInt128_mul_wide(r1, r1)),
FStar_UInt128_mul_wide(d4, r3));
FStar_UInt128_t
s3 =
FStar_UInt128_add(FStar_UInt128_add(FStar_UInt128_mul_wide(d0, r3),
FStar_UInt128_mul_wide(d1, r2)),
FStar_UInt128_mul_wide(r4, d419));
FStar_UInt128_t
s4 =
FStar_UInt128_add(FStar_UInt128_add(FStar_UInt128_mul_wide(d0, r4),
FStar_UInt128_mul_wide(d1, r3)),
FStar_UInt128_mul_wide(r2, r2));
tmp[0U] = s0;
tmp[1U] = s1;
tmp[2U] = s2;
tmp[3U] = s3;
tmp[4U] = s4;
}
inline static void Hacl_Bignum_Fsquare_fsquare_(FStar_UInt128_t *tmp, uint64_t *output)
{
Hacl_Bignum_Fsquare_fsquare__(tmp, output);
Hacl_Bignum_Fproduct_carry_wide_(tmp);
FStar_UInt128_t b4 = tmp[4U];
FStar_UInt128_t b0 = tmp[0U];
FStar_UInt128_t
b4_ = FStar_UInt128_logand(b4, FStar_UInt128_uint64_to_uint128((uint64_t)0x7ffffffffffffU));
FStar_UInt128_t
b0_ =
FStar_UInt128_add(b0,
FStar_UInt128_mul_wide((uint64_t)19U,
FStar_UInt128_uint128_to_uint64(FStar_UInt128_shift_right(b4, (uint32_t)51U))));
tmp[4U] = b4_;
tmp[0U] = b0_;
Hacl_Bignum_Fproduct_copy_from_wide_(output, tmp);
uint64_t i0 = output[0U];
uint64_t i1 = output[1U];
uint64_t i0_ = i0 & (uint64_t)0x7ffffffffffffU;
uint64_t i1_ = i1 + (i0 >> (uint32_t)51U);
output[0U] = i0_;
output[1U] = i1_;
}
static void
Hacl_Bignum_Fsquare_fsquare_times_(uint64_t *input, FStar_UInt128_t *tmp, uint32_t count1)
{
Hacl_Bignum_Fsquare_fsquare_(tmp, input);
for (uint32_t i = (uint32_t)1U; i < count1; i = i + (uint32_t)1U)
Hacl_Bignum_Fsquare_fsquare_(tmp, input);
}
inline static void
Hacl_Bignum_Fsquare_fsquare_times(uint64_t *output, uint64_t *input, uint32_t count1)
{
KRML_CHECK_SIZE(FStar_UInt128_uint64_to_uint128((uint64_t)0U), (uint32_t)5U);
FStar_UInt128_t t[5U];
for (uint32_t _i = 0U; _i < (uint32_t)5U; ++_i)
t[_i] = FStar_UInt128_uint64_to_uint128((uint64_t)0U);
memcpy(output, input, (uint32_t)5U * sizeof input[0U]);
Hacl_Bignum_Fsquare_fsquare_times_(output, t, count1);
}
inline static void Hacl_Bignum_Fsquare_fsquare_times_inplace(uint64_t *output, uint32_t count1)
{
KRML_CHECK_SIZE(FStar_UInt128_uint64_to_uint128((uint64_t)0U), (uint32_t)5U);
FStar_UInt128_t t[5U];
for (uint32_t _i = 0U; _i < (uint32_t)5U; ++_i)
t[_i] = FStar_UInt128_uint64_to_uint128((uint64_t)0U);
Hacl_Bignum_Fsquare_fsquare_times_(output, t, count1);
}
inline static void Hacl_Bignum_Crecip_crecip(uint64_t *out, uint64_t *z)
{
uint64_t buf[20U] = { 0U };
uint64_t *a = buf;
uint64_t *t00 = buf + (uint32_t)5U;
uint64_t *b0 = buf + (uint32_t)10U;
Hacl_Bignum_Fsquare_fsquare_times(a, z, (uint32_t)1U);
Hacl_Bignum_Fsquare_fsquare_times(t00, a, (uint32_t)2U);
Hacl_Bignum_Fmul_fmul(b0, t00, z);
Hacl_Bignum_Fmul_fmul(a, b0, a);
Hacl_Bignum_Fsquare_fsquare_times(t00, a, (uint32_t)1U);
Hacl_Bignum_Fmul_fmul(b0, t00, b0);
Hacl_Bignum_Fsquare_fsquare_times(t00, b0, (uint32_t)5U);
uint64_t *t01 = buf + (uint32_t)5U;
uint64_t *b1 = buf + (uint32_t)10U;
uint64_t *c0 = buf + (uint32_t)15U;
Hacl_Bignum_Fmul_fmul(b1, t01, b1);
Hacl_Bignum_Fsquare_fsquare_times(t01, b1, (uint32_t)10U);
Hacl_Bignum_Fmul_fmul(c0, t01, b1);
Hacl_Bignum_Fsquare_fsquare_times(t01, c0, (uint32_t)20U);
Hacl_Bignum_Fmul_fmul(t01, t01, c0);
Hacl_Bignum_Fsquare_fsquare_times_inplace(t01, (uint32_t)10U);
Hacl_Bignum_Fmul_fmul(b1, t01, b1);
Hacl_Bignum_Fsquare_fsquare_times(t01, b1, (uint32_t)50U);
uint64_t *a0 = buf;
uint64_t *t0 = buf + (uint32_t)5U;
uint64_t *b = buf + (uint32_t)10U;
uint64_t *c = buf + (uint32_t)15U;
Hacl_Bignum_Fmul_fmul(c, t0, b);
Hacl_Bignum_Fsquare_fsquare_times(t0, c, (uint32_t)100U);
Hacl_Bignum_Fmul_fmul(t0, t0, c);
Hacl_Bignum_Fsquare_fsquare_times_inplace(t0, (uint32_t)50U);
Hacl_Bignum_Fmul_fmul(t0, t0, b);
Hacl_Bignum_Fsquare_fsquare_times_inplace(t0, (uint32_t)5U);
Hacl_Bignum_Fmul_fmul(out, t0, a0);
}
inline static void Hacl_Bignum_Crecip_crecip_(uint64_t *out, uint64_t *z)
{
uint64_t buf[20U] = { 0U };
uint64_t *a = buf;
uint64_t *t00 = buf + (uint32_t)5U;
uint64_t *b0 = buf + (uint32_t)10U;
Hacl_Bignum_Fsquare_fsquare_times(a, z, (uint32_t)1U);
Hacl_Bignum_Fsquare_fsquare_times(t00, a, (uint32_t)2U);
Hacl_Bignum_Fmul_fmul(b0, t00, z);
Hacl_Bignum_Fmul_fmul(a, b0, a);
Hacl_Bignum_Fsquare_fsquare_times(t00, a, (uint32_t)1U);
Hacl_Bignum_Fmul_fmul(b0, t00, b0);
Hacl_Bignum_Fsquare_fsquare_times(t00, b0, (uint32_t)5U);
uint64_t *t01 = buf + (uint32_t)5U;
uint64_t *b1 = buf + (uint32_t)10U;
uint64_t *c0 = buf + (uint32_t)15U;
Hacl_Bignum_Fmul_fmul(b1, t01, b1);
Hacl_Bignum_Fsquare_fsquare_times(t01, b1, (uint32_t)10U);
Hacl_Bignum_Fmul_fmul(c0, t01, b1);
Hacl_Bignum_Fsquare_fsquare_times(t01, c0, (uint32_t)20U);
Hacl_Bignum_Fmul_fmul(t01, t01, c0);
Hacl_Bignum_Fsquare_fsquare_times_inplace(t01, (uint32_t)10U);
Hacl_Bignum_Fmul_fmul(b1, t01, b1);
Hacl_Bignum_Fsquare_fsquare_times(t01, b1, (uint32_t)50U);
uint64_t *a0 = buf;
Hacl_Bignum_Fsquare_fsquare_times(a0, z, (uint32_t)1U);
uint64_t *a1 = buf;
uint64_t *t0 = buf + (uint32_t)5U;
uint64_t *b = buf + (uint32_t)10U;
uint64_t *c = buf + (uint32_t)15U;
Hacl_Bignum_Fmul_fmul(c, t0, b);
Hacl_Bignum_Fsquare_fsquare_times(t0, c, (uint32_t)100U);
Hacl_Bignum_Fmul_fmul(t0, t0, c);
Hacl_Bignum_Fsquare_fsquare_times_inplace(t0, (uint32_t)50U);
Hacl_Bignum_Fmul_fmul(t0, t0, b);
Hacl_Bignum_Fsquare_fsquare_times_inplace(t0, (uint32_t)2U);
Hacl_Bignum_Fmul_fmul(out, t0, a1);
}
inline static void Hacl_Bignum_fsum(uint64_t *a, uint64_t *b)
{
{
uint64_t xi = a[0U];
uint64_t yi = b[0U];
a[0U] = xi + yi;
}
{
uint64_t xi = a[1U];
uint64_t yi = b[1U];
a[1U] = xi + yi;
}
{
uint64_t xi = a[2U];
uint64_t yi = b[2U];
a[2U] = xi + yi;
}
{
uint64_t xi = a[3U];
uint64_t yi = b[3U];
a[3U] = xi + yi;
}
{
uint64_t xi = a[4U];
uint64_t yi = b[4U];
a[4U] = xi + yi;
}
}
inline static void Hacl_Bignum_fdifference(uint64_t *a, uint64_t *b)
{
uint64_t tmp[5U] = { 0U };
memcpy(tmp, b, (uint32_t)5U * sizeof b[0U]);
uint64_t b0 = tmp[0U];
uint64_t b1 = tmp[1U];
uint64_t b2 = tmp[2U];
uint64_t b3 = tmp[3U];
uint64_t b4 = tmp[4U];
tmp[0U] = b0 + (uint64_t)0x3fffffffffff68U;
tmp[1U] = b1 + (uint64_t)0x3ffffffffffff8U;
tmp[2U] = b2 + (uint64_t)0x3ffffffffffff8U;
tmp[3U] = b3 + (uint64_t)0x3ffffffffffff8U;
tmp[4U] = b4 + (uint64_t)0x3ffffffffffff8U;
{
uint64_t xi = a[0U];
uint64_t yi = tmp[0U];
a[0U] = yi - xi;
}
{
uint64_t xi = a[1U];
uint64_t yi = tmp[1U];
a[1U] = yi - xi;
}
{
uint64_t xi = a[2U];
uint64_t yi = tmp[2U];
a[2U] = yi - xi;
}
{
uint64_t xi = a[3U];
uint64_t yi = tmp[3U];
a[3U] = yi - xi;
}
{
uint64_t xi = a[4U];
uint64_t yi = tmp[4U];
a[4U] = yi - xi;
}
}
inline static void Hacl_Bignum_fmul(uint64_t *output, uint64_t *a, uint64_t *b)
{
Hacl_Bignum_Fmul_fmul(output, a, b);
}
static void Hacl_EC_Format_fexpand(uint64_t *output, uint8_t *input)
{
uint64_t i0 = load64_le(input);
uint8_t *x00 = input + (uint32_t)6U;
uint64_t i1 = load64_le(x00);
uint8_t *x01 = input + (uint32_t)12U;
uint64_t i2 = load64_le(x01);
uint8_t *x02 = input + (uint32_t)19U;
uint64_t i3 = load64_le(x02);
uint8_t *x0 = input + (uint32_t)24U;
uint64_t i4 = load64_le(x0);
uint64_t output0 = i0 & (uint64_t)0x7ffffffffffffU;
uint64_t output1 = i1 >> (uint32_t)3U & (uint64_t)0x7ffffffffffffU;
uint64_t output2 = i2 >> (uint32_t)6U & (uint64_t)0x7ffffffffffffU;
uint64_t output3 = i3 >> (uint32_t)1U & (uint64_t)0x7ffffffffffffU;
uint64_t output4 = i4 >> (uint32_t)12U & (uint64_t)0x7ffffffffffffU;
output[0U] = output0;
output[1U] = output1;
output[2U] = output2;
output[3U] = output3;
output[4U] = output4;
}
static void Hacl_EC_Format_fcontract_first_carry_pass(uint64_t *input)
{
uint64_t t0 = input[0U];
uint64_t t1 = input[1U];
uint64_t t2 = input[2U];
uint64_t t3 = input[3U];
uint64_t t4 = input[4U];
uint64_t t1_ = t1 + (t0 >> (uint32_t)51U);
uint64_t t0_ = t0 & (uint64_t)0x7ffffffffffffU;
uint64_t t2_ = t2 + (t1_ >> (uint32_t)51U);
uint64_t t1__ = t1_ & (uint64_t)0x7ffffffffffffU;
uint64_t t3_ = t3 + (t2_ >> (uint32_t)51U);
uint64_t t2__ = t2_ & (uint64_t)0x7ffffffffffffU;
uint64_t t4_ = t4 + (t3_ >> (uint32_t)51U);
uint64_t t3__ = t3_ & (uint64_t)0x7ffffffffffffU;
input[0U] = t0_;
input[1U] = t1__;
input[2U] = t2__;
input[3U] = t3__;
input[4U] = t4_;
}
static void Hacl_EC_Format_fcontract_first_carry_full(uint64_t *input)
{
Hacl_EC_Format_fcontract_first_carry_pass(input);
Hacl_Bignum_Modulo_carry_top(input);
}
static void Hacl_EC_Format_fcontract_second_carry_pass(uint64_t *input)
{
uint64_t t0 = input[0U];
uint64_t t1 = input[1U];
uint64_t t2 = input[2U];
uint64_t t3 = input[3U];
uint64_t t4 = input[4U];
uint64_t t1_ = t1 + (t0 >> (uint32_t)51U);
uint64_t t0_ = t0 & (uint64_t)0x7ffffffffffffU;
uint64_t t2_ = t2 + (t1_ >> (uint32_t)51U);
uint64_t t1__ = t1_ & (uint64_t)0x7ffffffffffffU;
uint64_t t3_ = t3 + (t2_ >> (uint32_t)51U);
uint64_t t2__ = t2_ & (uint64_t)0x7ffffffffffffU;
uint64_t t4_ = t4 + (t3_ >> (uint32_t)51U);
uint64_t t3__ = t3_ & (uint64_t)0x7ffffffffffffU;
input[0U] = t0_;
input[1U] = t1__;
input[2U] = t2__;
input[3U] = t3__;
input[4U] = t4_;
}
static void Hacl_EC_Format_fcontract_second_carry_full(uint64_t *input)
{
Hacl_EC_Format_fcontract_second_carry_pass(input);
Hacl_Bignum_Modulo_carry_top(input);
uint64_t i0 = input[0U];
uint64_t i1 = input[1U];
uint64_t i0_ = i0 & (uint64_t)0x7ffffffffffffU;
uint64_t i1_ = i1 + (i0 >> (uint32_t)51U);
input[0U] = i0_;
input[1U] = i1_;
}
static void Hacl_EC_Format_fcontract_trim(uint64_t *input)
{
uint64_t a0 = input[0U];
uint64_t a1 = input[1U];
uint64_t a2 = input[2U];
uint64_t a3 = input[3U];
uint64_t a4 = input[4U];
uint64_t mask0 = FStar_UInt64_gte_mask(a0, (uint64_t)0x7ffffffffffedU);
uint64_t mask1 = FStar_UInt64_eq_mask(a1, (uint64_t)0x7ffffffffffffU);
uint64_t mask2 = FStar_UInt64_eq_mask(a2, (uint64_t)0x7ffffffffffffU);
uint64_t mask3 = FStar_UInt64_eq_mask(a3, (uint64_t)0x7ffffffffffffU);
uint64_t mask4 = FStar_UInt64_eq_mask(a4, (uint64_t)0x7ffffffffffffU);
uint64_t mask = (((mask0 & mask1) & mask2) & mask3) & mask4;
uint64_t a0_ = a0 - ((uint64_t)0x7ffffffffffedU & mask);
uint64_t a1_ = a1 - ((uint64_t)0x7ffffffffffffU & mask);
uint64_t a2_ = a2 - ((uint64_t)0x7ffffffffffffU & mask);
uint64_t a3_ = a3 - ((uint64_t)0x7ffffffffffffU & mask);
uint64_t a4_ = a4 - ((uint64_t)0x7ffffffffffffU & mask);
input[0U] = a0_;
input[1U] = a1_;
input[2U] = a2_;
input[3U] = a3_;
input[4U] = a4_;
}
static void Hacl_EC_Format_reduce(uint64_t *out)
{
Hacl_EC_Format_fcontract_first_carry_full(out);
Hacl_EC_Format_fcontract_second_carry_full(out);
Hacl_EC_Format_fcontract_trim(out);
}
static void
Hacl_Lib_Create64_make_h64_5(
uint64_t *b,
uint64_t s0,
uint64_t s1,
uint64_t s2,
uint64_t s3,
uint64_t s4
)
{
b[0U] = s0;
b[1U] = s1;
b[2U] = s2;
b[3U] = s3;
b[4U] = s4;
}
static void
Hacl_Lib_Create64_make_h64_10(
uint64_t *b,
uint64_t s0,
uint64_t s1,
uint64_t s2,
uint64_t s3,
uint64_t s4,
uint64_t s5,
uint64_t s6,
uint64_t s7,
uint64_t s8,
uint64_t s9
)
{
b[0U] = s0;
b[1U] = s1;
b[2U] = s2;
b[3U] = s3;
b[4U] = s4;
b[5U] = s5;
b[6U] = s6;
b[7U] = s7;
b[8U] = s8;
b[9U] = s9;
}
static void Hacl_Bignum25519_fsum(uint64_t *a, uint64_t *b)
{
Hacl_Bignum_fsum(a, b);
}
static void Hacl_Bignum25519_fdifference(uint64_t *a, uint64_t *b)
{
Hacl_Bignum_fdifference(a, b);
}
static void Hacl_Bignum25519_reduce_513(uint64_t *a)
{
uint64_t t0 = a[0U];
uint64_t t1 = a[1U];
uint64_t t2 = a[2U];
uint64_t t3 = a[3U];
uint64_t t4 = a[4U];
uint64_t t1_ = t1 + (t0 >> (uint32_t)51U);
uint64_t t0_ = t0 & (uint64_t)0x7ffffffffffffU;
uint64_t t2_ = t2 + (t1_ >> (uint32_t)51U);
uint64_t t1__ = t1_ & (uint64_t)0x7ffffffffffffU;
uint64_t t3_ = t3 + (t2_ >> (uint32_t)51U);
uint64_t t2__ = t2_ & (uint64_t)0x7ffffffffffffU;
uint64_t t4_ = t4 + (t3_ >> (uint32_t)51U);
uint64_t t3__ = t3_ & (uint64_t)0x7ffffffffffffU;
Hacl_Lib_Create64_make_h64_5(a, t0_, t1__, t2__, t3__, t4_);
Hacl_Bignum_Modulo_carry_top(a);
uint64_t i0 = a[0U];
uint64_t i1 = a[1U];
uint64_t i0_ = i0 & (uint64_t)0x7ffffffffffffU;
uint64_t i1_ = i1 + (i0 >> (uint32_t)51U);
a[0U] = i0_;
a[1U] = i1_;
}
static void Hacl_Bignum25519_fdifference_reduced(uint64_t *a, uint64_t *b)
{
Hacl_Bignum25519_fdifference(a, b);
Hacl_Bignum25519_reduce_513(a);
}
static void Hacl_Bignum25519_fmul(uint64_t *out, uint64_t *a, uint64_t *b)
{
Hacl_Bignum_fmul(out, a, b);
}
static void Hacl_Bignum25519_times_2(uint64_t *out, uint64_t *a)
{
uint64_t a0 = a[0U];
uint64_t a1 = a[1U];
uint64_t a2 = a[2U];
uint64_t a3 = a[3U];
uint64_t a4 = a[4U];
uint64_t o0 = (uint64_t)2U * a0;
uint64_t o1 = (uint64_t)2U * a1;
uint64_t o2 = (uint64_t)2U * a2;
uint64_t o3 = (uint64_t)2U * a3;
uint64_t o4 = (uint64_t)2U * a4;
Hacl_Lib_Create64_make_h64_5(out, o0, o1, o2, o3, o4);
}
static void Hacl_Bignum25519_times_d(uint64_t *out, uint64_t *a)
{
uint64_t d1[5U] = { 0U };
Hacl_Lib_Create64_make_h64_5(d1,
(uint64_t)0x00034dca135978a3U,
(uint64_t)0x0001a8283b156ebdU,
(uint64_t)0x0005e7a26001c029U,
(uint64_t)0x000739c663a03cbbU,
(uint64_t)0x00052036cee2b6ffU);
Hacl_Bignum25519_fmul(out, d1, a);
}
static void Hacl_Bignum25519_times_2d(uint64_t *out, uint64_t *a)
{
uint64_t d2[5U] = { 0U };
Hacl_Lib_Create64_make_h64_5(d2,
(uint64_t)0x00069b9426b2f159U,
(uint64_t)0x00035050762add7aU,
(uint64_t)0x0003cf44c0038052U,
(uint64_t)0x0006738cc7407977U,
(uint64_t)0x0002406d9dc56dffU);
Hacl_Bignum25519_fmul(out, a, d2);
}
static void Hacl_Bignum25519_fsquare(uint64_t *out, uint64_t *a)
{
KRML_CHECK_SIZE(FStar_UInt128_uint64_to_uint128((uint64_t)0U), (uint32_t)5U);
FStar_UInt128_t tmp[5U];
for (uint32_t _i = 0U; _i < (uint32_t)5U; ++_i)
tmp[_i] = FStar_UInt128_uint64_to_uint128((uint64_t)0U);
memcpy(out, a, (uint32_t)5U * sizeof a[0U]);
Hacl_Bignum_Fsquare_fsquare_(tmp, out);
}
static void Hacl_Bignum25519_inverse(uint64_t *out, uint64_t *a)
{
Hacl_Bignum_Crecip_crecip(out, a);
}
static void Hacl_Bignum25519_reduce(uint64_t *out)
{
Hacl_EC_Format_reduce(out);
}
static uint64_t *Hacl_Impl_Ed25519_ExtPoint_getx(uint64_t *p)
{
return p;
}
static uint64_t *Hacl_Impl_Ed25519_ExtPoint_gety(uint64_t *p)
{
return p + (uint32_t)5U;
}
static uint64_t *Hacl_Impl_Ed25519_ExtPoint_getz(uint64_t *p)
{
return p + (uint32_t)10U;
}
static uint64_t *Hacl_Impl_Ed25519_ExtPoint_gett(uint64_t *p)
{
return p + (uint32_t)15U;
}
static void Hacl_Impl_Ed25519_G_make_g(uint64_t *g1)
{
uint64_t *gx = Hacl_Impl_Ed25519_ExtPoint_getx(g1);
uint64_t *gy = Hacl_Impl_Ed25519_ExtPoint_gety(g1);
uint64_t *gz = Hacl_Impl_Ed25519_ExtPoint_getz(g1);
uint64_t *gt1 = Hacl_Impl_Ed25519_ExtPoint_gett(g1);
Hacl_Lib_Create64_make_h64_5(gx,
(uint64_t)0x00062d608f25d51aU,
(uint64_t)0x000412a4b4f6592aU,
(uint64_t)0x00075b7171a4b31dU,
(uint64_t)0x0001ff60527118feU,
(uint64_t)0x000216936d3cd6e5U);
Hacl_Lib_Create64_make_h64_5(gy,
(uint64_t)0x0006666666666658U,
(uint64_t)0x0004ccccccccccccU,
(uint64_t)0x0001999999999999U,
(uint64_t)0x0003333333333333U,
(uint64_t)0x0006666666666666U);
Hacl_Lib_Create64_make_h64_5(gz,
(uint64_t)0x0000000000000001U,
(uint64_t)0x0000000000000000U,
(uint64_t)0x0000000000000000U,
(uint64_t)0x0000000000000000U,
(uint64_t)0x0000000000000000U);
Hacl_Lib_Create64_make_h64_5(gt1,
(uint64_t)0x00068ab3a5b7dda3U,
(uint64_t)0x00000eea2a5eadbbU,
(uint64_t)0x0002af8df483c27eU,
(uint64_t)0x000332b375274732U,
(uint64_t)0x00067875f0fd78b7U);
}
static void Hacl_Impl_Store51_store_51_(uint8_t *output, uint64_t *input)
{
uint64_t t0 = input[0U];
uint64_t t1 = input[1U];
uint64_t t2 = input[2U];
uint64_t t3 = input[3U];
uint64_t t4 = input[4U];
uint64_t o0 = t1 << (uint32_t)51U | t0;
uint64_t o1 = t2 << (uint32_t)38U | t1 >> (uint32_t)13U;
uint64_t o2 = t3 << (uint32_t)25U | t2 >> (uint32_t)26U;
uint64_t o3 = t4 << (uint32_t)12U | t3 >> (uint32_t)39U;
uint8_t *b0 = output;
uint8_t *b1 = output + (uint32_t)8U;
uint8_t *b2 = output + (uint32_t)16U;
uint8_t *b3 = output + (uint32_t)24U;
store64_le(b0, o0);
store64_le(b1, o1);
store64_le(b2, o2);
store64_le(b3, o3);
}
static uint64_t Hacl_Impl_Ed25519_PointCompress_x_mod_2(uint64_t *x)
{
uint64_t x0 = x[0U];
return x0 & (uint64_t)1U;
}
static void Hacl_Impl_Ed25519_PointCompress_point_compress(uint8_t *z, uint64_t *p)
{
uint64_t tmp[15U] = { 0U };
uint64_t *x0 = tmp + (uint32_t)5U;
uint64_t *out0 = tmp + (uint32_t)10U;
uint64_t *zinv = tmp;
uint64_t *x = tmp + (uint32_t)5U;
uint64_t *out = tmp + (uint32_t)10U;
uint64_t *px = Hacl_Impl_Ed25519_ExtPoint_getx(p);
uint64_t *py = Hacl_Impl_Ed25519_ExtPoint_gety(p);
uint64_t *pz = Hacl_Impl_Ed25519_ExtPoint_getz(p);
Hacl_Bignum25519_inverse(zinv, pz);
Hacl_Bignum25519_fmul(x, px, zinv);
Hacl_Bignum25519_reduce(x);
Hacl_Bignum25519_fmul(out, py, zinv);
Hacl_Bignum25519_reduce(out);
uint64_t b = Hacl_Impl_Ed25519_PointCompress_x_mod_2(x0);
Hacl_Impl_Store51_store_51_(z, out0);
uint8_t xbyte = (uint8_t)b;
uint8_t o31 = z[31U];
z[31U] = o31 + (xbyte << (uint32_t)7U);
}
static void
Hacl_Impl_Ed25519_SwapConditional_swap_conditional_step(
uint64_t *a_,
uint64_t *b_,
uint64_t *a,
uint64_t *b,
uint64_t swap1
)
{
uint64_t a0 = a[0U];
uint64_t a1 = a[1U];
uint64_t a2 = a[2U];
uint64_t a3 = a[3U];
uint64_t a4 = a[4U];
uint64_t b0 = b[0U];
uint64_t b1 = b[1U];
uint64_t b2 = b[2U];
uint64_t b3 = b[3U];
uint64_t b4 = b[4U];
uint64_t x0 = swap1 & (a0 ^ b0);
uint64_t x1 = swap1 & (a1 ^ b1);
uint64_t x2 = swap1 & (a2 ^ b2);
uint64_t x3 = swap1 & (a3 ^ b3);
uint64_t x4 = swap1 & (a4 ^ b4);
uint64_t a0_ = a0 ^ x0;
uint64_t b0_ = b0 ^ x0;
uint64_t a1_ = a1 ^ x1;
uint64_t b1_ = b1 ^ x1;
uint64_t a2_ = a2 ^ x2;
uint64_t b2_ = b2 ^ x2;
uint64_t a3_ = a3 ^ x3;
uint64_t b3_ = b3 ^ x3;
uint64_t a4_ = a4 ^ x4;
uint64_t b4_ = b4 ^ x4;
Hacl_Lib_Create64_make_h64_5(a_, a0_, a1_, a2_, a3_, a4_);
Hacl_Lib_Create64_make_h64_5(b_, b0_, b1_, b2_, b3_, b4_);
}
static void
Hacl_Impl_Ed25519_SwapConditional_swap_conditional(
uint64_t *a_,
uint64_t *b_,
uint64_t *a,
uint64_t *b,
uint64_t iswap
)
{
uint64_t swap1 = (uint64_t)0U - iswap;
Hacl_Impl_Ed25519_SwapConditional_swap_conditional_step(Hacl_Impl_Ed25519_ExtPoint_getx(a_),
Hacl_Impl_Ed25519_ExtPoint_getx(b_),
Hacl_Impl_Ed25519_ExtPoint_getx(a),
Hacl_Impl_Ed25519_ExtPoint_getx(b),
swap1);
Hacl_Impl_Ed25519_SwapConditional_swap_conditional_step(Hacl_Impl_Ed25519_ExtPoint_gety(a_),
Hacl_Impl_Ed25519_ExtPoint_gety(b_),
Hacl_Impl_Ed25519_ExtPoint_gety(a),
Hacl_Impl_Ed25519_ExtPoint_gety(b),
swap1);
Hacl_Impl_Ed25519_SwapConditional_swap_conditional_step(Hacl_Impl_Ed25519_ExtPoint_getz(a_),
Hacl_Impl_Ed25519_ExtPoint_getz(b_),
Hacl_Impl_Ed25519_ExtPoint_getz(a),
Hacl_Impl_Ed25519_ExtPoint_getz(b),
swap1);
Hacl_Impl_Ed25519_SwapConditional_swap_conditional_step(Hacl_Impl_Ed25519_ExtPoint_gett(a_),
Hacl_Impl_Ed25519_ExtPoint_gett(b_),
Hacl_Impl_Ed25519_ExtPoint_gett(a),
Hacl_Impl_Ed25519_ExtPoint_gett(b),
swap1);
}
static void
Hacl_Impl_Ed25519_SwapConditional_swap_conditional_inplace(
uint64_t *a,
uint64_t *b,
uint64_t iswap
)
{
uint64_t swap1 = (uint64_t)0U - iswap;
Hacl_Impl_Ed25519_SwapConditional_swap_conditional_step(Hacl_Impl_Ed25519_ExtPoint_getx(a),
Hacl_Impl_Ed25519_ExtPoint_getx(b),
Hacl_Impl_Ed25519_ExtPoint_getx(a),
Hacl_Impl_Ed25519_ExtPoint_getx(b),
swap1);
Hacl_Impl_Ed25519_SwapConditional_swap_conditional_step(Hacl_Impl_Ed25519_ExtPoint_gety(a),
Hacl_Impl_Ed25519_ExtPoint_gety(b),
Hacl_Impl_Ed25519_ExtPoint_gety(a),
Hacl_Impl_Ed25519_ExtPoint_gety(b),
swap1);
Hacl_Impl_Ed25519_SwapConditional_swap_conditional_step(Hacl_Impl_Ed25519_ExtPoint_getz(a),
Hacl_Impl_Ed25519_ExtPoint_getz(b),
Hacl_Impl_Ed25519_ExtPoint_getz(a),
Hacl_Impl_Ed25519_ExtPoint_getz(b),
swap1);
Hacl_Impl_Ed25519_SwapConditional_swap_conditional_step(Hacl_Impl_Ed25519_ExtPoint_gett(a),
Hacl_Impl_Ed25519_ExtPoint_gett(b),
Hacl_Impl_Ed25519_ExtPoint_gett(a),
Hacl_Impl_Ed25519_ExtPoint_gett(b),
swap1);
}
static void Hacl_Impl_Ed25519_SwapConditional_copy(uint64_t *output, uint64_t *input)
{
memcpy(output, input, (uint32_t)20U * sizeof input[0U]);
}
static void Hacl_Impl_Ed25519_PointAdd_point_add(uint64_t *out, uint64_t *p, uint64_t *q1)
{
uint64_t tmp[30U] = { 0U };
uint64_t *tmp1 = tmp;
uint64_t *tmp20 = tmp + (uint32_t)5U;
uint64_t *tmp30 = tmp + (uint32_t)10U;
uint64_t *tmp40 = tmp + (uint32_t)15U;
uint64_t *x1 = Hacl_Impl_Ed25519_ExtPoint_getx(p);
uint64_t *y1 = Hacl_Impl_Ed25519_ExtPoint_gety(p);
uint64_t *x2 = Hacl_Impl_Ed25519_ExtPoint_getx(q1);
uint64_t *y2 = Hacl_Impl_Ed25519_ExtPoint_gety(q1);
memcpy(tmp1, x1, (uint32_t)5U * sizeof x1[0U]);
memcpy(tmp20, x2, (uint32_t)5U * sizeof x2[0U]);
Hacl_Bignum25519_fdifference_reduced(tmp1, y1);
Hacl_Bignum25519_fdifference(tmp20, y2);
Hacl_Bignum25519_fmul(tmp30, tmp1, tmp20);
memcpy(tmp1, y1, (uint32_t)5U * sizeof y1[0U]);
memcpy(tmp20, y2, (uint32_t)5U * sizeof y2[0U]);
Hacl_Bignum25519_fsum(tmp1, x1);
Hacl_Bignum25519_fsum(tmp20, x2);
Hacl_Bignum25519_fmul(tmp40, tmp1, tmp20);
uint64_t *tmp10 = tmp;
uint64_t *tmp21 = tmp + (uint32_t)5U;
uint64_t *tmp31 = tmp + (uint32_t)10U;
uint64_t *tmp50 = tmp + (uint32_t)20U;
uint64_t *tmp60 = tmp + (uint32_t)25U;
uint64_t *z1 = Hacl_Impl_Ed25519_ExtPoint_getz(p);
uint64_t *t1 = Hacl_Impl_Ed25519_ExtPoint_gett(p);
uint64_t *z2 = Hacl_Impl_Ed25519_ExtPoint_getz(q1);
uint64_t *t2 = Hacl_Impl_Ed25519_ExtPoint_gett(q1);
Hacl_Bignum25519_times_2d(tmp10, t1);
Hacl_Bignum25519_fmul(tmp21, tmp10, t2);
Hacl_Bignum25519_times_2(tmp10, z1);
Hacl_Bignum25519_fmul(tmp50, tmp10, z2);
memcpy(tmp10, tmp31, (uint32_t)5U * sizeof tmp31[0U]);
memcpy(tmp60, tmp21, (uint32_t)5U * sizeof tmp21[0U]);
uint64_t *tmp11 = tmp;
uint64_t *tmp2 = tmp + (uint32_t)5U;
uint64_t *tmp3 = tmp + (uint32_t)10U;
uint64_t *tmp41 = tmp + (uint32_t)15U;
uint64_t *tmp51 = tmp + (uint32_t)20U;
uint64_t *tmp61 = tmp + (uint32_t)25U;
Hacl_Bignum25519_fdifference_reduced(tmp11, tmp41);
Hacl_Bignum25519_fdifference(tmp61, tmp51);
Hacl_Bignum25519_fsum(tmp51, tmp2);
Hacl_Bignum25519_fsum(tmp41, tmp3);
uint64_t *tmp12 = tmp;
uint64_t *tmp4 = tmp + (uint32_t)15U;
uint64_t *tmp5 = tmp + (uint32_t)20U;
uint64_t *tmp6 = tmp + (uint32_t)25U;
uint64_t *x3 = Hacl_Impl_Ed25519_ExtPoint_getx(out);
uint64_t *y3 = Hacl_Impl_Ed25519_ExtPoint_gety(out);
uint64_t *z3 = Hacl_Impl_Ed25519_ExtPoint_getz(out);
uint64_t *t3 = Hacl_Impl_Ed25519_ExtPoint_gett(out);
Hacl_Bignum25519_fmul(x3, tmp12, tmp6);
Hacl_Bignum25519_fmul(y3, tmp5, tmp4);
Hacl_Bignum25519_fmul(t3, tmp12, tmp4);
Hacl_Bignum25519_fmul(z3, tmp5, tmp6);
}