mirror of
https://github.com/cathugger/mkp224o.git
synced 2025-12-05 21:27:13 -06:00
dont do indirection in for batch stuff
This commit is contained in:
@@ -53,7 +53,7 @@ extern void fe_sq(fe,const fe);
|
||||
extern void fe_sq2(fe,const fe);
|
||||
extern void fe_mul121666(fe,const fe);
|
||||
extern void fe_invert(fe,const fe);
|
||||
extern void fe_batchinvert(fe *out[],fe tmp[],fe * const in[], size_t num);
|
||||
extern void fe_batchinvert(fe *out,fe *in,fe *tmp,size_t num,size_t shift);
|
||||
extern void fe_pow22523(fe,const fe);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,26 +1,34 @@
|
||||
#include "fe.h"
|
||||
|
||||
// tmp MUST != out
|
||||
// tmp MUST != out or in
|
||||
// in MAY == out
|
||||
void fe_batchinvert(fe *out[],fe tmp[],fe * const in[], size_t num)
|
||||
void fe_batchinvert(fe *out,fe *in,fe *tmp,size_t num,size_t shift)
|
||||
{
|
||||
fe acc;
|
||||
fe tmpacc;
|
||||
size_t i;
|
||||
fe *inp;
|
||||
fe *outp;
|
||||
|
||||
fe_1(acc);
|
||||
|
||||
inp = in;
|
||||
for (i = 0;i < num;++i) {
|
||||
fe_copy(tmp[i],acc);
|
||||
fe_mul(acc,acc,*in[i]);
|
||||
fe_mul(acc,acc,*inp);
|
||||
inp = (fe *)((char *)inp + shift);
|
||||
}
|
||||
|
||||
fe_invert(acc,acc);
|
||||
|
||||
i = num;
|
||||
inp = (fe *)((char *)in + shift * num);
|
||||
outp = (fe *)((char *)out + shift * num);
|
||||
while (i--) {
|
||||
fe_mul(tmpacc,acc,*in[i]);
|
||||
fe_mul(*out[i],acc,tmp[i]);
|
||||
inp = (fe *)((char *)inp - shift);
|
||||
outp = (fe *)((char *)outp - shift);
|
||||
fe_mul(tmpacc,acc,*inp);
|
||||
fe_mul(*outp,acc,tmp[i]);
|
||||
fe_copy(acc,tmpacc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ typedef unsigned char bytes32[32];
|
||||
|
||||
extern void ge_tobytes(unsigned char *,const ge_p2 *);
|
||||
extern void ge_p3_tobytes(unsigned char *,const ge_p3 *);
|
||||
extern void ge_p3_batchtobytes_destructive_1(bytes32 out[],ge_p3 in[],fe *inz[],fe tmp[],size_t num);
|
||||
extern void ge_p3_batchtobytes_destructive_1(bytes32 *out,ge_p3 *in,fe *tmp,size_t num);
|
||||
extern void ge_p3_batchtobytes_destructive_finish(bytes32 out,ge_p3 *unf);
|
||||
extern int ge_frombytes_negate_vartime(ge_p3 *,const unsigned char *);
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
// inz is ge_p3.Z pointer array. contents to .Zs will be overwritten
|
||||
// NOTE: leaves in unfinished state
|
||||
void ge_p3_batchtobytes_destructive_1(bytes32 out[],ge_p3 in[],fe *inz[],fe tmp[],size_t num)
|
||||
void ge_p3_batchtobytes_destructive_1(bytes32 *out,ge_p3 *in,fe *tmp,size_t num)
|
||||
{
|
||||
fe y;
|
||||
|
||||
fe_batchinvert(inz,tmp,inz,num);
|
||||
fe_batchinvert(&in->Z,&in->Z,tmp,num,sizeof(ge_p3));
|
||||
|
||||
for (size_t i = 0;i < num;++i) {
|
||||
fe_mul(y,in[i].Y,in[i].Z);
|
||||
|
||||
Reference in New Issue
Block a user