summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjonsykkel <jonrevold@gmail.com>2021-09-21 17:06:10 +0200
committerjonsykkel <jonrevold@gmail.com>2021-09-21 17:08:20 +0200
commit6150b05af3dc19cafe86bf05ae0eeb829faed401 (patch)
treed29bc46cc831d94299d54ec0412760402ff30603
parent7a8b194ba51e444c5f4129ca812c9ed1007bc784 (diff)
downloadokeffa-6150b05af3dc19cafe86bf05ae0eeb829faed401.tar.gz
turbo egypt mul
-rw-r--r--src/fz_mul.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/fz_mul.c b/src/fz_mul.c
index b9d6c09..74d6906 100644
--- a/src/fz_mul.c
+++ b/src/fz_mul.c
@@ -6,22 +6,22 @@
#include <okeffa/w_op.h>
void fz_mul_egypt(word_t *a,word_t *b,word_t *o_lo,word_t *o_hi,size_t len){
- size_t len2 = len*2;
- size_t bitness_m1 = fz_bitness(len)-1;
+ size_t len2 = len*2;
word_t xy[len2];
word_t xs[len2];
- word_t ys[len];
fz_clear(xy,len2);
fz_copy(a,xs,len);
fz_clear(xs+len,len);
- fz_copy(b,ys,len);
- for(size_t x = 0;x < bitness_m1;x++){
- fz_add_gated(xy,xs,xy,len2,fz_odd(ys));
- fz_shl(xs,xs,len2,1);
- fz_shr(ys,ys,len,1);
+ for(size_t y = 0;y < len;y++){
+ word_t w = b[y];
+ size_t cut = len+y+1;
+ for(size_t x = 0;x < WORD_BITNESS;x++){
+ fz_add_gated(xy,xs,xy,cut,w_odd(w));
+ w >>= 1;
+ fz_shl(xs,xs,cut,1);
+ }
}
- fz_add_gated(xy,xs,xy,len2,fz_odd(ys));
fz_copy(xy, o_lo,len);
fz_copy(xy+len,o_hi,len);
}