mirror of
https://github.com/cathugger/mkp224o.git
synced 2025-05-25 11:22:22 +00:00
ref10: batch invert maybe
This commit is contained in:
parent
f89c2d778c
commit
5bb3d0f821
3 changed files with 32 additions and 3 deletions
|
@ -2,6 +2,7 @@
|
|||
#define FE_H
|
||||
|
||||
#include "crypto_int32.h"
|
||||
#include <stddef.h>
|
||||
|
||||
typedef crypto_int32 fe[10];
|
||||
|
||||
|
@ -30,6 +31,7 @@ Bounds on each t[i] vary depending on context.
|
|||
#define fe_sq2 crypto_sign_ed25519_ref10_fe_sq2
|
||||
#define fe_mul121666 crypto_sign_ed25519_ref10_fe_mul121666
|
||||
#define fe_invert crypto_sign_ed25519_ref10_fe_invert
|
||||
#define fe_batchinvert crypto_sign_ed25519_ref10_fe_batchinvert
|
||||
#define fe_pow22523 crypto_sign_ed25519_ref10_fe_pow22523
|
||||
|
||||
extern void fe_frombytes(fe,const unsigned char *);
|
||||
|
@ -51,6 +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[],const fe in[], size_t num);
|
||||
extern void fe_pow22523(fe,const fe);
|
||||
|
||||
#endif
|
||||
|
|
26
ed25519/ref10/fe_batchinvert.c
Normal file
26
ed25519/ref10/fe_batchinvert.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
#include "fe.h"
|
||||
|
||||
// tmp MUST != out
|
||||
// in MAY == out
|
||||
void fe_batchinvert(fe out[],fe tmp[],const fe in[], size_t num)
|
||||
{
|
||||
fe acc;
|
||||
fe tmpacc;
|
||||
size_t i;
|
||||
|
||||
fe_1(acc);
|
||||
|
||||
for (i = 0;i < num;++i) {
|
||||
fe_copy(tmp[i],acc);
|
||||
fe_mul(acc,acc,in[i]);
|
||||
}
|
||||
|
||||
fe_invert(acc,acc);
|
||||
|
||||
i = num;
|
||||
while (i--) {
|
||||
fe_mul(tmpacc,acc,in[i]);
|
||||
fe_mul(out[i],acc,tmp[i]);
|
||||
fe_copy(acc,tmpacc);
|
||||
}
|
||||
}
|
6
main.c
6
main.c
|
@ -291,7 +291,7 @@ again:
|
|||
// base32
|
||||
strcpy(base32_to(&sname[direndpos],pk,PUBONION_LEN),".onion");
|
||||
onionready(sname,secret,pubonion.raw);
|
||||
pk[PUBLIC_LEN] = 0;
|
||||
pk[PUBLIC_LEN] = 0; // what is this for?
|
||||
goto initseed;
|
||||
});
|
||||
next:
|
||||
|
@ -391,7 +391,7 @@ initseed:
|
|||
// full name
|
||||
strcpy(base32_to(&sname[direndpos],pk,PUBONION_LEN),".onion");
|
||||
onionready(sname,secret,pubonion.raw);
|
||||
pk[PUBLIC_LEN] = 0;
|
||||
pk[PUBLIC_LEN] = 0; // what is this for?
|
||||
// don't reuse same seed
|
||||
goto initseed;
|
||||
});
|
||||
|
@ -494,7 +494,7 @@ initseed:
|
|||
// full name
|
||||
strcpy(base32_to(&sname[direndpos],pk,PUBONION_LEN),".onion");
|
||||
onionready(sname,secret,pubonion.raw);
|
||||
pk[PUBLIC_LEN] = 0;
|
||||
pk[PUBLIC_LEN] = 0; // what is this for?
|
||||
});
|
||||
next:
|
||||
ge_add(&sum, &ge_public,&ge_eightpoint);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue