-
Notifications
You must be signed in to change notification settings - Fork 1
/
bls12_381.huff
3241 lines (3241 loc) · 75.9 KB
/
bls12_381.huff
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
#include "inversemod/inversemod_bls12381.huff"
#define macro INIT_MEM = takes(0) returns(0) {
0xfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce77 0x6c0 mstore
0xba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615 0x6d0 mstore
0xabaafffffffffeb9ffff53b1feffab1e24f6b0f6a0d23067bf1285f3844b7764 0x900 mstore
0xbf1285f3844b7764d7ac4b43b6a71b4b9ae67f39ea11011afdfffcfffcfff389 0x918 mstore
0x30 0x900 setmod
} // INIT_MEM
#define macro MILLER_LOOP = takes(0) returns(0) {
addmodmont 0x580a383c383c
submodmont 0x580a8004580a
addmodmont 0x880a683c683c
addmodmont 0x3809983c8004
addmodmont 0x6809c83c8004
addmodmont 0x9809f83c8004
addmodmont 0xc809283d8004
addmodmont 0xf809c0068004
addmodmont 0x280af0068004
///////////
// Edouble https://www.hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#doubling-dbl-2009-alnr
// A = X1^2
// f2sqr
addmodmont 0xd80b38096809
submodmont 0x080c38096809
mulmodmont 0xf82138096809
addmodmont 0xf821f821f821
mulmodmont 0xc821d80b080c
// B = Y1^2
// f2sqr
addmodmont 0xd80b9809c809
submodmont 0x080c9809c809
mulmodmont 0x58229809c809
addmodmont 0x582258225822
mulmodmont 0x2822d80b080c
// ZZ = Z1^2
// f2sqr
addmodmont 0xd80bf809280a
submodmont 0x080cf809280a
mulmodmont 0xb822f809280a
addmodmont 0xb822b822b822
mulmodmont 0x8822d80b080c
// C = B^2
// f2sqr
addmodmont 0xd80b28225822
submodmont 0x080c28225822
mulmodmont 0x182328225822
addmodmont 0x182318231823
mulmodmont 0xe822d80b080c
// D = 2*((X1+B)^2-A-C)
// f2 add
addmodmont 0x482338092822
addmodmont 0x782368095822
// f2sqr
addmodmont 0xd80b48237823
submodmont 0x080c48237823
mulmodmont 0x782348237823
addmodmont 0x782378237823
mulmodmont 0x4823d80b080c
// f2 sub
submodmont 0x48234823c821
submodmont 0x78237823f821
// f2 sub
submodmont 0x48234823e822
submodmont 0x782378231823
// f2 add
addmodmont 0x482348234823
addmodmont 0x782378237823
// E = 3*A
// f2 add
addmodmont 0xa823c821c821
addmodmont 0xd823f821f821
// f2 add
addmodmont 0xa823a823c821
addmodmont 0xd823d823f821
// F = E^2
// f2sqr
addmodmont 0xd80ba823d823
submodmont 0x080ca823d823
mulmodmont 0x3824a823d823
addmodmont 0x382438243824
mulmodmont 0x0824d80b080c
// line0 = E+X1, this is useful for pairing
// f2 add
addmodmont 0xb80aa8233809
addmodmont 0xe80ad8236809
// X3 = F-2*D
// f2 sub
submodmont 0x380908244823
submodmont 0x680938247823
// f2 sub
submodmont 0x380938094823
submodmont 0x680968097823
// Z3 = (Y1+Z1)^2-B-ZZ
// f2 add
addmodmont 0xf8099809f809
addmodmont 0x280ac809280a
// f2sqr
addmodmont 0xd80bf809280a
submodmont 0x080cf809280a
mulmodmont 0x280af809280a
addmodmont 0x280a280a280a
mulmodmont 0xf809d80b080c
// f2 sub
submodmont 0xf809f8092822
submodmont 0x280a280a5822
// f2 sub
submodmont 0xf809f8098822
submodmont 0x280a280ab822
// Y3 = E*(D-X3)-8*C
// f2 sub
submodmont 0x980948233809
submodmont 0xc80978236809
// f2 mul
addmodmont 0xd80ba823d823
addmodmont 0x080c9809c809
mulmodmont 0x080c080cd80b
mulmodmont 0xd80ba8239809
mulmodmont 0x380cd823c809
submodmont 0x9809d80b380c
submodmont 0xc809080cd80b
submodmont 0xc809c809380c
// f2 add
addmodmont 0xe822e822e822
addmodmont 0x182318231823
// f2 add
addmodmont 0xe822e822e822
addmodmont 0x182318231823
// f2 add
addmodmont 0xe822e822e822
addmodmont 0x182318231823
// f2 sub
submodmont 0x98099809e822
submodmont 0xc809c8091823
// E double
////////////
// f2sqr
addmodmont 0xd80bb80ae80a
submodmont 0x080cb80ae80a
mulmodmont 0xe80ab80ae80a
addmodmont 0xe80ae80ae80a
mulmodmont 0xb80ad80b080c
// f2 sub
submodmont 0xb80ab80ac821
submodmont 0xe80ae80af821
// f2 sub
submodmont 0xb80ab80a0824
submodmont 0xe80ae80a3824
// f2 add
addmodmont 0x282228222822
addmodmont 0x582258225822
// f2 add
addmodmont 0x282228222822
addmodmont 0x582258225822
// f2 sub
submodmont 0xb80ab80a2822
submodmont 0xe80ae80a5822
// f2 mul
addmodmont 0xd80ba823d823
addmodmont 0x080c8822b822
mulmodmont 0x080c080cd80b
mulmodmont 0xd80ba8238822
mulmodmont 0x380cd823b822
submodmont 0x180bd80b380c
submodmont 0x480b080cd80b
submodmont 0x480b480b380c
// f2 mul
addmodmont 0xd80bf809280a
addmodmont 0x080c8822b822
mulmodmont 0x080c080cd80b
mulmodmont 0xd80bf8098822
mulmodmont 0x380c280ab822
submodmont 0x780bd80b380c
submodmont 0xa80b080cd80b
submodmont 0xa80ba80b380c
mulmodmont 0x180b180b580a
mulmodmont 0x480b480b580a
mulmodmont 0x780b780b880a
mulmodmont 0xa80ba80b880a
addmodmont 0x000080048004
addmodmont 0x3000b0048004
addmodmont 0x6000e0048004
addmodmont 0x900010058004
addmodmont 0xc00040058004
addmodmont 0xf00070058004
addmodmont 0x2001a0058004
addmodmont 0x5001d0058004
addmodmont 0x800100068004
addmodmont 0xb00130068004
addmodmont 0xe00160068004
addmodmont 0x100290068004
addmodmont 0x0000b80a8004
addmodmont 0x3000e80a8004
addmodmont 0x6000180b8004
addmodmont 0x9000480b8004
addmodmont 0x8001780b8004
addmodmont 0xb001a80b8004
63
miller_loop1:
0x1 swap1 sub
0xd201000000010000 dup2 shr
0x1 and
0x1 xor end_if1 jumpi
begin_if1:
/////////
// Eadd https://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#addition-madd-2007-bl
// Z1Z1 = Z1^2
// f2sqr
addmodmont 0xd80bf809280a
submodmont 0x080cf809280a
mulmodmont 0x3812f809280a
addmodmont 0x381238123812
mulmodmont 0x0812d80b080c
// U2 = X2*Z1Z1
// f2 mul
addmodmont 0xd80b983cc83c
addmodmont 0x080c08123812
mulmodmont 0x080c080cd80b
mulmodmont 0xd80b983c0812
mulmodmont 0x380cc83c3812
submodmont 0x6812d80b380c
submodmont 0x9812080cd80b
submodmont 0x98129812380c
// S2 = Y2*Z1*Z1Z1
// f2 mul
addmodmont 0xd80bf83c283d
addmodmont 0x080cf809280a
mulmodmont 0x080c080cd80b
mulmodmont 0xd80bf83cf809
mulmodmont 0x380c283d280a
submodmont 0xc812d80b380c
submodmont 0xf812080cd80b
submodmont 0xf812f812380c
// f2 mul
addmodmont 0xd80bc812f812
addmodmont 0x080c08123812
mulmodmont 0x080c080cd80b
mulmodmont 0xd80bc8120812
mulmodmont 0x380cf8123812
submodmont 0xc812d80b380c
submodmont 0xf812080cd80b
submodmont 0xf812f812380c
// H = U2-X1
// f2 sub
submodmont 0x281368123809
submodmont 0x581398126809
// HH = H^2
// f2sqr
addmodmont 0xd80b28135813
submodmont 0x080c28135813
mulmodmont 0xb81328135813
addmodmont 0xb813b813b813
mulmodmont 0x8813d80b080c
// I = 4*HH
// f2 add
addmodmont 0xe81388138813
addmodmont 0x1814b813b813
// f2 add
addmodmont 0xe813e813e813
addmodmont 0x181418141814
// J = H*I
// f2 mul
addmodmont 0xd80b28135813
addmodmont 0x080ce8131814
mulmodmont 0x080c080cd80b
mulmodmont 0xd80b2813e813
mulmodmont 0x380c58131814
submodmont 0x4814d80b380c
submodmont 0x7814080cd80b
submodmont 0x78147814380c
// r = 2*(S2-Y1)
// f2 sub
submodmont 0x180bc8129809
submodmont 0x480bf812c809
// f2 add
addmodmont 0x180b180b180b
addmodmont 0x480b480b480b
// V = X1*I
// f2 mul
addmodmont 0xd80b38096809
addmodmont 0x080ce8131814
mulmodmont 0x080c080cd80b
mulmodmont 0xd80b3809e813
mulmodmont 0x380c68091814
submodmont 0xa814d80b380c
submodmont 0xd814080cd80b
submodmont 0xd814d814380c
// X3 = r^2-J-2*V
// f2sqr
addmodmont 0xd80b180b480b
submodmont 0x080c180b480b
mulmodmont 0x6809180b480b
addmodmont 0x680968096809
mulmodmont 0x3809d80b080c
// f2 sub
submodmont 0x380938094814
submodmont 0x680968097814
// f2 sub
submodmont 0x38093809a814
submodmont 0x68096809d814
// f2 sub
submodmont 0x38093809a814
submodmont 0x68096809d814
// Y3 = r*(V-X3)-2*Y1*J
// f2 mul
addmodmont 0xd80b48147814
addmodmont 0x080c9809c809
mulmodmont 0x080c080cd80b
mulmodmont 0xd80b48149809
mulmodmont 0x380c7814c809
submodmont 0x4814d80b380c
submodmont 0x7814080cd80b
submodmont 0x78147814380c
// f2 sub
submodmont 0x9809a8143809
submodmont 0xc809d8146809
// f2 mul
addmodmont 0xd80b9809c809
addmodmont 0x080c180b480b
mulmodmont 0x080c080cd80b
mulmodmont 0xd80b9809180b
mulmodmont 0x380cc809480b
submodmont 0x9809d80b380c
submodmont 0xc809080cd80b
submodmont 0xc809c809380c
// f2 sub
submodmont 0x980998094814
submodmont 0xc809c8097814
// f2 sub
submodmont 0x980998094814
submodmont 0xc809c8097814
// Z3 = (Z1+H)^2-Z1Z1-HH
// f2 add
addmodmont 0xf809f8092813
addmodmont 0x280a280a5813
// f2sqr
addmodmont 0xd80bf809280a
submodmont 0x080cf809280a
mulmodmont 0x280af809280a
addmodmont 0x280a280a280a
mulmodmont 0xf809d80b080c
// f2 sub
submodmont 0xf809f8090812
submodmont 0x280a280a3812
// f2 sub
submodmont 0xf809f8098813
submodmont 0x280a280ab813
// E add
/////////
// f2 mul
addmodmont 0xd80b180b480b
addmodmont 0x080c983cc83c
mulmodmont 0x080c080cd80b
mulmodmont 0xd80b180b983c
mulmodmont 0x380c480bc83c
submodmont 0xe813d80b380c
submodmont 0x1814080cd80b
submodmont 0x18141814380c
// f2 mul
addmodmont 0xd80bf83c283d
addmodmont 0x080cf809280a
mulmodmont 0x080c080cd80b
mulmodmont 0xd80bf83cf809
mulmodmont 0x380c283d280a
submodmont 0x4814d80b380c
submodmont 0x7814080cd80b
submodmont 0x78147814380c
// f2 sub
submodmont 0xe813e8134814
submodmont 0x181418147814
// f2 add
addmodmont 0xb80ae813e813
addmodmont 0xe80a18141814
addmodmont 0x780bf8098004
addmodmont 0xa80b280a8004
mulmodmont 0x180b180b580a
mulmodmont 0x480b480b580a
mulmodmont 0x780b780b880a
mulmodmont 0xa80ba80b880a
// f2 mul
addmodmont 0xd80b00003000
addmodmont 0x080cb80ae80a
mulmodmont 0x080c080cd80b
mulmodmont 0xd80b0000b80a
mulmodmont 0x380c3000e80a
submodmont 0x680cd80b380c
submodmont 0x980c080cd80b
submodmont 0x980c980c380c
// f2 mul
addmodmont 0xd80b60009000
addmodmont 0x080c180b480b
mulmodmont 0x080c080cd80b
mulmodmont 0xd80b6000180b
mulmodmont 0x380c9000480b
submodmont 0xc80cd80b380c
submodmont 0xf80c080cd80b
submodmont 0xf80cf80c380c
// f2 mul
addmodmont 0xd80bc000f000
addmodmont 0x080c180b480b
mulmodmont 0x080c080cd80b
mulmodmont 0xd80bc000180b
mulmodmont 0x380cf000480b
submodmont 0x880dd80b380c
submodmont 0xb80d080cd80b
submodmont 0xb80db80d380c
addmodmont 0xd80b880db80d
submodmont 0x880d880db80d
addmodmont 0xb80dd80b8004
// f2 add
addmodmont 0xe80d00006000
addmodmont 0x180e30009000
// f2 add
addmodmont 0x480eb80a180b
addmodmont 0x780ee80a480b
// f2 mul
addmodmont 0xd80be80d180e
addmodmont 0x080c480e780e
mulmodmont 0x080c080cd80b
mulmodmont 0xd80be80d480e
mulmodmont 0x380c180e780e
submodmont 0x080fd80b380c
submodmont 0x380f080cd80b
submodmont 0x380f380f380c
// f2 sub
submodmont 0x080f080f680c
submodmont 0x380f380f980c
// f2 sub
submodmont 0x080f080fc80c
submodmont 0x380f380ff80c
// f2 mul
addmodmont 0xd80bc000f000
addmodmont 0x080cb80ae80a
mulmodmont 0x080c080cd80b
mulmodmont 0xd80bc000b80a
mulmodmont 0x380cf000e80a
submodmont 0x680fd80b380c
submodmont 0x980f080cd80b
submodmont 0x980f980f380c
// f2 add
addmodmont 0x680f680fc80c
addmodmont 0x980f980ff80c
// f2 add
addmodmont 0xa80e880d680c
addmodmont 0xd80eb80d980c
// f2 mul
addmodmont 0xd80be0011002
addmodmont 0x080c780ba80b
mulmodmont 0x080c080cd80b
mulmodmont 0xd80be001780b
mulmodmont 0x380c1002a80b
submodmont 0x680cd80b380c
submodmont 0x980c080cd80b
submodmont 0x980c980c380c
// f2 mul
addmodmont 0xd80b8001b001
addmodmont 0x080c780ba80b
mulmodmont 0x080c080cd80b
mulmodmont 0xd80b8001780b
mulmodmont 0x380cb001a80b
submodmont 0x8810d80b380c
submodmont 0xb810080cd80b
submodmont 0xb810b810380c
// f2 mul
addmodmont 0xd80b20015001
addmodmont 0x080c780ba80b
mulmodmont 0x080c080cd80b
mulmodmont 0xd80b2001780b
mulmodmont 0x380c5001a80b
submodmont 0x2810d80b380c
submodmont 0x5810080cd80b
submodmont 0x58105810380c
addmodmont 0xd80b680c980c
submodmont 0xc80f680c980c
addmodmont 0xf80fd80b8004
addmodmont 0xe810b80a8004
addmodmont 0x1811e80a8004
// f2 add
addmodmont 0x4811180b780b
addmodmont 0x7811480ba80b
// f6 add
// f2 add
addmodmont 0x200100002001
addmodmont 0x500130005001
// f2 add
addmodmont 0x800160008001
addmodmont 0xb0019000b001
// f2 add
addmodmont 0xe001c000e001
addmodmont 0x1002f0001002
// f2 mul
addmodmont 0xd80b20015001
addmodmont 0x080ce8101811
mulmodmont 0x080c080cd80b
mulmodmont 0xd80b2001e810
mulmodmont 0x380c50011811
submodmont 0x680cd80b380c
submodmont 0x980c080cd80b
submodmont 0x980c980c380c
// f2 mul
addmodmont 0xd80b8001b001
addmodmont 0x080c48117811
mulmodmont 0x080c080cd80b
mulmodmont 0xd80b80014811
mulmodmont 0x380cb0017811
submodmont 0xc80cd80b380c
submodmont 0xf80c080cd80b
submodmont 0xf80cf80c380c
// f2 mul
addmodmont 0xd80be0011002
addmodmont 0x080c48117811
mulmodmont 0x080c080cd80b
mulmodmont 0xd80be0014811
mulmodmont 0x380c10027811
submodmont 0x880dd80b380c
submodmont 0xb80d080cd80b
submodmont 0xb80db80d380c
addmodmont 0xd80b880db80d
submodmont 0x880d880db80d
addmodmont 0xb80dd80b8004
// f2 add
addmodmont 0xe80d20018001
addmodmont 0x180e5001b001
// f2 add
addmodmont 0x480ee8104811
addmodmont 0x780e18117811
// f2 mul
addmodmont 0xd80be80d180e
addmodmont 0x080c480e780e
mulmodmont 0x080c080cd80b
mulmodmont 0xd80be80d480e
mulmodmont 0x380c180e780e
submodmont 0x8001d80b380c
submodmont 0xb001080cd80b
submodmont 0xb001b001380c
// f2 sub
submodmont 0x80018001680c
submodmont 0xb001b001980c
// f2 sub
submodmont 0x80018001c80c
submodmont 0xb001b001f80c
// f2 mul
addmodmont 0xd80be0011002
addmodmont 0x080ce8101811
mulmodmont 0x080c080cd80b
mulmodmont 0xd80be001e810
mulmodmont 0x380c10021811
submodmont 0xe001d80b380c
submodmont 0x1002080cd80b
submodmont 0x10021002380c
// f2 add
addmodmont 0xe001e001c80c
addmodmont 0x10021002f80c
// f2 add
addmodmont 0x2001880d680c
addmodmont 0x5001b80d980c
// f6 sub
// f2 sub
submodmont 0x20012001a80e
submodmont 0x50015001d80e
// f2 sub
submodmont 0x80018001080f
submodmont 0xb001b001380f
// f2 sub
submodmont 0xe001e001680f
submodmont 0x10021002980f
// f6 sub
// f2 sub
submodmont 0x20012001c80f
submodmont 0x50015001f80f
// f2 sub
submodmont 0x800180012810
submodmont 0xb001b0015810
// f2 sub
submodmont 0xe001e0018810
submodmont 0x10021002b810
addmodmont 0xd80b8810b810
submodmont 0x88108810b810
addmodmont 0xb810d80b8004
// f2 add
addmodmont 0x0000a80e8810
addmodmont 0x3000d80eb810
// f2 add
addmodmont 0x6000080fc80f
addmodmont 0x9000380ff80f
// f2 add
addmodmont 0xc000680f2810
addmodmont 0xf000980f5810
end_if1:
// f12sqr begin
// f6 add
// f2 add
addmodmont 0xa80e00002001
addmodmont 0xd80e30005001
// f2 add
addmodmont 0x080f60008001
addmodmont 0x380f9000b001
// f2 add
addmodmont 0x680fc000e001
addmodmont 0x980ff0001002
addmodmont 0xd80be0011002
submodmont 0x8810e0011002
addmodmont 0xb810d80b8004
// f2 add
addmodmont 0xc80f00008810
addmodmont 0xf80f3000b810
// f2 add
addmodmont 0x281060002001
addmodmont 0x581090005001
// f2 add
addmodmont 0x8810c0008001
addmodmont 0xb810f000b001
// f6mul begin
// f2 mul
addmodmont 0xd80ba80ed80e
addmodmont 0x080cc80ff80f
mulmodmont 0x080c080cd80b
mulmodmont 0xd80ba80ec80f
mulmodmont 0x380cd80ef80f
submodmont 0x680cd80b380c
submodmont 0x980c080cd80b
submodmont 0x980c980c380c
// f2 mul
addmodmont 0xd80b080f380f
addmodmont 0x080c28105810
mulmodmont 0x080c080cd80b
mulmodmont 0xd80b080f2810
mulmodmont 0x380c380f5810
submodmont 0xc80cd80b380c
submodmont 0xf80c080cd80b
submodmont 0xf80cf80c380c
// f2 mul
addmodmont 0xd80b680f980f
addmodmont 0x080c8810b810
mulmodmont 0x080c080cd80b
mulmodmont 0xd80b680f8810
mulmodmont 0x380c980fb810
submodmont 0x280dd80b380c
submodmont 0x580d080cd80b
submodmont 0x580d580d380c
// f2 add
addmodmont 0xe80d080f680f
addmodmont 0x180e380f980f
// f2 add
addmodmont 0x480e28108810
addmodmont 0x780e5810b810
// f2 mul
addmodmont 0xd80be80d180e
addmodmont 0x080c480e780e
mulmodmont 0x080c080cd80b
mulmodmont 0xd80be80d480e
mulmodmont 0x380c180e780e
submodmont 0x880dd80b380c
submodmont 0xb80d080cd80b
submodmont 0xb80db80d380c
// f2 sub
submodmont 0x880d880dc80c
submodmont 0xb80db80df80c
// f2 sub
submodmont 0x880d880d280d
submodmont 0xb80db80d580d
addmodmont 0xd80b880db80d
submodmont 0x880d880db80d
addmodmont 0xb80dd80b8004
// f2 add
addmodmont 0xe80da80e080f
addmodmont 0x180ed80e380f
// f2 add
addmodmont 0x480ec80f2810
addmodmont 0x780ef80f5810
// f2 mul
addmodmont 0xd80be80d180e
addmodmont 0x080c480e780e
mulmodmont 0x080c080cd80b
mulmodmont 0xd80be80d480e
mulmodmont 0x380c180e780e
submodmont 0x080fd80b380c
submodmont 0x380f080cd80b
submodmont 0x380f380f380c
// f2 sub
submodmont 0x080f080f680c
submodmont 0x380f380f980c
// f2 sub
submodmont 0x080f080fc80c
submodmont 0x380f380ff80c
addmodmont 0xd80b280d580d
submodmont 0xe80d280d580d
addmodmont 0x180ed80b8004
// f2 add
addmodmont 0x080f080fe80d
addmodmont 0x380f380f180e
// f2 add
addmodmont 0xe80da80e680f
addmodmont 0x180ed80e980f
// f2 add
addmodmont 0x480ec80f8810
addmodmont 0x780ef80fb810
// f2 mul
addmodmont 0xd80be80d180e
addmodmont 0x080c480e780e
mulmodmont 0x080c080cd80b
mulmodmont 0xd80be80d480e
mulmodmont 0x380c180e780e
submodmont 0x680fd80b380c
submodmont 0x980f080cd80b
submodmont 0x980f980f380c
// f2 sub
submodmont 0x680f680f680c
submodmont 0x980f980f980c
// f2 sub
submodmont 0x680f680f280d
submodmont 0x980f980f580d
// f2 add
addmodmont 0x680f680fc80c
addmodmont 0x980f980ff80c
// f2 add
addmodmont 0xa80e880d680c
addmodmont 0xd80eb80d980c
// f6mul end
// f6mul begin
// f2 mul
addmodmont 0xd80b00003000
addmodmont 0x080c20015001
mulmodmont 0x080c080cd80b
mulmodmont 0xd80b00002001
mulmodmont 0x380c30005001
submodmont 0x680cd80b380c
submodmont 0x980c080cd80b
submodmont 0x980c980c380c
// f2 mul
addmodmont 0xd80b60009000
addmodmont 0x080c8001b001
mulmodmont 0x080c080cd80b
mulmodmont 0xd80b60008001
mulmodmont 0x380c9000b001
submodmont 0xc80cd80b380c
submodmont 0xf80c080cd80b
submodmont 0xf80cf80c380c
// f2 mul
addmodmont 0xd80bc000f000
addmodmont 0x080ce0011002
mulmodmont 0x080c080cd80b
mulmodmont 0xd80bc000e001
mulmodmont 0x380cf0001002
submodmont 0x280dd80b380c
submodmont 0x580d080cd80b
submodmont 0x580d580d380c
// f2 add
addmodmont 0xe80d6000c000
addmodmont 0x180e9000f000
// f2 add
addmodmont 0x480e8001e001
addmodmont 0x780eb0011002
// f2 mul
addmodmont 0xd80be80d180e
addmodmont 0x080c480e780e
mulmodmont 0x080c080cd80b
mulmodmont 0xd80be80d480e
mulmodmont 0x380c180e780e
submodmont 0x880dd80b380c
submodmont 0xb80d080cd80b
submodmont 0xb80db80d380c
// f2 sub
submodmont 0x880d880dc80c
submodmont 0xb80db80df80c
// f2 sub
submodmont 0x880d880d280d
submodmont 0xb80db80d580d
addmodmont 0xd80b880db80d
submodmont 0x880d880db80d
addmodmont 0xb80dd80b8004
// f2 add
addmodmont 0xe80d00006000
addmodmont 0x180e30009000
// f2 add
addmodmont 0x480e20018001
addmodmont 0x780e5001b001
// f2 mul
addmodmont 0xd80be80d180e
addmodmont 0x080c480e780e
mulmodmont 0x080c080cd80b
mulmodmont 0xd80be80d480e
mulmodmont 0x380c180e780e
submodmont 0x2810d80b380c
submodmont 0x5810080cd80b
submodmont 0x58105810380c
// f2 sub
submodmont 0x28102810680c
submodmont 0x58105810980c
// f2 sub
submodmont 0x28102810c80c
submodmont 0x58105810f80c
addmodmont 0xd80b280d580d
submodmont 0xe80d280d580d
addmodmont 0x180ed80b8004
// f2 add
addmodmont 0x28102810e80d
addmodmont 0x58105810180e
// f2 add
addmodmont 0xe80d0000c000
addmodmont 0x180e3000f000
// f2 add
addmodmont 0x480e2001e001
addmodmont 0x780e50011002
// f2 mul
addmodmont 0xd80be80d180e
addmodmont 0x080c480e780e
mulmodmont 0x080c080cd80b
mulmodmont 0xd80be80d480e
mulmodmont 0x380c180e780e
submodmont 0x8810d80b380c
submodmont 0xb810080cd80b
submodmont 0xb810b810380c
// f2 sub
submodmont 0x88108810680c
submodmont 0xb810b810980c
// f2 sub
submodmont 0x88108810280d
submodmont 0xb810b810580d
// f2 add
addmodmont 0x88108810c80c
addmodmont 0xb810b810f80c
// f2 add
addmodmont 0xc80f880d680c
addmodmont 0xf80fb80d980c
// f6mul end
// f6 add
// f2 add
addmodmont 0x2001c80fc80f
addmodmont 0x5001f80ff80f
// f2 add
addmodmont 0x800128102810
addmodmont 0xb00158105810
// f2 add
addmodmont 0xe00188108810
addmodmont 0x1002b810b810
// f6 sub
// f2 sub
submodmont 0x0000a80ec80f
submodmont 0x3000d80ef80f
// f2 sub
submodmont 0x6000080f2810
submodmont 0x9000380f5810
// f2 sub
submodmont 0xc000680f8810
submodmont 0xf000980fb810
addmodmont 0xd80b8810b810
submodmont 0x88108810b810
addmodmont 0xb810d80b8004
// f2 sub
submodmont 0x000000008810
submodmont 0x30003000b810
// f2 sub
submodmont 0x60006000c80f
submodmont 0x90009000f80f
// f2 sub
submodmont 0xc000c0002810
submodmont 0xf000f0005810
// f12sqr end
///////////
// Edouble https://www.hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#doubling-dbl-2009-alnr
// A = X1^2
// f2sqr
addmodmont 0xd80b38096809
submodmont 0x080c38096809
mulmodmont 0xf82138096809
addmodmont 0xf821f821f821
mulmodmont 0xc821d80b080c
// B = Y1^2
// f2sqr
addmodmont 0xd80b9809c809
submodmont 0x080c9809c809
mulmodmont 0x58229809c809
addmodmont 0x582258225822
mulmodmont 0x2822d80b080c
// ZZ = Z1^2
// f2sqr
addmodmont 0xd80bf809280a
submodmont 0x080cf809280a
mulmodmont 0xb822f809280a
addmodmont 0xb822b822b822
mulmodmont 0x8822d80b080c
// C = B^2
// f2sqr
addmodmont 0xd80b28225822
submodmont 0x080c28225822
mulmodmont 0x182328225822
addmodmont 0x182318231823
mulmodmont 0xe822d80b080c
// D = 2*((X1+B)^2-A-C)
// f2 add
addmodmont 0x482338092822
addmodmont 0x782368095822
// f2sqr
addmodmont 0xd80b48237823
submodmont 0x080c48237823
mulmodmont 0x782348237823
addmodmont 0x782378237823
mulmodmont 0x4823d80b080c
// f2 sub
submodmont 0x48234823c821
submodmont 0x78237823f821
// f2 sub
submodmont 0x48234823e822
submodmont 0x782378231823
// f2 add
addmodmont 0x482348234823
addmodmont 0x782378237823
// E = 3*A
// f2 add
addmodmont 0xa823c821c821
addmodmont 0xd823f821f821
// f2 add
addmodmont 0xa823a823c821
addmodmont 0xd823d823f821
// F = E^2
// f2sqr
addmodmont 0xd80ba823d823
submodmont 0x080ca823d823
mulmodmont 0x3824a823d823
addmodmont 0x382438243824
mulmodmont 0x0824d80b080c
// line0 = E+X1, this is useful for pairing
// f2 add
addmodmont 0xb80aa8233809
addmodmont 0xe80ad8236809
// X3 = F-2*D
// f2 sub
submodmont 0x380908244823
submodmont 0x680938247823
// f2 sub
submodmont 0x380938094823
submodmont 0x680968097823
// Z3 = (Y1+Z1)^2-B-ZZ
// f2 add
addmodmont 0xf8099809f809
addmodmont 0x280ac809280a
// f2sqr
addmodmont 0xd80bf809280a
submodmont 0x080cf809280a
mulmodmont 0x280af809280a
addmodmont 0x280a280a280a
mulmodmont 0xf809d80b080c
// f2 sub
submodmont 0xf809f8092822
submodmont 0x280a280a5822
// f2 sub
submodmont 0xf809f8098822
submodmont 0x280a280ab822
// Y3 = E*(D-X3)-8*C
// f2 sub
submodmont 0x980948233809
submodmont 0xc80978236809
// f2 mul
addmodmont 0xd80ba823d823
addmodmont 0x080c9809c809
mulmodmont 0x080c080cd80b
mulmodmont 0xd80ba8239809
mulmodmont 0x380cd823c809
submodmont 0x9809d80b380c
submodmont 0xc809080cd80b
submodmont 0xc809c809380c
// f2 add
addmodmont 0xe822e822e822
addmodmont 0x182318231823
// f2 add
addmodmont 0xe822e822e822
addmodmont 0x182318231823
// f2 add
addmodmont 0xe822e822e822
addmodmont 0x182318231823
// f2 sub
submodmont 0x98099809e822
submodmont 0xc809c8091823
// E double
////////////
// f2sqr
addmodmont 0xd80bb80ae80a
submodmont 0x080cb80ae80a
mulmodmont 0xe80ab80ae80a
addmodmont 0xe80ae80ae80a
mulmodmont 0xb80ad80b080c
// f2 sub
submodmont 0xb80ab80ac821
submodmont 0xe80ae80af821
// f2 sub
submodmont 0xb80ab80a0824
submodmont 0xe80ae80a3824
// f2 add
addmodmont 0x282228222822
addmodmont 0x582258225822
// f2 add
addmodmont 0x282228222822
addmodmont 0x582258225822
// f2 sub
submodmont 0xb80ab80a2822
submodmont 0xe80ae80a5822
// f2 mul
addmodmont 0xd80ba823d823
addmodmont 0x080c8822b822
mulmodmont 0x080c080cd80b