1
0

ge_p3_batchtobytes.c 544 B

1234567891011121314151617181920212223
  1. #include "ge.h"
  2. // inz is ge_p3.Z pointer array. contents to .Zs will be overwritten
  3. // NOTE: leaves in unfinished state
  4. void ge_p3_batchtobytes_destructive_1(bytes32 *out,ge_p3 *in,fe *tmp,size_t num)
  5. {
  6. fe y;
  7. fe_batchinvert(&in->Z,&in->Z,tmp,num,sizeof(ge_p3));
  8. for (size_t i = 0;i < num;++i) {
  9. fe_mul(y,in[i].Y,in[i].Z);
  10. fe_tobytes(out[i],y);
  11. }
  12. }
  13. void ge_p3_batchtobytes_destructive_finish(bytes32 out,ge_p3 *unf)
  14. {
  15. fe x;
  16. // z of unfinished is inverted
  17. fe_mul(x,unf->X,unf->Z);
  18. out[31] ^= fe_isnegative(x) << 7;
  19. }