You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@milagro.apache.org by sa...@apache.org on 2020/03/06 09:15:43 UTC
[incubator-milagro-crypto-c] 02/02: Add missing norms
This is an automated email from the ASF dual-hosted git repository.
sandreoli pushed a commit to branch issue75-review-norm
in repository https://gitbox.apache.org/repos/asf/incubator-milagro-crypto-c.git
commit 0fac9ed257f3c6b2747d4e4b09d79a2d4865759e
Author: Samuele Andreoli <sa...@yahoo.it>
AuthorDate: Thu Mar 5 14:17:07 2020 +0000
Add missing norms
---
src/ecp2.c.in | 1 +
src/ecp4.c.in | 1 +
src/ecp8.c.in | 1 +
src/fp.c.in | 1 +
src/fp4.c.in | 1 +
src/fp8.c.in | 4 ++--
6 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/ecp2.c.in b/src/ecp2.c.in
index 4a6f937..6061d98 100644
--- a/src/ecp2.c.in
+++ b/src/ecp2.c.in
@@ -641,6 +641,7 @@ void ECP2_ZZZ_mapit(ECP2_ZZZ *Q,octet *W)
FP2_YYY_from_BIGs(&X,one,hv);
if (ECP2_ZZZ_setx(Q,&X)) break;
BIG_XXX_inc(hv,1);
+ BIG_XXX_norm(hv);
}
BIG_XXX_rcopy(Fx,Fra_YYY);
diff --git a/src/ecp4.c.in b/src/ecp4.c.in
index 3f95f7a..3a35199 100644
--- a/src/ecp4.c.in
+++ b/src/ecp4.c.in
@@ -744,6 +744,7 @@ void ECP4_ZZZ_mapit(ECP4_ZZZ *Q,octet *W)
FP4_YYY_from_FP2(&X4,&T);
if (ECP4_ZZZ_setx(Q,&X4)) break;
BIG_XXX_inc(hv,1);
+ BIG_XXX_norm(hv);
}
ECP4_ZZZ_frob_constants(X);
diff --git a/src/ecp8.c.in b/src/ecp8.c.in
index f807da2..2cca877 100644
--- a/src/ecp8.c.in
+++ b/src/ecp8.c.in
@@ -893,6 +893,7 @@ void ECP8_ZZZ_mapit(ECP8_ZZZ *Q,octet *W)
FP8_YYY_from_FP4(&X8,&X4);
if (ECP8_ZZZ_setx(Q,&X8)) break;
BIG_XXX_inc(hv,1);
+ BIG_XXX_norm(hv);
}
ECP8_ZZZ_frob_constants(X);
diff --git a/src/fp.c.in b/src/fp.c.in
index ec1ab9a..7a98312 100644
--- a/src/fp.c.in
+++ b/src/fp.c.in
@@ -767,6 +767,7 @@ void FP_YYY_sqrt(FP_YYY *r,FP_YYY *a)
FP_YYY_mul(&i,&i,&v); // i=(2x)^(p+3)/8
FP_YYY_mul(&i,&i,&v); // i=(2x)^(p-1)/4
BIG_XXX_dec(i.g,1); // i=(2x)^(p-1)/4 - 1
+ BIG_XXX_norm(i.g);
FP_YYY_mul(r,a,&v);
FP_YYY_mul(r,r,&i);
FP_YYY_reduce(r);
diff --git a/src/fp4.c.in b/src/fp4.c.in
index c1c54f0..3e3b64b 100644
--- a/src/fp4.c.in
+++ b/src/fp4.c.in
@@ -624,6 +624,7 @@ int FP4_YYY_sqrt(FP4_YYY *r,FP4_YYY* x)
FP2_YYY_mul_ip(&s);
FP2_YYY_norm(&s);
FP2_YYY_sub(&a,&a,&s); // a-=txx(s)
+ FP2_YYY_norm(&a);
if (!FP2_YYY_sqrt(&s,&a)) return 0;
diff --git a/src/fp8.c.in b/src/fp8.c.in
index 9fe0452..e4557df 100644
--- a/src/fp8.c.in
+++ b/src/fp8.c.in
@@ -614,12 +614,12 @@ int FP8_YYY_sqrt(FP8_YYY *r,FP8_YYY* x)
FP4_YYY_times_i(&s);
FP4_YYY_norm(&s);
FP4_YYY_sub(&a,&a,&s); // a-=txx(s)
+ FP4_YYY_norm(&a);
if (!FP4_YYY_sqrt(&s,&a)) return 0;
FP4_YYY_sqr(&t,&s);
-
FP4_YYY_copy(&t,&(x->a));
FP4_YYY_add(&a,&t,&s);
FP4_YYY_norm(&a);
@@ -635,13 +635,13 @@ int FP8_YYY_sqrt(FP8_YYY *r,FP8_YYY* x)
FP4_YYY_copy(&t,&(x->b));
FP4_YYY_add(&s,&a,&a);
+ FP4_YYY_norm(&s);
FP4_YYY_inv(&s,&s);
FP4_YYY_mul(&t,&t,&s);
FP8_YYY_from_FP4s(r,&a,&t);
return 1;
-
}