ed25519 1.0.0-jruby
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +5 -0
- data/.rubocop.yml +35 -0
- data/.travis.yml +13 -0
- data/CHANGES.md +16 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +12 -0
- data/LICENSE +22 -0
- data/README.md +159 -0
- data/Rakefile +27 -0
- data/ed25519.gemspec +32 -0
- data/ed25519.png +0 -0
- data/ext/ed25519_java/org/cryptosphere/ed25519.java +228 -0
- data/ext/ed25519_ref10/api.h +4 -0
- data/ext/ed25519_ref10/base.h +1344 -0
- data/ext/ed25519_ref10/base2.h +40 -0
- data/ext/ed25519_ref10/d.h +1 -0
- data/ext/ed25519_ref10/d2.h +1 -0
- data/ext/ed25519_ref10/ed25519_ref10.c +99 -0
- data/ext/ed25519_ref10/ed25519_ref10.h +33 -0
- data/ext/ed25519_ref10/extconf.rb +9 -0
- data/ext/ed25519_ref10/fe.h +56 -0
- data/ext/ed25519_ref10/fe_0.c +19 -0
- data/ext/ed25519_ref10/fe_1.c +19 -0
- data/ext/ed25519_ref10/fe_add.c +57 -0
- data/ext/ed25519_ref10/fe_cmov.c +63 -0
- data/ext/ed25519_ref10/fe_copy.c +29 -0
- data/ext/ed25519_ref10/fe_frombytes.c +71 -0
- data/ext/ed25519_ref10/fe_invert.c +14 -0
- data/ext/ed25519_ref10/fe_isnegative.c +16 -0
- data/ext/ed25519_ref10/fe_isnonzero.c +19 -0
- data/ext/ed25519_ref10/fe_mul.c +252 -0
- data/ext/ed25519_ref10/fe_neg.c +45 -0
- data/ext/ed25519_ref10/fe_pow22523.c +13 -0
- data/ext/ed25519_ref10/fe_sq.c +148 -0
- data/ext/ed25519_ref10/fe_sq2.c +159 -0
- data/ext/ed25519_ref10/fe_sub.c +57 -0
- data/ext/ed25519_ref10/fe_tobytes.c +119 -0
- data/ext/ed25519_ref10/ge.h +95 -0
- data/ext/ed25519_ref10/ge_add.c +11 -0
- data/ext/ed25519_ref10/ge_add.h +97 -0
- data/ext/ed25519_ref10/ge_double_scalarmult.c +96 -0
- data/ext/ed25519_ref10/ge_frombytes.c +50 -0
- data/ext/ed25519_ref10/ge_madd.c +11 -0
- data/ext/ed25519_ref10/ge_madd.h +88 -0
- data/ext/ed25519_ref10/ge_msub.c +11 -0
- data/ext/ed25519_ref10/ge_msub.h +88 -0
- data/ext/ed25519_ref10/ge_p1p1_to_p2.c +12 -0
- data/ext/ed25519_ref10/ge_p1p1_to_p3.c +13 -0
- data/ext/ed25519_ref10/ge_p2_0.c +8 -0
- data/ext/ed25519_ref10/ge_p2_dbl.c +11 -0
- data/ext/ed25519_ref10/ge_p2_dbl.h +73 -0
- data/ext/ed25519_ref10/ge_p3_0.c +9 -0
- data/ext/ed25519_ref10/ge_p3_dbl.c +12 -0
- data/ext/ed25519_ref10/ge_p3_to_cached.c +17 -0
- data/ext/ed25519_ref10/ge_p3_to_p2.c +12 -0
- data/ext/ed25519_ref10/ge_p3_tobytes.c +14 -0
- data/ext/ed25519_ref10/ge_precomp_0.c +8 -0
- data/ext/ed25519_ref10/ge_scalarmult_base.c +104 -0
- data/ext/ed25519_ref10/ge_sub.c +11 -0
- data/ext/ed25519_ref10/ge_sub.h +97 -0
- data/ext/ed25519_ref10/ge_tobytes.c +14 -0
- data/ext/ed25519_ref10/keypair.c +22 -0
- data/ext/ed25519_ref10/open.c +47 -0
- data/ext/ed25519_ref10/pow22523.h +160 -0
- data/ext/ed25519_ref10/pow225521.h +160 -0
- data/ext/ed25519_ref10/sc.h +17 -0
- data/ext/ed25519_ref10/sc_muladd.c +366 -0
- data/ext/ed25519_ref10/sc_reduce.c +272 -0
- data/ext/ed25519_ref10/sha512.c +304 -0
- data/ext/ed25519_ref10/sha512.h +8 -0
- data/ext/ed25519_ref10/sign.c +41 -0
- data/ext/ed25519_ref10/sqrtm1.h +1 -0
- data/ext/ed25519_ref10/verify.c +40 -0
- data/lib/ed25519.rb +65 -0
- data/lib/ed25519/provider/jruby.rb +39 -0
- data/lib/ed25519/signing_key.rb +39 -0
- data/lib/ed25519/verify_key.rb +44 -0
- data/lib/ed25519/version.rb +5 -0
- data/lib/ed25519_java.jar +0 -0
- metadata +138 -0
@@ -0,0 +1,96 @@
|
|
1
|
+
#include "ge.h"
|
2
|
+
|
3
|
+
static void slide(signed char *r,const unsigned char *a)
|
4
|
+
{
|
5
|
+
int i;
|
6
|
+
int b;
|
7
|
+
int k;
|
8
|
+
|
9
|
+
for (i = 0;i < 256;++i)
|
10
|
+
r[i] = 1 & (a[i >> 3] >> (i & 7));
|
11
|
+
|
12
|
+
for (i = 0;i < 256;++i)
|
13
|
+
if (r[i]) {
|
14
|
+
for (b = 1;b <= 6 && i + b < 256;++b) {
|
15
|
+
if (r[i + b]) {
|
16
|
+
if (r[i] + (r[i + b] << b) <= 15) {
|
17
|
+
r[i] += r[i + b] << b; r[i + b] = 0;
|
18
|
+
} else if (r[i] - (r[i + b] << b) >= -15) {
|
19
|
+
r[i] -= r[i + b] << b;
|
20
|
+
for (k = i + b;k < 256;++k) {
|
21
|
+
if (!r[k]) {
|
22
|
+
r[k] = 1;
|
23
|
+
break;
|
24
|
+
}
|
25
|
+
r[k] = 0;
|
26
|
+
}
|
27
|
+
} else
|
28
|
+
break;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
}
|
34
|
+
|
35
|
+
static ge_precomp Bi[8] = {
|
36
|
+
#include "base2.h"
|
37
|
+
} ;
|
38
|
+
|
39
|
+
/*
|
40
|
+
r = a * A + b * B
|
41
|
+
where a = a[0]+256*a[1]+...+256^31 a[31].
|
42
|
+
and b = b[0]+256*b[1]+...+256^31 b[31].
|
43
|
+
B is the Ed25519 base point (x,4/5) with x positive.
|
44
|
+
*/
|
45
|
+
|
46
|
+
void ge_double_scalarmult_vartime(ge_p2 *r,const unsigned char *a,const ge_p3 *A,const unsigned char *b)
|
47
|
+
{
|
48
|
+
signed char aslide[256];
|
49
|
+
signed char bslide[256];
|
50
|
+
ge_cached Ai[8]; /* A,3A,5A,7A,9A,11A,13A,15A */
|
51
|
+
ge_p1p1 t;
|
52
|
+
ge_p3 u;
|
53
|
+
ge_p3 A2;
|
54
|
+
int i;
|
55
|
+
|
56
|
+
slide(aslide,a);
|
57
|
+
slide(bslide,b);
|
58
|
+
|
59
|
+
ge_p3_to_cached(&Ai[0],A);
|
60
|
+
ge_p3_dbl(&t,A); ge_p1p1_to_p3(&A2,&t);
|
61
|
+
ge_add(&t,&A2,&Ai[0]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[1],&u);
|
62
|
+
ge_add(&t,&A2,&Ai[1]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[2],&u);
|
63
|
+
ge_add(&t,&A2,&Ai[2]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[3],&u);
|
64
|
+
ge_add(&t,&A2,&Ai[3]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[4],&u);
|
65
|
+
ge_add(&t,&A2,&Ai[4]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[5],&u);
|
66
|
+
ge_add(&t,&A2,&Ai[5]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[6],&u);
|
67
|
+
ge_add(&t,&A2,&Ai[6]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[7],&u);
|
68
|
+
|
69
|
+
ge_p2_0(r);
|
70
|
+
|
71
|
+
for (i = 255;i >= 0;--i) {
|
72
|
+
if (aslide[i] || bslide[i]) break;
|
73
|
+
}
|
74
|
+
|
75
|
+
for (;i >= 0;--i) {
|
76
|
+
ge_p2_dbl(&t,r);
|
77
|
+
|
78
|
+
if (aslide[i] > 0) {
|
79
|
+
ge_p1p1_to_p3(&u,&t);
|
80
|
+
ge_add(&t,&u,&Ai[aslide[i]/2]);
|
81
|
+
} else if (aslide[i] < 0) {
|
82
|
+
ge_p1p1_to_p3(&u,&t);
|
83
|
+
ge_sub(&t,&u,&Ai[(-aslide[i])/2]);
|
84
|
+
}
|
85
|
+
|
86
|
+
if (bslide[i] > 0) {
|
87
|
+
ge_p1p1_to_p3(&u,&t);
|
88
|
+
ge_madd(&t,&u,&Bi[bslide[i]/2]);
|
89
|
+
} else if (bslide[i] < 0) {
|
90
|
+
ge_p1p1_to_p3(&u,&t);
|
91
|
+
ge_msub(&t,&u,&Bi[(-bslide[i])/2]);
|
92
|
+
}
|
93
|
+
|
94
|
+
ge_p1p1_to_p2(r,&t);
|
95
|
+
}
|
96
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#include "ge.h"
|
2
|
+
|
3
|
+
static const fe d = {
|
4
|
+
#include "d.h"
|
5
|
+
} ;
|
6
|
+
|
7
|
+
static const fe sqrtm1 = {
|
8
|
+
#include "sqrtm1.h"
|
9
|
+
} ;
|
10
|
+
|
11
|
+
int ge_frombytes_negate_vartime(ge_p3 *h,const unsigned char *s)
|
12
|
+
{
|
13
|
+
fe u;
|
14
|
+
fe v;
|
15
|
+
fe v3;
|
16
|
+
fe vxx;
|
17
|
+
fe check;
|
18
|
+
|
19
|
+
fe_frombytes(h->Y,s);
|
20
|
+
fe_1(h->Z);
|
21
|
+
fe_sq(u,h->Y);
|
22
|
+
fe_mul(v,u,d);
|
23
|
+
fe_sub(u,u,h->Z); /* u = y^2-1 */
|
24
|
+
fe_add(v,v,h->Z); /* v = dy^2+1 */
|
25
|
+
|
26
|
+
fe_sq(v3,v);
|
27
|
+
fe_mul(v3,v3,v); /* v3 = v^3 */
|
28
|
+
fe_sq(h->X,v3);
|
29
|
+
fe_mul(h->X,h->X,v);
|
30
|
+
fe_mul(h->X,h->X,u); /* x = uv^7 */
|
31
|
+
|
32
|
+
fe_pow22523(h->X,h->X); /* x = (uv^7)^((q-5)/8) */
|
33
|
+
fe_mul(h->X,h->X,v3);
|
34
|
+
fe_mul(h->X,h->X,u); /* x = uv^3(uv^7)^((q-5)/8) */
|
35
|
+
|
36
|
+
fe_sq(vxx,h->X);
|
37
|
+
fe_mul(vxx,vxx,v);
|
38
|
+
fe_sub(check,vxx,u); /* vx^2-u */
|
39
|
+
if (fe_isnonzero(check)) {
|
40
|
+
fe_add(check,vxx,u); /* vx^2+u */
|
41
|
+
if (fe_isnonzero(check)) return -1;
|
42
|
+
fe_mul(h->X,h->X,sqrtm1);
|
43
|
+
}
|
44
|
+
|
45
|
+
if (fe_isnegative(h->X) == (s[31] >> 7))
|
46
|
+
fe_neg(h->X,h->X);
|
47
|
+
|
48
|
+
fe_mul(h->T,h->X,h->Y);
|
49
|
+
return 0;
|
50
|
+
}
|
@@ -0,0 +1,88 @@
|
|
1
|
+
|
2
|
+
/* qhasm: enter ge_madd */
|
3
|
+
|
4
|
+
/* qhasm: fe X1 */
|
5
|
+
|
6
|
+
/* qhasm: fe Y1 */
|
7
|
+
|
8
|
+
/* qhasm: fe Z1 */
|
9
|
+
|
10
|
+
/* qhasm: fe T1 */
|
11
|
+
|
12
|
+
/* qhasm: fe ypx2 */
|
13
|
+
|
14
|
+
/* qhasm: fe ymx2 */
|
15
|
+
|
16
|
+
/* qhasm: fe xy2d2 */
|
17
|
+
|
18
|
+
/* qhasm: fe X3 */
|
19
|
+
|
20
|
+
/* qhasm: fe Y3 */
|
21
|
+
|
22
|
+
/* qhasm: fe Z3 */
|
23
|
+
|
24
|
+
/* qhasm: fe T3 */
|
25
|
+
|
26
|
+
/* qhasm: fe YpX1 */
|
27
|
+
|
28
|
+
/* qhasm: fe YmX1 */
|
29
|
+
|
30
|
+
/* qhasm: fe A */
|
31
|
+
|
32
|
+
/* qhasm: fe B */
|
33
|
+
|
34
|
+
/* qhasm: fe C */
|
35
|
+
|
36
|
+
/* qhasm: fe D */
|
37
|
+
|
38
|
+
/* qhasm: YpX1 = Y1+X1 */
|
39
|
+
/* asm 1: fe_add(>YpX1=fe#1,<Y1=fe#12,<X1=fe#11); */
|
40
|
+
/* asm 2: fe_add(>YpX1=r->X,<Y1=p->Y,<X1=p->X); */
|
41
|
+
fe_add(r->X,p->Y,p->X);
|
42
|
+
|
43
|
+
/* qhasm: YmX1 = Y1-X1 */
|
44
|
+
/* asm 1: fe_sub(>YmX1=fe#2,<Y1=fe#12,<X1=fe#11); */
|
45
|
+
/* asm 2: fe_sub(>YmX1=r->Y,<Y1=p->Y,<X1=p->X); */
|
46
|
+
fe_sub(r->Y,p->Y,p->X);
|
47
|
+
|
48
|
+
/* qhasm: A = YpX1*ypx2 */
|
49
|
+
/* asm 1: fe_mul(>A=fe#3,<YpX1=fe#1,<ypx2=fe#15); */
|
50
|
+
/* asm 2: fe_mul(>A=r->Z,<YpX1=r->X,<ypx2=q->yplusx); */
|
51
|
+
fe_mul(r->Z,r->X,q->yplusx);
|
52
|
+
|
53
|
+
/* qhasm: B = YmX1*ymx2 */
|
54
|
+
/* asm 1: fe_mul(>B=fe#2,<YmX1=fe#2,<ymx2=fe#16); */
|
55
|
+
/* asm 2: fe_mul(>B=r->Y,<YmX1=r->Y,<ymx2=q->yminusx); */
|
56
|
+
fe_mul(r->Y,r->Y,q->yminusx);
|
57
|
+
|
58
|
+
/* qhasm: C = xy2d2*T1 */
|
59
|
+
/* asm 1: fe_mul(>C=fe#4,<xy2d2=fe#17,<T1=fe#14); */
|
60
|
+
/* asm 2: fe_mul(>C=r->T,<xy2d2=q->xy2d,<T1=p->T); */
|
61
|
+
fe_mul(r->T,q->xy2d,p->T);
|
62
|
+
|
63
|
+
/* qhasm: D = 2*Z1 */
|
64
|
+
/* asm 1: fe_add(>D=fe#5,<Z1=fe#13,<Z1=fe#13); */
|
65
|
+
/* asm 2: fe_add(>D=t0,<Z1=p->Z,<Z1=p->Z); */
|
66
|
+
fe_add(t0,p->Z,p->Z);
|
67
|
+
|
68
|
+
/* qhasm: X3 = A-B */
|
69
|
+
/* asm 1: fe_sub(>X3=fe#1,<A=fe#3,<B=fe#2); */
|
70
|
+
/* asm 2: fe_sub(>X3=r->X,<A=r->Z,<B=r->Y); */
|
71
|
+
fe_sub(r->X,r->Z,r->Y);
|
72
|
+
|
73
|
+
/* qhasm: Y3 = A+B */
|
74
|
+
/* asm 1: fe_add(>Y3=fe#2,<A=fe#3,<B=fe#2); */
|
75
|
+
/* asm 2: fe_add(>Y3=r->Y,<A=r->Z,<B=r->Y); */
|
76
|
+
fe_add(r->Y,r->Z,r->Y);
|
77
|
+
|
78
|
+
/* qhasm: Z3 = D+C */
|
79
|
+
/* asm 1: fe_add(>Z3=fe#3,<D=fe#5,<C=fe#4); */
|
80
|
+
/* asm 2: fe_add(>Z3=r->Z,<D=t0,<C=r->T); */
|
81
|
+
fe_add(r->Z,t0,r->T);
|
82
|
+
|
83
|
+
/* qhasm: T3 = D-C */
|
84
|
+
/* asm 1: fe_sub(>T3=fe#4,<D=fe#5,<C=fe#4); */
|
85
|
+
/* asm 2: fe_sub(>T3=r->T,<D=t0,<C=r->T); */
|
86
|
+
fe_sub(r->T,t0,r->T);
|
87
|
+
|
88
|
+
/* qhasm: return */
|
@@ -0,0 +1,88 @@
|
|
1
|
+
|
2
|
+
/* qhasm: enter ge_msub */
|
3
|
+
|
4
|
+
/* qhasm: fe X1 */
|
5
|
+
|
6
|
+
/* qhasm: fe Y1 */
|
7
|
+
|
8
|
+
/* qhasm: fe Z1 */
|
9
|
+
|
10
|
+
/* qhasm: fe T1 */
|
11
|
+
|
12
|
+
/* qhasm: fe ypx2 */
|
13
|
+
|
14
|
+
/* qhasm: fe ymx2 */
|
15
|
+
|
16
|
+
/* qhasm: fe xy2d2 */
|
17
|
+
|
18
|
+
/* qhasm: fe X3 */
|
19
|
+
|
20
|
+
/* qhasm: fe Y3 */
|
21
|
+
|
22
|
+
/* qhasm: fe Z3 */
|
23
|
+
|
24
|
+
/* qhasm: fe T3 */
|
25
|
+
|
26
|
+
/* qhasm: fe YpX1 */
|
27
|
+
|
28
|
+
/* qhasm: fe YmX1 */
|
29
|
+
|
30
|
+
/* qhasm: fe A */
|
31
|
+
|
32
|
+
/* qhasm: fe B */
|
33
|
+
|
34
|
+
/* qhasm: fe C */
|
35
|
+
|
36
|
+
/* qhasm: fe D */
|
37
|
+
|
38
|
+
/* qhasm: YpX1 = Y1+X1 */
|
39
|
+
/* asm 1: fe_add(>YpX1=fe#1,<Y1=fe#12,<X1=fe#11); */
|
40
|
+
/* asm 2: fe_add(>YpX1=r->X,<Y1=p->Y,<X1=p->X); */
|
41
|
+
fe_add(r->X,p->Y,p->X);
|
42
|
+
|
43
|
+
/* qhasm: YmX1 = Y1-X1 */
|
44
|
+
/* asm 1: fe_sub(>YmX1=fe#2,<Y1=fe#12,<X1=fe#11); */
|
45
|
+
/* asm 2: fe_sub(>YmX1=r->Y,<Y1=p->Y,<X1=p->X); */
|
46
|
+
fe_sub(r->Y,p->Y,p->X);
|
47
|
+
|
48
|
+
/* qhasm: A = YpX1*ymx2 */
|
49
|
+
/* asm 1: fe_mul(>A=fe#3,<YpX1=fe#1,<ymx2=fe#16); */
|
50
|
+
/* asm 2: fe_mul(>A=r->Z,<YpX1=r->X,<ymx2=q->yminusx); */
|
51
|
+
fe_mul(r->Z,r->X,q->yminusx);
|
52
|
+
|
53
|
+
/* qhasm: B = YmX1*ypx2 */
|
54
|
+
/* asm 1: fe_mul(>B=fe#2,<YmX1=fe#2,<ypx2=fe#15); */
|
55
|
+
/* asm 2: fe_mul(>B=r->Y,<YmX1=r->Y,<ypx2=q->yplusx); */
|
56
|
+
fe_mul(r->Y,r->Y,q->yplusx);
|
57
|
+
|
58
|
+
/* qhasm: C = xy2d2*T1 */
|
59
|
+
/* asm 1: fe_mul(>C=fe#4,<xy2d2=fe#17,<T1=fe#14); */
|
60
|
+
/* asm 2: fe_mul(>C=r->T,<xy2d2=q->xy2d,<T1=p->T); */
|
61
|
+
fe_mul(r->T,q->xy2d,p->T);
|
62
|
+
|
63
|
+
/* qhasm: D = 2*Z1 */
|
64
|
+
/* asm 1: fe_add(>D=fe#5,<Z1=fe#13,<Z1=fe#13); */
|
65
|
+
/* asm 2: fe_add(>D=t0,<Z1=p->Z,<Z1=p->Z); */
|
66
|
+
fe_add(t0,p->Z,p->Z);
|
67
|
+
|
68
|
+
/* qhasm: X3 = A-B */
|
69
|
+
/* asm 1: fe_sub(>X3=fe#1,<A=fe#3,<B=fe#2); */
|
70
|
+
/* asm 2: fe_sub(>X3=r->X,<A=r->Z,<B=r->Y); */
|
71
|
+
fe_sub(r->X,r->Z,r->Y);
|
72
|
+
|
73
|
+
/* qhasm: Y3 = A+B */
|
74
|
+
/* asm 1: fe_add(>Y3=fe#2,<A=fe#3,<B=fe#2); */
|
75
|
+
/* asm 2: fe_add(>Y3=r->Y,<A=r->Z,<B=r->Y); */
|
76
|
+
fe_add(r->Y,r->Z,r->Y);
|
77
|
+
|
78
|
+
/* qhasm: Z3 = D-C */
|
79
|
+
/* asm 1: fe_sub(>Z3=fe#3,<D=fe#5,<C=fe#4); */
|
80
|
+
/* asm 2: fe_sub(>Z3=r->Z,<D=t0,<C=r->T); */
|
81
|
+
fe_sub(r->Z,t0,r->T);
|
82
|
+
|
83
|
+
/* qhasm: T3 = D+C */
|
84
|
+
/* asm 1: fe_add(>T3=fe#4,<D=fe#5,<C=fe#4); */
|
85
|
+
/* asm 2: fe_add(>T3=r->T,<D=t0,<C=r->T); */
|
86
|
+
fe_add(r->T,t0,r->T);
|
87
|
+
|
88
|
+
/* qhasm: return */
|
@@ -0,0 +1,73 @@
|
|
1
|
+
|
2
|
+
/* qhasm: enter ge_p2_dbl */
|
3
|
+
|
4
|
+
/* qhasm: fe X1 */
|
5
|
+
|
6
|
+
/* qhasm: fe Y1 */
|
7
|
+
|
8
|
+
/* qhasm: fe Z1 */
|
9
|
+
|
10
|
+
/* qhasm: fe A */
|
11
|
+
|
12
|
+
/* qhasm: fe AA */
|
13
|
+
|
14
|
+
/* qhasm: fe XX */
|
15
|
+
|
16
|
+
/* qhasm: fe YY */
|
17
|
+
|
18
|
+
/* qhasm: fe B */
|
19
|
+
|
20
|
+
/* qhasm: fe X3 */
|
21
|
+
|
22
|
+
/* qhasm: fe Y3 */
|
23
|
+
|
24
|
+
/* qhasm: fe Z3 */
|
25
|
+
|
26
|
+
/* qhasm: fe T3 */
|
27
|
+
|
28
|
+
/* qhasm: XX=X1^2 */
|
29
|
+
/* asm 1: fe_sq(>XX=fe#1,<X1=fe#11); */
|
30
|
+
/* asm 2: fe_sq(>XX=r->X,<X1=p->X); */
|
31
|
+
fe_sq(r->X,p->X);
|
32
|
+
|
33
|
+
/* qhasm: YY=Y1^2 */
|
34
|
+
/* asm 1: fe_sq(>YY=fe#3,<Y1=fe#12); */
|
35
|
+
/* asm 2: fe_sq(>YY=r->Z,<Y1=p->Y); */
|
36
|
+
fe_sq(r->Z,p->Y);
|
37
|
+
|
38
|
+
/* qhasm: B=2*Z1^2 */
|
39
|
+
/* asm 1: fe_sq2(>B=fe#4,<Z1=fe#13); */
|
40
|
+
/* asm 2: fe_sq2(>B=r->T,<Z1=p->Z); */
|
41
|
+
fe_sq2(r->T,p->Z);
|
42
|
+
|
43
|
+
/* qhasm: A=X1+Y1 */
|
44
|
+
/* asm 1: fe_add(>A=fe#2,<X1=fe#11,<Y1=fe#12); */
|
45
|
+
/* asm 2: fe_add(>A=r->Y,<X1=p->X,<Y1=p->Y); */
|
46
|
+
fe_add(r->Y,p->X,p->Y);
|
47
|
+
|
48
|
+
/* qhasm: AA=A^2 */
|
49
|
+
/* asm 1: fe_sq(>AA=fe#5,<A=fe#2); */
|
50
|
+
/* asm 2: fe_sq(>AA=t0,<A=r->Y); */
|
51
|
+
fe_sq(t0,r->Y);
|
52
|
+
|
53
|
+
/* qhasm: Y3=YY+XX */
|
54
|
+
/* asm 1: fe_add(>Y3=fe#2,<YY=fe#3,<XX=fe#1); */
|
55
|
+
/* asm 2: fe_add(>Y3=r->Y,<YY=r->Z,<XX=r->X); */
|
56
|
+
fe_add(r->Y,r->Z,r->X);
|
57
|
+
|
58
|
+
/* qhasm: Z3=YY-XX */
|
59
|
+
/* asm 1: fe_sub(>Z3=fe#3,<YY=fe#3,<XX=fe#1); */
|
60
|
+
/* asm 2: fe_sub(>Z3=r->Z,<YY=r->Z,<XX=r->X); */
|
61
|
+
fe_sub(r->Z,r->Z,r->X);
|
62
|
+
|
63
|
+
/* qhasm: X3=AA-Y3 */
|
64
|
+
/* asm 1: fe_sub(>X3=fe#1,<AA=fe#5,<Y3=fe#2); */
|
65
|
+
/* asm 2: fe_sub(>X3=r->X,<AA=t0,<Y3=r->Y); */
|
66
|
+
fe_sub(r->X,t0,r->Y);
|
67
|
+
|
68
|
+
/* qhasm: T3=B-Z3 */
|
69
|
+
/* asm 1: fe_sub(>T3=fe#4,<B=fe#4,<Z3=fe#3); */
|
70
|
+
/* asm 2: fe_sub(>T3=r->T,<B=r->T,<Z3=r->Z); */
|
71
|
+
fe_sub(r->T,r->T,r->Z);
|
72
|
+
|
73
|
+
/* qhasm: return */
|