mirror of
https://github.com/cathugger/mkp224o.git
synced 2025-04-20 22:09:10 +00:00
add missing files, 2 stage batch pack
This commit is contained in:
parent
f944bb64a2
commit
8f248cbd14
2 changed files with 50 additions and 0 deletions
26
ed25519/amd64-64-24k/fe25519_batchinvert.c
Normal file
26
ed25519/amd64-64-24k/fe25519_batchinvert.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
#include "fe25519.h"
|
||||
|
||||
// tmp MUST != out
|
||||
// in MAY == out
|
||||
void fe25519_batchinvert(fe25519 *out[],fe25519 tmp[],fe25519 * const in[], size_t num)
|
||||
{
|
||||
fe25519 acc;
|
||||
fe25519 tmpacc;
|
||||
size_t i;
|
||||
|
||||
fe25519_setint(&acc,1);
|
||||
|
||||
for (i = 0;i < num;++i) {
|
||||
tmp[i] = acc;
|
||||
fe25519_mul(&acc,&acc,in[i]);
|
||||
}
|
||||
|
||||
fe25519_invert(&acc,&acc);
|
||||
|
||||
i = num;
|
||||
while (i--) {
|
||||
fe25519_mul(&tmpacc,&acc,in[i]);
|
||||
fe25519_mul(out[i],&acc,&tmp[i]);
|
||||
acc = tmpacc;
|
||||
}
|
||||
}
|
24
ed25519/amd64-64-24k/ge25519_batchpack.c
Normal file
24
ed25519/amd64-64-24k/ge25519_batchpack.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include "fe25519.h"
|
||||
#include "ge25519.h"
|
||||
|
||||
// assumes inz[] points to things in in[]
|
||||
// NOTE: leaves in unfinished state
|
||||
void ge25519_batchpack_destructive_1(bytes32 out[], ge25519_p3 in[], fe25519 *inz[], fe25519 tmp[], size_t num)
|
||||
{
|
||||
fe25519 ty;
|
||||
|
||||
fe25519_batchinvert(inz, tmp, inz, num);
|
||||
|
||||
for (size_t i = 0; i < num; ++i) {
|
||||
fe25519_mul(&ty, &in[i].y, &in[i].z);
|
||||
fe25519_pack(out[i], &ty);
|
||||
}
|
||||
}
|
||||
|
||||
void ge25519_batchpack_destructive_finish(bytes32 out, ge25519_p3 *unf)
|
||||
{
|
||||
fe25519 tx;
|
||||
// z of unfinished is inverted
|
||||
fe25519_mul(&tx, &unf->x, &unf->z);
|
||||
out[31] ^= fe25519_getparity(&tx) << 7;
|
||||
}
|
Loading…
Add table
Reference in a new issue