mkp224o/ed25519/ref10/ge_p3_batchtobytes.c

24 lines
544 B
C
Raw Normal View History

2019-01-19 15:45:25 +00:00
#include "ge.h"
// inz is ge_p3.Z pointer array. contents to .Zs will be overwritten
2019-01-20 01:04:48 +02:00
// NOTE: leaves in unfinished state
2020-11-22 10:21:06 +00:00
void ge_p3_batchtobytes_destructive_1(bytes32 *out,ge_p3 *in,fe *tmp,size_t num)
2019-01-19 15:45:25 +00:00
{
fe y;
2020-11-22 10:21:06 +00:00
fe_batchinvert(&in->Z,&in->Z,tmp,num,sizeof(ge_p3));
2019-01-19 15:45:25 +00:00
for (size_t i = 0;i < num;++i) {
2019-01-20 01:04:48 +02:00
fe_mul(y,in[i].Y,in[i].Z);
2019-01-19 15:45:25 +00:00
fe_tobytes(out[i],y);
}
}
2019-01-20 01:04:48 +02:00
void ge_p3_batchtobytes_destructive_finish(bytes32 out,ge_p3 *unf)
{
fe x;
// z of unfinished is inverted
fe_mul(x,unf->X,unf->Z);
out[31] ^= fe_isnegative(x) << 7;
}