-
Notifications
You must be signed in to change notification settings - Fork 147
/
secp256k1_montgomery_scalar_64.c
2234 lines (2208 loc) · 92.5 KB
/
secp256k1_montgomery_scalar_64.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
/* Autogenerated: 'src/ExtractionOCaml/word_by_word_montgomery' --inline --static --use-value-barrier secp256k1_montgomery_scalar 64 '2^256 - 432420386565659656852420866394968145599' mul square add sub opp from_montgomery to_montgomery nonzero selectznz to_bytes from_bytes one msat divstep divstep_precomp */
/* curve description: secp256k1_montgomery_scalar */
/* machine_wordsize = 64 (from "64") */
/* requested operations: mul, square, add, sub, opp, from_montgomery, to_montgomery, nonzero, selectznz, to_bytes, from_bytes, one, msat, divstep, divstep_precomp */
/* m = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 (from "2^256 - 432420386565659656852420866394968145599") */
/* */
/* NOTE: In addition to the bounds specified above each function, all */
/* functions synthesized for this Montgomery arithmetic require the */
/* input to be strictly less than the prime modulus (m), and also */
/* require the input to be in the unique saturated representation. */
/* All functions also ensure that these two properties are true of */
/* return values. */
/* */
/* Computed values: */
/* eval z = z[0] + (z[1] << 64) + (z[2] << 128) + (z[3] << 192) */
/* bytes_eval z = z[0] + (z[1] << 8) + (z[2] << 16) + (z[3] << 24) + (z[4] << 32) + (z[5] << 40) + (z[6] << 48) + (z[7] << 56) + (z[8] << 64) + (z[9] << 72) + (z[10] << 80) + (z[11] << 88) + (z[12] << 96) + (z[13] << 104) + (z[14] << 112) + (z[15] << 120) + (z[16] << 128) + (z[17] << 136) + (z[18] << 144) + (z[19] << 152) + (z[20] << 160) + (z[21] << 168) + (z[22] << 176) + (z[23] << 184) + (z[24] << 192) + (z[25] << 200) + (z[26] << 208) + (z[27] << 216) + (z[28] << 224) + (z[29] << 232) + (z[30] << 240) + (z[31] << 248) */
/* twos_complement_eval z = let x1 := z[0] + (z[1] << 64) + (z[2] << 128) + (z[3] << 192) in */
/* if x1 & (2^256-1) < 2^255 then x1 & (2^256-1) else (x1 & (2^256-1)) - 2^256 */
#include <stdint.h>
typedef unsigned char fiat_secp256k1_montgomery_scalar_uint1;
typedef signed char fiat_secp256k1_montgomery_scalar_int1;
#if defined(__GNUC__) || defined(__clang__)
# define FIAT_SECP256K1_MONTGOMERY_SCALAR_FIAT_EXTENSION __extension__
# define FIAT_SECP256K1_MONTGOMERY_SCALAR_FIAT_INLINE __inline__
#else
# define FIAT_SECP256K1_MONTGOMERY_SCALAR_FIAT_EXTENSION
# define FIAT_SECP256K1_MONTGOMERY_SCALAR_FIAT_INLINE
#endif
FIAT_SECP256K1_MONTGOMERY_SCALAR_FIAT_EXTENSION typedef signed __int128 fiat_secp256k1_montgomery_scalar_int128;
FIAT_SECP256K1_MONTGOMERY_SCALAR_FIAT_EXTENSION typedef unsigned __int128 fiat_secp256k1_montgomery_scalar_uint128;
/* The type fiat_secp256k1_montgomery_scalar_montgomery_domain_field_element is a field element in the Montgomery domain. */
/* Bounds: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */
typedef uint64_t fiat_secp256k1_montgomery_scalar_montgomery_domain_field_element[4];
/* The type fiat_secp256k1_montgomery_scalar_non_montgomery_domain_field_element is a field element NOT in the Montgomery domain. */
/* Bounds: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */
typedef uint64_t fiat_secp256k1_montgomery_scalar_non_montgomery_domain_field_element[4];
#if (-1 & 3) != 3
#error "This code only works on a two's complement system"
#endif
#if !defined(FIAT_SECP256K1_MONTGOMERY_SCALAR_NO_ASM) && (defined(__GNUC__) || defined(__clang__))
static __inline__ uint64_t fiat_secp256k1_montgomery_scalar_value_barrier_u64(uint64_t a) {
__asm__("" : "+r"(a) : /* no inputs */);
return a;
}
#else
# define fiat_secp256k1_montgomery_scalar_value_barrier_u64(x) (x)
#endif
/*
* The function fiat_secp256k1_montgomery_scalar_addcarryx_u64 is an addition with carry.
*
* Postconditions:
* out1 = (arg1 + arg2 + arg3) mod 2^64
* out2 = ⌊(arg1 + arg2 + arg3) / 2^64⌋
*
* Input Bounds:
* arg1: [0x0 ~> 0x1]
* arg2: [0x0 ~> 0xffffffffffffffff]
* arg3: [0x0 ~> 0xffffffffffffffff]
* Output Bounds:
* out1: [0x0 ~> 0xffffffffffffffff]
* out2: [0x0 ~> 0x1]
*/
static FIAT_SECP256K1_MONTGOMERY_SCALAR_FIAT_INLINE void fiat_secp256k1_montgomery_scalar_addcarryx_u64(uint64_t* out1, fiat_secp256k1_montgomery_scalar_uint1* out2, fiat_secp256k1_montgomery_scalar_uint1 arg1, uint64_t arg2, uint64_t arg3) {
fiat_secp256k1_montgomery_scalar_uint128 x1;
uint64_t x2;
fiat_secp256k1_montgomery_scalar_uint1 x3;
x1 = ((arg1 + (fiat_secp256k1_montgomery_scalar_uint128)arg2) + arg3);
x2 = (uint64_t)(x1 & UINT64_C(0xffffffffffffffff));
x3 = (fiat_secp256k1_montgomery_scalar_uint1)(x1 >> 64);
*out1 = x2;
*out2 = x3;
}
/*
* The function fiat_secp256k1_montgomery_scalar_subborrowx_u64 is a subtraction with borrow.
*
* Postconditions:
* out1 = (-arg1 + arg2 + -arg3) mod 2^64
* out2 = -⌊(-arg1 + arg2 + -arg3) / 2^64⌋
*
* Input Bounds:
* arg1: [0x0 ~> 0x1]
* arg2: [0x0 ~> 0xffffffffffffffff]
* arg3: [0x0 ~> 0xffffffffffffffff]
* Output Bounds:
* out1: [0x0 ~> 0xffffffffffffffff]
* out2: [0x0 ~> 0x1]
*/
static FIAT_SECP256K1_MONTGOMERY_SCALAR_FIAT_INLINE void fiat_secp256k1_montgomery_scalar_subborrowx_u64(uint64_t* out1, fiat_secp256k1_montgomery_scalar_uint1* out2, fiat_secp256k1_montgomery_scalar_uint1 arg1, uint64_t arg2, uint64_t arg3) {
fiat_secp256k1_montgomery_scalar_int128 x1;
fiat_secp256k1_montgomery_scalar_int1 x2;
uint64_t x3;
x1 = ((arg2 - (fiat_secp256k1_montgomery_scalar_int128)arg1) - arg3);
x2 = (fiat_secp256k1_montgomery_scalar_int1)(x1 >> 64);
x3 = (uint64_t)(x1 & UINT64_C(0xffffffffffffffff));
*out1 = x3;
*out2 = (fiat_secp256k1_montgomery_scalar_uint1)(0x0 - x2);
}
/*
* The function fiat_secp256k1_montgomery_scalar_mulx_u64 is a multiplication, returning the full double-width result.
*
* Postconditions:
* out1 = (arg1 * arg2) mod 2^64
* out2 = ⌊arg1 * arg2 / 2^64⌋
*
* Input Bounds:
* arg1: [0x0 ~> 0xffffffffffffffff]
* arg2: [0x0 ~> 0xffffffffffffffff]
* Output Bounds:
* out1: [0x0 ~> 0xffffffffffffffff]
* out2: [0x0 ~> 0xffffffffffffffff]
*/
static FIAT_SECP256K1_MONTGOMERY_SCALAR_FIAT_INLINE void fiat_secp256k1_montgomery_scalar_mulx_u64(uint64_t* out1, uint64_t* out2, uint64_t arg1, uint64_t arg2) {
fiat_secp256k1_montgomery_scalar_uint128 x1;
uint64_t x2;
uint64_t x3;
x1 = ((fiat_secp256k1_montgomery_scalar_uint128)arg1 * arg2);
x2 = (uint64_t)(x1 & UINT64_C(0xffffffffffffffff));
x3 = (uint64_t)(x1 >> 64);
*out1 = x2;
*out2 = x3;
}
/*
* The function fiat_secp256k1_montgomery_scalar_cmovznz_u64 is a single-word conditional move.
*
* Postconditions:
* out1 = (if arg1 = 0 then arg2 else arg3)
*
* Input Bounds:
* arg1: [0x0 ~> 0x1]
* arg2: [0x0 ~> 0xffffffffffffffff]
* arg3: [0x0 ~> 0xffffffffffffffff]
* Output Bounds:
* out1: [0x0 ~> 0xffffffffffffffff]
*/
static FIAT_SECP256K1_MONTGOMERY_SCALAR_FIAT_INLINE void fiat_secp256k1_montgomery_scalar_cmovznz_u64(uint64_t* out1, fiat_secp256k1_montgomery_scalar_uint1 arg1, uint64_t arg2, uint64_t arg3) {
fiat_secp256k1_montgomery_scalar_uint1 x1;
uint64_t x2;
uint64_t x3;
x1 = (!(!arg1));
x2 = ((fiat_secp256k1_montgomery_scalar_int1)(0x0 - x1) & UINT64_C(0xffffffffffffffff));
x3 = ((fiat_secp256k1_montgomery_scalar_value_barrier_u64(x2) & arg3) | (fiat_secp256k1_montgomery_scalar_value_barrier_u64((~x2)) & arg2));
*out1 = x3;
}
/*
* The function fiat_secp256k1_montgomery_scalar_mul multiplies two field elements in the Montgomery domain.
*
* Preconditions:
* 0 ≤ eval arg1 < m
* 0 ≤ eval arg2 < m
* Postconditions:
* eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg2)) mod m
* 0 ≤ eval out1 < m
*
*/
static FIAT_SECP256K1_MONTGOMERY_SCALAR_FIAT_INLINE void fiat_secp256k1_montgomery_scalar_mul(fiat_secp256k1_montgomery_scalar_montgomery_domain_field_element out1, const fiat_secp256k1_montgomery_scalar_montgomery_domain_field_element arg1, const fiat_secp256k1_montgomery_scalar_montgomery_domain_field_element arg2) {
uint64_t x1;
uint64_t x2;
uint64_t x3;
uint64_t x4;
uint64_t x5;
uint64_t x6;
uint64_t x7;
uint64_t x8;
uint64_t x9;
uint64_t x10;
uint64_t x11;
uint64_t x12;
uint64_t x13;
fiat_secp256k1_montgomery_scalar_uint1 x14;
uint64_t x15;
fiat_secp256k1_montgomery_scalar_uint1 x16;
uint64_t x17;
fiat_secp256k1_montgomery_scalar_uint1 x18;
uint64_t x19;
uint64_t x20;
uint64_t x21;
uint64_t x22;
uint64_t x23;
uint64_t x24;
uint64_t x25;
uint64_t x26;
uint64_t x27;
uint64_t x28;
uint64_t x29;
uint64_t x30;
fiat_secp256k1_montgomery_scalar_uint1 x31;
uint64_t x32;
fiat_secp256k1_montgomery_scalar_uint1 x33;
uint64_t x34;
fiat_secp256k1_montgomery_scalar_uint1 x35;
uint64_t x36;
uint64_t x37;
fiat_secp256k1_montgomery_scalar_uint1 x38;
uint64_t x39;
fiat_secp256k1_montgomery_scalar_uint1 x40;
uint64_t x41;
fiat_secp256k1_montgomery_scalar_uint1 x42;
uint64_t x43;
fiat_secp256k1_montgomery_scalar_uint1 x44;
uint64_t x45;
fiat_secp256k1_montgomery_scalar_uint1 x46;
uint64_t x47;
uint64_t x48;
uint64_t x49;
uint64_t x50;
uint64_t x51;
uint64_t x52;
uint64_t x53;
uint64_t x54;
uint64_t x55;
fiat_secp256k1_montgomery_scalar_uint1 x56;
uint64_t x57;
fiat_secp256k1_montgomery_scalar_uint1 x58;
uint64_t x59;
fiat_secp256k1_montgomery_scalar_uint1 x60;
uint64_t x61;
uint64_t x62;
fiat_secp256k1_montgomery_scalar_uint1 x63;
uint64_t x64;
fiat_secp256k1_montgomery_scalar_uint1 x65;
uint64_t x66;
fiat_secp256k1_montgomery_scalar_uint1 x67;
uint64_t x68;
fiat_secp256k1_montgomery_scalar_uint1 x69;
uint64_t x70;
fiat_secp256k1_montgomery_scalar_uint1 x71;
uint64_t x72;
uint64_t x73;
uint64_t x74;
uint64_t x75;
uint64_t x76;
uint64_t x77;
uint64_t x78;
uint64_t x79;
uint64_t x80;
uint64_t x81;
uint64_t x82;
fiat_secp256k1_montgomery_scalar_uint1 x83;
uint64_t x84;
fiat_secp256k1_montgomery_scalar_uint1 x85;
uint64_t x86;
fiat_secp256k1_montgomery_scalar_uint1 x87;
uint64_t x88;
uint64_t x89;
fiat_secp256k1_montgomery_scalar_uint1 x90;
uint64_t x91;
fiat_secp256k1_montgomery_scalar_uint1 x92;
uint64_t x93;
fiat_secp256k1_montgomery_scalar_uint1 x94;
uint64_t x95;
fiat_secp256k1_montgomery_scalar_uint1 x96;
uint64_t x97;
fiat_secp256k1_montgomery_scalar_uint1 x98;
uint64_t x99;
uint64_t x100;
uint64_t x101;
uint64_t x102;
uint64_t x103;
uint64_t x104;
uint64_t x105;
uint64_t x106;
uint64_t x107;
uint64_t x108;
fiat_secp256k1_montgomery_scalar_uint1 x109;
uint64_t x110;
fiat_secp256k1_montgomery_scalar_uint1 x111;
uint64_t x112;
fiat_secp256k1_montgomery_scalar_uint1 x113;
uint64_t x114;
uint64_t x115;
fiat_secp256k1_montgomery_scalar_uint1 x116;
uint64_t x117;
fiat_secp256k1_montgomery_scalar_uint1 x118;
uint64_t x119;
fiat_secp256k1_montgomery_scalar_uint1 x120;
uint64_t x121;
fiat_secp256k1_montgomery_scalar_uint1 x122;
uint64_t x123;
fiat_secp256k1_montgomery_scalar_uint1 x124;
uint64_t x125;
uint64_t x126;
uint64_t x127;
uint64_t x128;
uint64_t x129;
uint64_t x130;
uint64_t x131;
uint64_t x132;
uint64_t x133;
uint64_t x134;
uint64_t x135;
fiat_secp256k1_montgomery_scalar_uint1 x136;
uint64_t x137;
fiat_secp256k1_montgomery_scalar_uint1 x138;
uint64_t x139;
fiat_secp256k1_montgomery_scalar_uint1 x140;
uint64_t x141;
uint64_t x142;
fiat_secp256k1_montgomery_scalar_uint1 x143;
uint64_t x144;
fiat_secp256k1_montgomery_scalar_uint1 x145;
uint64_t x146;
fiat_secp256k1_montgomery_scalar_uint1 x147;
uint64_t x148;
fiat_secp256k1_montgomery_scalar_uint1 x149;
uint64_t x150;
fiat_secp256k1_montgomery_scalar_uint1 x151;
uint64_t x152;
uint64_t x153;
uint64_t x154;
uint64_t x155;
uint64_t x156;
uint64_t x157;
uint64_t x158;
uint64_t x159;
uint64_t x160;
uint64_t x161;
fiat_secp256k1_montgomery_scalar_uint1 x162;
uint64_t x163;
fiat_secp256k1_montgomery_scalar_uint1 x164;
uint64_t x165;
fiat_secp256k1_montgomery_scalar_uint1 x166;
uint64_t x167;
uint64_t x168;
fiat_secp256k1_montgomery_scalar_uint1 x169;
uint64_t x170;
fiat_secp256k1_montgomery_scalar_uint1 x171;
uint64_t x172;
fiat_secp256k1_montgomery_scalar_uint1 x173;
uint64_t x174;
fiat_secp256k1_montgomery_scalar_uint1 x175;
uint64_t x176;
fiat_secp256k1_montgomery_scalar_uint1 x177;
uint64_t x178;
uint64_t x179;
uint64_t x180;
uint64_t x181;
uint64_t x182;
uint64_t x183;
uint64_t x184;
uint64_t x185;
uint64_t x186;
uint64_t x187;
uint64_t x188;
fiat_secp256k1_montgomery_scalar_uint1 x189;
uint64_t x190;
fiat_secp256k1_montgomery_scalar_uint1 x191;
uint64_t x192;
fiat_secp256k1_montgomery_scalar_uint1 x193;
uint64_t x194;
uint64_t x195;
fiat_secp256k1_montgomery_scalar_uint1 x196;
uint64_t x197;
fiat_secp256k1_montgomery_scalar_uint1 x198;
uint64_t x199;
fiat_secp256k1_montgomery_scalar_uint1 x200;
uint64_t x201;
fiat_secp256k1_montgomery_scalar_uint1 x202;
uint64_t x203;
fiat_secp256k1_montgomery_scalar_uint1 x204;
uint64_t x205;
uint64_t x206;
fiat_secp256k1_montgomery_scalar_uint1 x207;
uint64_t x208;
fiat_secp256k1_montgomery_scalar_uint1 x209;
uint64_t x210;
fiat_secp256k1_montgomery_scalar_uint1 x211;
uint64_t x212;
fiat_secp256k1_montgomery_scalar_uint1 x213;
uint64_t x214;
fiat_secp256k1_montgomery_scalar_uint1 x215;
uint64_t x216;
uint64_t x217;
uint64_t x218;
uint64_t x219;
x1 = (arg1[1]);
x2 = (arg1[2]);
x3 = (arg1[3]);
x4 = (arg1[0]);
fiat_secp256k1_montgomery_scalar_mulx_u64(&x5, &x6, x4, (arg2[3]));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x7, &x8, x4, (arg2[2]));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x9, &x10, x4, (arg2[1]));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x11, &x12, x4, (arg2[0]));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x13, &x14, 0x0, x12, x9);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x15, &x16, x14, x10, x7);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x17, &x18, x16, x8, x5);
x19 = (x18 + x6);
fiat_secp256k1_montgomery_scalar_mulx_u64(&x20, &x21, x11, UINT64_C(0x4b0dff665588b13f));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x22, &x23, x20, UINT64_C(0xffffffffffffffff));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x24, &x25, x20, UINT64_C(0xfffffffffffffffe));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x26, &x27, x20, UINT64_C(0xbaaedce6af48a03b));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x28, &x29, x20, UINT64_C(0xbfd25e8cd0364141));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x30, &x31, 0x0, x29, x26);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x32, &x33, x31, x27, x24);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x34, &x35, x33, x25, x22);
x36 = (x35 + x23);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x37, &x38, 0x0, x11, x28);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x39, &x40, x38, x13, x30);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x41, &x42, x40, x15, x32);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x43, &x44, x42, x17, x34);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x45, &x46, x44, x19, x36);
fiat_secp256k1_montgomery_scalar_mulx_u64(&x47, &x48, x1, (arg2[3]));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x49, &x50, x1, (arg2[2]));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x51, &x52, x1, (arg2[1]));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x53, &x54, x1, (arg2[0]));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x55, &x56, 0x0, x54, x51);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x57, &x58, x56, x52, x49);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x59, &x60, x58, x50, x47);
x61 = (x60 + x48);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x62, &x63, 0x0, x39, x53);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x64, &x65, x63, x41, x55);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x66, &x67, x65, x43, x57);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x68, &x69, x67, x45, x59);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x70, &x71, x69, x46, x61);
fiat_secp256k1_montgomery_scalar_mulx_u64(&x72, &x73, x62, UINT64_C(0x4b0dff665588b13f));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x74, &x75, x72, UINT64_C(0xffffffffffffffff));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x76, &x77, x72, UINT64_C(0xfffffffffffffffe));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x78, &x79, x72, UINT64_C(0xbaaedce6af48a03b));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x80, &x81, x72, UINT64_C(0xbfd25e8cd0364141));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x82, &x83, 0x0, x81, x78);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x84, &x85, x83, x79, x76);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x86, &x87, x85, x77, x74);
x88 = (x87 + x75);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x89, &x90, 0x0, x62, x80);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x91, &x92, x90, x64, x82);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x93, &x94, x92, x66, x84);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x95, &x96, x94, x68, x86);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x97, &x98, x96, x70, x88);
x99 = ((uint64_t)x98 + x71);
fiat_secp256k1_montgomery_scalar_mulx_u64(&x100, &x101, x2, (arg2[3]));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x102, &x103, x2, (arg2[2]));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x104, &x105, x2, (arg2[1]));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x106, &x107, x2, (arg2[0]));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x108, &x109, 0x0, x107, x104);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x110, &x111, x109, x105, x102);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x112, &x113, x111, x103, x100);
x114 = (x113 + x101);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x115, &x116, 0x0, x91, x106);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x117, &x118, x116, x93, x108);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x119, &x120, x118, x95, x110);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x121, &x122, x120, x97, x112);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x123, &x124, x122, x99, x114);
fiat_secp256k1_montgomery_scalar_mulx_u64(&x125, &x126, x115, UINT64_C(0x4b0dff665588b13f));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x127, &x128, x125, UINT64_C(0xffffffffffffffff));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x129, &x130, x125, UINT64_C(0xfffffffffffffffe));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x131, &x132, x125, UINT64_C(0xbaaedce6af48a03b));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x133, &x134, x125, UINT64_C(0xbfd25e8cd0364141));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x135, &x136, 0x0, x134, x131);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x137, &x138, x136, x132, x129);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x139, &x140, x138, x130, x127);
x141 = (x140 + x128);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x142, &x143, 0x0, x115, x133);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x144, &x145, x143, x117, x135);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x146, &x147, x145, x119, x137);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x148, &x149, x147, x121, x139);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x150, &x151, x149, x123, x141);
x152 = ((uint64_t)x151 + x124);
fiat_secp256k1_montgomery_scalar_mulx_u64(&x153, &x154, x3, (arg2[3]));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x155, &x156, x3, (arg2[2]));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x157, &x158, x3, (arg2[1]));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x159, &x160, x3, (arg2[0]));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x161, &x162, 0x0, x160, x157);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x163, &x164, x162, x158, x155);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x165, &x166, x164, x156, x153);
x167 = (x166 + x154);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x168, &x169, 0x0, x144, x159);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x170, &x171, x169, x146, x161);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x172, &x173, x171, x148, x163);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x174, &x175, x173, x150, x165);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x176, &x177, x175, x152, x167);
fiat_secp256k1_montgomery_scalar_mulx_u64(&x178, &x179, x168, UINT64_C(0x4b0dff665588b13f));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x180, &x181, x178, UINT64_C(0xffffffffffffffff));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x182, &x183, x178, UINT64_C(0xfffffffffffffffe));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x184, &x185, x178, UINT64_C(0xbaaedce6af48a03b));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x186, &x187, x178, UINT64_C(0xbfd25e8cd0364141));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x188, &x189, 0x0, x187, x184);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x190, &x191, x189, x185, x182);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x192, &x193, x191, x183, x180);
x194 = (x193 + x181);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x195, &x196, 0x0, x168, x186);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x197, &x198, x196, x170, x188);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x199, &x200, x198, x172, x190);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x201, &x202, x200, x174, x192);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x203, &x204, x202, x176, x194);
x205 = ((uint64_t)x204 + x177);
fiat_secp256k1_montgomery_scalar_subborrowx_u64(&x206, &x207, 0x0, x197, UINT64_C(0xbfd25e8cd0364141));
fiat_secp256k1_montgomery_scalar_subborrowx_u64(&x208, &x209, x207, x199, UINT64_C(0xbaaedce6af48a03b));
fiat_secp256k1_montgomery_scalar_subborrowx_u64(&x210, &x211, x209, x201, UINT64_C(0xfffffffffffffffe));
fiat_secp256k1_montgomery_scalar_subborrowx_u64(&x212, &x213, x211, x203, UINT64_C(0xffffffffffffffff));
fiat_secp256k1_montgomery_scalar_subborrowx_u64(&x214, &x215, x213, x205, 0x0);
fiat_secp256k1_montgomery_scalar_cmovznz_u64(&x216, x215, x206, x197);
fiat_secp256k1_montgomery_scalar_cmovznz_u64(&x217, x215, x208, x199);
fiat_secp256k1_montgomery_scalar_cmovznz_u64(&x218, x215, x210, x201);
fiat_secp256k1_montgomery_scalar_cmovznz_u64(&x219, x215, x212, x203);
out1[0] = x216;
out1[1] = x217;
out1[2] = x218;
out1[3] = x219;
}
/*
* The function fiat_secp256k1_montgomery_scalar_square squares a field element in the Montgomery domain.
*
* Preconditions:
* 0 ≤ eval arg1 < m
* Postconditions:
* eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg1)) mod m
* 0 ≤ eval out1 < m
*
*/
static FIAT_SECP256K1_MONTGOMERY_SCALAR_FIAT_INLINE void fiat_secp256k1_montgomery_scalar_square(fiat_secp256k1_montgomery_scalar_montgomery_domain_field_element out1, const fiat_secp256k1_montgomery_scalar_montgomery_domain_field_element arg1) {
uint64_t x1;
uint64_t x2;
uint64_t x3;
uint64_t x4;
uint64_t x5;
uint64_t x6;
uint64_t x7;
uint64_t x8;
uint64_t x9;
uint64_t x10;
uint64_t x11;
uint64_t x12;
uint64_t x13;
fiat_secp256k1_montgomery_scalar_uint1 x14;
uint64_t x15;
fiat_secp256k1_montgomery_scalar_uint1 x16;
uint64_t x17;
fiat_secp256k1_montgomery_scalar_uint1 x18;
uint64_t x19;
uint64_t x20;
uint64_t x21;
uint64_t x22;
uint64_t x23;
uint64_t x24;
uint64_t x25;
uint64_t x26;
uint64_t x27;
uint64_t x28;
uint64_t x29;
uint64_t x30;
fiat_secp256k1_montgomery_scalar_uint1 x31;
uint64_t x32;
fiat_secp256k1_montgomery_scalar_uint1 x33;
uint64_t x34;
fiat_secp256k1_montgomery_scalar_uint1 x35;
uint64_t x36;
uint64_t x37;
fiat_secp256k1_montgomery_scalar_uint1 x38;
uint64_t x39;
fiat_secp256k1_montgomery_scalar_uint1 x40;
uint64_t x41;
fiat_secp256k1_montgomery_scalar_uint1 x42;
uint64_t x43;
fiat_secp256k1_montgomery_scalar_uint1 x44;
uint64_t x45;
fiat_secp256k1_montgomery_scalar_uint1 x46;
uint64_t x47;
uint64_t x48;
uint64_t x49;
uint64_t x50;
uint64_t x51;
uint64_t x52;
uint64_t x53;
uint64_t x54;
uint64_t x55;
fiat_secp256k1_montgomery_scalar_uint1 x56;
uint64_t x57;
fiat_secp256k1_montgomery_scalar_uint1 x58;
uint64_t x59;
fiat_secp256k1_montgomery_scalar_uint1 x60;
uint64_t x61;
uint64_t x62;
fiat_secp256k1_montgomery_scalar_uint1 x63;
uint64_t x64;
fiat_secp256k1_montgomery_scalar_uint1 x65;
uint64_t x66;
fiat_secp256k1_montgomery_scalar_uint1 x67;
uint64_t x68;
fiat_secp256k1_montgomery_scalar_uint1 x69;
uint64_t x70;
fiat_secp256k1_montgomery_scalar_uint1 x71;
uint64_t x72;
uint64_t x73;
uint64_t x74;
uint64_t x75;
uint64_t x76;
uint64_t x77;
uint64_t x78;
uint64_t x79;
uint64_t x80;
uint64_t x81;
uint64_t x82;
fiat_secp256k1_montgomery_scalar_uint1 x83;
uint64_t x84;
fiat_secp256k1_montgomery_scalar_uint1 x85;
uint64_t x86;
fiat_secp256k1_montgomery_scalar_uint1 x87;
uint64_t x88;
uint64_t x89;
fiat_secp256k1_montgomery_scalar_uint1 x90;
uint64_t x91;
fiat_secp256k1_montgomery_scalar_uint1 x92;
uint64_t x93;
fiat_secp256k1_montgomery_scalar_uint1 x94;
uint64_t x95;
fiat_secp256k1_montgomery_scalar_uint1 x96;
uint64_t x97;
fiat_secp256k1_montgomery_scalar_uint1 x98;
uint64_t x99;
uint64_t x100;
uint64_t x101;
uint64_t x102;
uint64_t x103;
uint64_t x104;
uint64_t x105;
uint64_t x106;
uint64_t x107;
uint64_t x108;
fiat_secp256k1_montgomery_scalar_uint1 x109;
uint64_t x110;
fiat_secp256k1_montgomery_scalar_uint1 x111;
uint64_t x112;
fiat_secp256k1_montgomery_scalar_uint1 x113;
uint64_t x114;
uint64_t x115;
fiat_secp256k1_montgomery_scalar_uint1 x116;
uint64_t x117;
fiat_secp256k1_montgomery_scalar_uint1 x118;
uint64_t x119;
fiat_secp256k1_montgomery_scalar_uint1 x120;
uint64_t x121;
fiat_secp256k1_montgomery_scalar_uint1 x122;
uint64_t x123;
fiat_secp256k1_montgomery_scalar_uint1 x124;
uint64_t x125;
uint64_t x126;
uint64_t x127;
uint64_t x128;
uint64_t x129;
uint64_t x130;
uint64_t x131;
uint64_t x132;
uint64_t x133;
uint64_t x134;
uint64_t x135;
fiat_secp256k1_montgomery_scalar_uint1 x136;
uint64_t x137;
fiat_secp256k1_montgomery_scalar_uint1 x138;
uint64_t x139;
fiat_secp256k1_montgomery_scalar_uint1 x140;
uint64_t x141;
uint64_t x142;
fiat_secp256k1_montgomery_scalar_uint1 x143;
uint64_t x144;
fiat_secp256k1_montgomery_scalar_uint1 x145;
uint64_t x146;
fiat_secp256k1_montgomery_scalar_uint1 x147;
uint64_t x148;
fiat_secp256k1_montgomery_scalar_uint1 x149;
uint64_t x150;
fiat_secp256k1_montgomery_scalar_uint1 x151;
uint64_t x152;
uint64_t x153;
uint64_t x154;
uint64_t x155;
uint64_t x156;
uint64_t x157;
uint64_t x158;
uint64_t x159;
uint64_t x160;
uint64_t x161;
fiat_secp256k1_montgomery_scalar_uint1 x162;
uint64_t x163;
fiat_secp256k1_montgomery_scalar_uint1 x164;
uint64_t x165;
fiat_secp256k1_montgomery_scalar_uint1 x166;
uint64_t x167;
uint64_t x168;
fiat_secp256k1_montgomery_scalar_uint1 x169;
uint64_t x170;
fiat_secp256k1_montgomery_scalar_uint1 x171;
uint64_t x172;
fiat_secp256k1_montgomery_scalar_uint1 x173;
uint64_t x174;
fiat_secp256k1_montgomery_scalar_uint1 x175;
uint64_t x176;
fiat_secp256k1_montgomery_scalar_uint1 x177;
uint64_t x178;
uint64_t x179;
uint64_t x180;
uint64_t x181;
uint64_t x182;
uint64_t x183;
uint64_t x184;
uint64_t x185;
uint64_t x186;
uint64_t x187;
uint64_t x188;
fiat_secp256k1_montgomery_scalar_uint1 x189;
uint64_t x190;
fiat_secp256k1_montgomery_scalar_uint1 x191;
uint64_t x192;
fiat_secp256k1_montgomery_scalar_uint1 x193;
uint64_t x194;
uint64_t x195;
fiat_secp256k1_montgomery_scalar_uint1 x196;
uint64_t x197;
fiat_secp256k1_montgomery_scalar_uint1 x198;
uint64_t x199;
fiat_secp256k1_montgomery_scalar_uint1 x200;
uint64_t x201;
fiat_secp256k1_montgomery_scalar_uint1 x202;
uint64_t x203;
fiat_secp256k1_montgomery_scalar_uint1 x204;
uint64_t x205;
uint64_t x206;
fiat_secp256k1_montgomery_scalar_uint1 x207;
uint64_t x208;
fiat_secp256k1_montgomery_scalar_uint1 x209;
uint64_t x210;
fiat_secp256k1_montgomery_scalar_uint1 x211;
uint64_t x212;
fiat_secp256k1_montgomery_scalar_uint1 x213;
uint64_t x214;
fiat_secp256k1_montgomery_scalar_uint1 x215;
uint64_t x216;
uint64_t x217;
uint64_t x218;
uint64_t x219;
x1 = (arg1[1]);
x2 = (arg1[2]);
x3 = (arg1[3]);
x4 = (arg1[0]);
fiat_secp256k1_montgomery_scalar_mulx_u64(&x5, &x6, x4, (arg1[3]));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x7, &x8, x4, (arg1[2]));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x9, &x10, x4, (arg1[1]));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x11, &x12, x4, (arg1[0]));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x13, &x14, 0x0, x12, x9);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x15, &x16, x14, x10, x7);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x17, &x18, x16, x8, x5);
x19 = (x18 + x6);
fiat_secp256k1_montgomery_scalar_mulx_u64(&x20, &x21, x11, UINT64_C(0x4b0dff665588b13f));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x22, &x23, x20, UINT64_C(0xffffffffffffffff));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x24, &x25, x20, UINT64_C(0xfffffffffffffffe));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x26, &x27, x20, UINT64_C(0xbaaedce6af48a03b));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x28, &x29, x20, UINT64_C(0xbfd25e8cd0364141));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x30, &x31, 0x0, x29, x26);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x32, &x33, x31, x27, x24);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x34, &x35, x33, x25, x22);
x36 = (x35 + x23);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x37, &x38, 0x0, x11, x28);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x39, &x40, x38, x13, x30);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x41, &x42, x40, x15, x32);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x43, &x44, x42, x17, x34);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x45, &x46, x44, x19, x36);
fiat_secp256k1_montgomery_scalar_mulx_u64(&x47, &x48, x1, (arg1[3]));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x49, &x50, x1, (arg1[2]));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x51, &x52, x1, (arg1[1]));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x53, &x54, x1, (arg1[0]));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x55, &x56, 0x0, x54, x51);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x57, &x58, x56, x52, x49);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x59, &x60, x58, x50, x47);
x61 = (x60 + x48);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x62, &x63, 0x0, x39, x53);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x64, &x65, x63, x41, x55);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x66, &x67, x65, x43, x57);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x68, &x69, x67, x45, x59);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x70, &x71, x69, x46, x61);
fiat_secp256k1_montgomery_scalar_mulx_u64(&x72, &x73, x62, UINT64_C(0x4b0dff665588b13f));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x74, &x75, x72, UINT64_C(0xffffffffffffffff));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x76, &x77, x72, UINT64_C(0xfffffffffffffffe));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x78, &x79, x72, UINT64_C(0xbaaedce6af48a03b));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x80, &x81, x72, UINT64_C(0xbfd25e8cd0364141));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x82, &x83, 0x0, x81, x78);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x84, &x85, x83, x79, x76);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x86, &x87, x85, x77, x74);
x88 = (x87 + x75);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x89, &x90, 0x0, x62, x80);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x91, &x92, x90, x64, x82);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x93, &x94, x92, x66, x84);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x95, &x96, x94, x68, x86);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x97, &x98, x96, x70, x88);
x99 = ((uint64_t)x98 + x71);
fiat_secp256k1_montgomery_scalar_mulx_u64(&x100, &x101, x2, (arg1[3]));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x102, &x103, x2, (arg1[2]));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x104, &x105, x2, (arg1[1]));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x106, &x107, x2, (arg1[0]));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x108, &x109, 0x0, x107, x104);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x110, &x111, x109, x105, x102);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x112, &x113, x111, x103, x100);
x114 = (x113 + x101);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x115, &x116, 0x0, x91, x106);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x117, &x118, x116, x93, x108);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x119, &x120, x118, x95, x110);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x121, &x122, x120, x97, x112);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x123, &x124, x122, x99, x114);
fiat_secp256k1_montgomery_scalar_mulx_u64(&x125, &x126, x115, UINT64_C(0x4b0dff665588b13f));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x127, &x128, x125, UINT64_C(0xffffffffffffffff));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x129, &x130, x125, UINT64_C(0xfffffffffffffffe));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x131, &x132, x125, UINT64_C(0xbaaedce6af48a03b));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x133, &x134, x125, UINT64_C(0xbfd25e8cd0364141));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x135, &x136, 0x0, x134, x131);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x137, &x138, x136, x132, x129);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x139, &x140, x138, x130, x127);
x141 = (x140 + x128);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x142, &x143, 0x0, x115, x133);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x144, &x145, x143, x117, x135);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x146, &x147, x145, x119, x137);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x148, &x149, x147, x121, x139);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x150, &x151, x149, x123, x141);
x152 = ((uint64_t)x151 + x124);
fiat_secp256k1_montgomery_scalar_mulx_u64(&x153, &x154, x3, (arg1[3]));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x155, &x156, x3, (arg1[2]));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x157, &x158, x3, (arg1[1]));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x159, &x160, x3, (arg1[0]));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x161, &x162, 0x0, x160, x157);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x163, &x164, x162, x158, x155);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x165, &x166, x164, x156, x153);
x167 = (x166 + x154);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x168, &x169, 0x0, x144, x159);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x170, &x171, x169, x146, x161);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x172, &x173, x171, x148, x163);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x174, &x175, x173, x150, x165);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x176, &x177, x175, x152, x167);
fiat_secp256k1_montgomery_scalar_mulx_u64(&x178, &x179, x168, UINT64_C(0x4b0dff665588b13f));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x180, &x181, x178, UINT64_C(0xffffffffffffffff));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x182, &x183, x178, UINT64_C(0xfffffffffffffffe));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x184, &x185, x178, UINT64_C(0xbaaedce6af48a03b));
fiat_secp256k1_montgomery_scalar_mulx_u64(&x186, &x187, x178, UINT64_C(0xbfd25e8cd0364141));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x188, &x189, 0x0, x187, x184);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x190, &x191, x189, x185, x182);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x192, &x193, x191, x183, x180);
x194 = (x193 + x181);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x195, &x196, 0x0, x168, x186);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x197, &x198, x196, x170, x188);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x199, &x200, x198, x172, x190);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x201, &x202, x200, x174, x192);
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x203, &x204, x202, x176, x194);
x205 = ((uint64_t)x204 + x177);
fiat_secp256k1_montgomery_scalar_subborrowx_u64(&x206, &x207, 0x0, x197, UINT64_C(0xbfd25e8cd0364141));
fiat_secp256k1_montgomery_scalar_subborrowx_u64(&x208, &x209, x207, x199, UINT64_C(0xbaaedce6af48a03b));
fiat_secp256k1_montgomery_scalar_subborrowx_u64(&x210, &x211, x209, x201, UINT64_C(0xfffffffffffffffe));
fiat_secp256k1_montgomery_scalar_subborrowx_u64(&x212, &x213, x211, x203, UINT64_C(0xffffffffffffffff));
fiat_secp256k1_montgomery_scalar_subborrowx_u64(&x214, &x215, x213, x205, 0x0);
fiat_secp256k1_montgomery_scalar_cmovznz_u64(&x216, x215, x206, x197);
fiat_secp256k1_montgomery_scalar_cmovznz_u64(&x217, x215, x208, x199);
fiat_secp256k1_montgomery_scalar_cmovznz_u64(&x218, x215, x210, x201);
fiat_secp256k1_montgomery_scalar_cmovznz_u64(&x219, x215, x212, x203);
out1[0] = x216;
out1[1] = x217;
out1[2] = x218;
out1[3] = x219;
}
/*
* The function fiat_secp256k1_montgomery_scalar_add adds two field elements in the Montgomery domain.
*
* Preconditions:
* 0 ≤ eval arg1 < m
* 0 ≤ eval arg2 < m
* Postconditions:
* eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) + eval (from_montgomery arg2)) mod m
* 0 ≤ eval out1 < m
*
*/
static FIAT_SECP256K1_MONTGOMERY_SCALAR_FIAT_INLINE void fiat_secp256k1_montgomery_scalar_add(fiat_secp256k1_montgomery_scalar_montgomery_domain_field_element out1, const fiat_secp256k1_montgomery_scalar_montgomery_domain_field_element arg1, const fiat_secp256k1_montgomery_scalar_montgomery_domain_field_element arg2) {
uint64_t x1;
fiat_secp256k1_montgomery_scalar_uint1 x2;
uint64_t x3;
fiat_secp256k1_montgomery_scalar_uint1 x4;
uint64_t x5;
fiat_secp256k1_montgomery_scalar_uint1 x6;
uint64_t x7;
fiat_secp256k1_montgomery_scalar_uint1 x8;
uint64_t x9;
fiat_secp256k1_montgomery_scalar_uint1 x10;
uint64_t x11;
fiat_secp256k1_montgomery_scalar_uint1 x12;
uint64_t x13;
fiat_secp256k1_montgomery_scalar_uint1 x14;
uint64_t x15;
fiat_secp256k1_montgomery_scalar_uint1 x16;
uint64_t x17;
fiat_secp256k1_montgomery_scalar_uint1 x18;
uint64_t x19;
uint64_t x20;
uint64_t x21;
uint64_t x22;
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x1, &x2, 0x0, (arg1[0]), (arg2[0]));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x3, &x4, x2, (arg1[1]), (arg2[1]));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x5, &x6, x4, (arg1[2]), (arg2[2]));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x7, &x8, x6, (arg1[3]), (arg2[3]));
fiat_secp256k1_montgomery_scalar_subborrowx_u64(&x9, &x10, 0x0, x1, UINT64_C(0xbfd25e8cd0364141));
fiat_secp256k1_montgomery_scalar_subborrowx_u64(&x11, &x12, x10, x3, UINT64_C(0xbaaedce6af48a03b));
fiat_secp256k1_montgomery_scalar_subborrowx_u64(&x13, &x14, x12, x5, UINT64_C(0xfffffffffffffffe));
fiat_secp256k1_montgomery_scalar_subborrowx_u64(&x15, &x16, x14, x7, UINT64_C(0xffffffffffffffff));
fiat_secp256k1_montgomery_scalar_subborrowx_u64(&x17, &x18, x16, x8, 0x0);
fiat_secp256k1_montgomery_scalar_cmovznz_u64(&x19, x18, x9, x1);
fiat_secp256k1_montgomery_scalar_cmovznz_u64(&x20, x18, x11, x3);
fiat_secp256k1_montgomery_scalar_cmovznz_u64(&x21, x18, x13, x5);
fiat_secp256k1_montgomery_scalar_cmovznz_u64(&x22, x18, x15, x7);
out1[0] = x19;
out1[1] = x20;
out1[2] = x21;
out1[3] = x22;
}
/*
* The function fiat_secp256k1_montgomery_scalar_sub subtracts two field elements in the Montgomery domain.
*
* Preconditions:
* 0 ≤ eval arg1 < m
* 0 ≤ eval arg2 < m
* Postconditions:
* eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) - eval (from_montgomery arg2)) mod m
* 0 ≤ eval out1 < m
*
*/
static FIAT_SECP256K1_MONTGOMERY_SCALAR_FIAT_INLINE void fiat_secp256k1_montgomery_scalar_sub(fiat_secp256k1_montgomery_scalar_montgomery_domain_field_element out1, const fiat_secp256k1_montgomery_scalar_montgomery_domain_field_element arg1, const fiat_secp256k1_montgomery_scalar_montgomery_domain_field_element arg2) {
uint64_t x1;
fiat_secp256k1_montgomery_scalar_uint1 x2;
uint64_t x3;
fiat_secp256k1_montgomery_scalar_uint1 x4;
uint64_t x5;
fiat_secp256k1_montgomery_scalar_uint1 x6;
uint64_t x7;
fiat_secp256k1_montgomery_scalar_uint1 x8;
uint64_t x9;
uint64_t x10;
fiat_secp256k1_montgomery_scalar_uint1 x11;
uint64_t x12;
fiat_secp256k1_montgomery_scalar_uint1 x13;
uint64_t x14;
fiat_secp256k1_montgomery_scalar_uint1 x15;
uint64_t x16;
fiat_secp256k1_montgomery_scalar_uint1 x17;
fiat_secp256k1_montgomery_scalar_subborrowx_u64(&x1, &x2, 0x0, (arg1[0]), (arg2[0]));
fiat_secp256k1_montgomery_scalar_subborrowx_u64(&x3, &x4, x2, (arg1[1]), (arg2[1]));
fiat_secp256k1_montgomery_scalar_subborrowx_u64(&x5, &x6, x4, (arg1[2]), (arg2[2]));
fiat_secp256k1_montgomery_scalar_subborrowx_u64(&x7, &x8, x6, (arg1[3]), (arg2[3]));
fiat_secp256k1_montgomery_scalar_cmovznz_u64(&x9, x8, 0x0, UINT64_C(0xffffffffffffffff));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x10, &x11, 0x0, x1, (x9 & UINT64_C(0xbfd25e8cd0364141)));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x12, &x13, x11, x3, (x9 & UINT64_C(0xbaaedce6af48a03b)));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x14, &x15, x13, x5, (x9 & UINT64_C(0xfffffffffffffffe)));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x16, &x17, x15, x7, x9);
out1[0] = x10;
out1[1] = x12;
out1[2] = x14;
out1[3] = x16;
}
/*
* The function fiat_secp256k1_montgomery_scalar_opp negates a field element in the Montgomery domain.
*
* Preconditions:
* 0 ≤ eval arg1 < m
* Postconditions:
* eval (from_montgomery out1) mod m = -eval (from_montgomery arg1) mod m
* 0 ≤ eval out1 < m
*
*/
static FIAT_SECP256K1_MONTGOMERY_SCALAR_FIAT_INLINE void fiat_secp256k1_montgomery_scalar_opp(fiat_secp256k1_montgomery_scalar_montgomery_domain_field_element out1, const fiat_secp256k1_montgomery_scalar_montgomery_domain_field_element arg1) {
uint64_t x1;
fiat_secp256k1_montgomery_scalar_uint1 x2;
uint64_t x3;
fiat_secp256k1_montgomery_scalar_uint1 x4;
uint64_t x5;
fiat_secp256k1_montgomery_scalar_uint1 x6;
uint64_t x7;
fiat_secp256k1_montgomery_scalar_uint1 x8;
uint64_t x9;
uint64_t x10;
fiat_secp256k1_montgomery_scalar_uint1 x11;
uint64_t x12;
fiat_secp256k1_montgomery_scalar_uint1 x13;
uint64_t x14;
fiat_secp256k1_montgomery_scalar_uint1 x15;
uint64_t x16;
fiat_secp256k1_montgomery_scalar_uint1 x17;
fiat_secp256k1_montgomery_scalar_subborrowx_u64(&x1, &x2, 0x0, 0x0, (arg1[0]));
fiat_secp256k1_montgomery_scalar_subborrowx_u64(&x3, &x4, x2, 0x0, (arg1[1]));
fiat_secp256k1_montgomery_scalar_subborrowx_u64(&x5, &x6, x4, 0x0, (arg1[2]));
fiat_secp256k1_montgomery_scalar_subborrowx_u64(&x7, &x8, x6, 0x0, (arg1[3]));
fiat_secp256k1_montgomery_scalar_cmovznz_u64(&x9, x8, 0x0, UINT64_C(0xffffffffffffffff));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x10, &x11, 0x0, x1, (x9 & UINT64_C(0xbfd25e8cd0364141)));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x12, &x13, x11, x3, (x9 & UINT64_C(0xbaaedce6af48a03b)));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x14, &x15, x13, x5, (x9 & UINT64_C(0xfffffffffffffffe)));
fiat_secp256k1_montgomery_scalar_addcarryx_u64(&x16, &x17, x15, x7, x9);