#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "steps.h"
#include "mont.h"
#include "../common/fp/mulx/fp.h"
#include "poly.h"
#include "int64mask.h"
Go to the source code of this file.
|
void | xA24 (proj *A24, const proj *A) |
|
void | xDBLADD (proj *R, proj *S, proj const *P, proj const *Q, proj const *PQ, proj const *A24, int Aaffine) |
|
void | xDBL (proj *Q, proj const *P, const proj *A24, int Aaffine) |
|
void | xADD (proj *S, proj const *P, proj const *Q, proj const *PQ) |
|
void | xMUL_dac (proj *Q, proj const *A24, int Aaffine, proj const *P, int64_t dac, int64_t daclen, int64_t maxdaclen) |
|
void | xMUL (proj *Q, proj const *A, int Aaffine, proj const *P, uintbig const *k, int64_t kbits) |
|
void | xMUL_vartime (proj *Q, proj const *A, int Aaffine, proj const *P, uintbig const *k) |
|
void | xISOG_matryoshka (proj *A, proj *P, int64_t Plen, proj const *K, int64_t k, int64_t klower, int64_t kupper) |
|
void | xISOG (proj *A, proj *P, int64_t Plen, proj const *K, int64_t k) |
|
void | xISOG_old (proj *A, proj *P, proj const *K, int64_t k) |
|
◆ xA24()
Definition at line 20 of file mont.c.
21{
22 fp_double2(&
A24->x, &
A->z);
23 fp_double2(&
A24->z, (
const fp *)&
A24->x);
24 fp_add2(&
A24->x, &
A->x);
25}
uint64_t fp[NUMBER_OF_WORDS]
References i.
◆ xADD()
Definition at line 85 of file mont.c.
86{
88 fp_add3(&
a, &
P->x, &
P->z);
89 fp_sub3(&b, &
P->x, &
P->z);
90 fp_add3(&c, &
Q->x, &
Q->z);
91 fp_sub3(&d, &
Q->x, &
Q->z);
92 fp_mul2(&
a, (
const fp *)&d);
93 fp_mul2(&b, (
const fp *)&c);
94 fp_add3(&c, (
const fp *)&
a, (
const fp *)&b);
95 fp_sub3(&d, (
const fp *)&
a, (
const fp *)&b);
96 fp_sq1(&c);
97 fp_sq1(&d);
98 fp_mul3(&
S->x, &
PQ->z, (
const fp *)&c);
99 fp_mul3(&
S->z, &
PQ->x, (
const fp *)&d);
100}
References a, and i.
◆ xDBL()
Definition at line 78 of file mont.c.
References i.
◆ xDBLADD()
Definition at line 49 of file mont.c.
50{
52
53 fp_add3(&
tmp0, &
P->x, &
P->z);
54 fp_sub3(&
tmp1, &
P->x, &
P->z);
55 fp_sq2(&
R->x, (
const fp *)&
tmp0);
56 fp_sub3(&
tmp2, &
Q->x, &
Q->z);
57 fp_add3(&
S->x, &
Q->x, &
Q->z);
59 fp_sq2(&
R->z, (
const fp *)&
tmp1);
60 fp_mul2(&
tmp1, (
const fp *)&
S->x);
61 fp_sub3(&
tmp2, (
const fp *)&
R->x, (
const fp *)&
R->z);
64 else
65 fp_mul2(&
R->z, &
A24->z);
66 fp_mul2(&
R->x, (
const fp *)&
R->z);
69 fp_add2(&
R->z, (
const fp *)&
S->x);
71 fp_mul2(&
R->z, (
const fp *)&
tmp2);
74 fp_mul2(&
S->z, &
PQ->x);
75 fp_mul2(&
S->x, &
PQ->z);
76}
References i.
◆ xISOG()
◆ xISOG_matryoshka()
Definition at line 429 of file mont.c.
430{
434
438
441 {
446 }
447
449
452
453
454
455 fp_double2(&
Aed.z, (
const fp *)&
A->z);
456
457
458 fp_add3(&
Aed.x, (
const fp *)&
A->x, (
const fp *)&
Aed.z);
459
460
462
463
464 fp_double2(&
A24.z, (
const fp *)&
Aed.z);
465
466
467 fp_sub3(&
Aed.z, (
const fp *)&
A->x, (
const fp *)&
Aed.z);
468
470#ifndef NDEBUG
472
475
477#endif
480#ifndef NDEBUG
482#endif
483
485 {
487 {
489 {
493 {
495 {
499#ifndef NDEBUG
501#endif
502 continue;
503 }
508#ifndef NDEBUG
510#endif
511 continue;
512 }
513 }
514 else
515 {
519 {
521 {
524#ifndef NDEBUG
526#endif
527 continue;
528 }
533#ifndef NDEBUG
535#endif
536 continue;
537 }
538 }
539
541 {
543 {
548#ifndef NDEBUG
550#endif
551 continue;
552 }
553 else if (
s == 4 *
bs)
554 {
557#ifndef NDEBUG
559#endif
560 continue;
561 }
562 else if (
s == 6 *
bs)
563 {
567#ifndef NDEBUG
569#endif
570 continue;
571 }
572 else if (
s % (4 *
bs) == 2 *
bs)
573 {
577 {
582#ifndef NDEBUG
584#endif
585 continue;
586 }
587 }
588 }
589 }
590 }
591 else
592 {
594 {
595#ifndef NDEBUG
597#endif
599 }
600 }
601
608 } else {
610 }
613 {
616 }
619 {
620
621
623
625 }
626
628 {
631
633 {
635 fp_neg2(&
TI[2 *
i], (
const fp *)&
M[2 *
i + 1].x);
637 }
638
640
644
646 {
648 biquad_precompute_curve(
Aprecomp[
j], &
M[2 *
bs * (2 *
j + 1)], A);
650 }
653
657
659
664
669
671 {
674
679
683
688
693 }
694
697 {
700 fp_sub3(&
tmp4, (
const fp *)&
M[2 *
i + 2].x, (
const fp *)&
M[2 *
i + 2].z);
701 fp_add3(&
tmp3, (
const fp *)&
M[2 *
i + 2].x, (
const fp *)&
M[2 *
i + 2].z);
707 {
716 }
717 }
718 }
719 else
720 {
721
723
725 fp_sub3(&
tmp4, (
const fp *)&
M[1].x, (
const fp *)&
M[1].z);
726 fp_add3(&
tmp3, (
const fp *)&
M[1].x, (
const fp *)&
M[1].z);
729
731 {
736 }
737
739 {
741
743 fp_sub3(&
tmp4, (
const fp *)&
M[
i].x, (
const fp *)&
M[
i].z);
744 fp_add3(&
tmp3, (
const fp *)&
M[
i].x, (
const fp *)&
M[
i].z);
750 {
751
760 }
761 }
762 }
763
765 {
766
767
770
771
772
775 }
776
777
779
781
782
783
784 fp_add3(&
A->x, (
const fp *)&
Aed.x, (
const fp *)&
Aed.z);
785 fp_sub3(&
A->z, (
const fp *)&
Aed.x, (
const fp *)&
Aed.z);
787}
#define poly_multieval_postcompute
#define poly_multiprod2_selfreciprocal
#define poly_multieval_precomputesize
#define poly_multieval_precompute
References assert(), fp_1, fp_copy, i, j, poly_multieval_postcompute, poly_multieval_precompute, poly_multieval_precomputesize, poly_multiprod2, poly_multiprod2_selfreciprocal, poly_tree1, poly_tree1size, steps, xADD, and xDBL.
◆ xISOG_old()
Definition at line 794 of file mont.c.
795{
798
801
802 fp_add3(&
Aed.z, (
const fp *)&
A->z, (
const fp *)&
A->z);
803 fp_add3(&
Aed.x, (
const fp *)&
A->x, (
const fp *)&
Aed.z);
804 fp_sub3(&
Aed.z, (
const fp *)&
A->x, (
const fp *)&
Aed.z);
805
806 fp_add3(&
Psum, (
const fp *)&
P->x, (
const fp *)&
P->z);
807 fp_sub3(&
Pdif, (
const fp *)&
P->x, (
const fp *)&
P->z);
808
809 fp_sub3(&
prod.x, &
K->x, &
K->z);
810 fp_add3(&
prod.z, &
K->x, &
K->z);
811
816
820
824 {
826 }
827
829 {
830 fp_sub3(&
tmp1, (
const fp *)&
M[
i].x, (
const fp *)&
M[
i].z);
831 fp_add3(&
tmp0, (
const fp *)&
M[
i].x, (
const fp *)&
M[
i].z);
837 fp_mul2(&
Q.x, (
const fp *)&
tmp2);
839 fp_mul2(&
Q.z, (
const fp *)&
tmp2);
840 }
841
842
845 fp_mul2(&
P->x, (
const fp *)&
Q.x);
846 fp_mul2(&
P->z, (
const fp *)&
Q.z);
847
848
849 exp_by_squaring_(&
Aed.x, &
Aed.z,
k);
850
851
858
859
862
863
864 fp_add3(&
A->x, (
const fp *)&
Aed.x, (
const fp *)&
Aed.z);
865 fp_sub3(&
A->z, (
const fp *)&
Aed.x, (
const fp *)&
Aed.z);
866 fp_add2(&
A->x, (
const fp *)&
A->x);
867}
References assert(), i, xA24, xADD, and xDBL.
◆ xMUL()
◆ xMUL_dac()
Definition at line 110 of file mont.c.
111{
118
120
121 for (;;)
122 {
126 break;
127
128
129
130
131
132 proj_cswap(&
P1, &
P2, 1 - (
dac & 1));
133
134
135
136
138
143
147 }
148
150
151}
References i, xADD, and xDBL.
◆ xMUL_vartime()