ge25519_batchpack.c 579 B

1234567891011121314151617181920212223
  1. #include "fe25519.h"
  2. #include "ge25519.h"
  3. // NOTE: leaves in unfinished state
  4. void ge25519_batchpack_destructive_1(bytes32 *out, ge25519_p3 *in, fe25519 *tmp, size_t num)
  5. {
  6. fe25519 ty;
  7. fe25519_batchinvert(&in->z, &in->z, tmp, num, sizeof(ge25519_p3));
  8. for (size_t i = 0; i < num; ++i) {
  9. fe25519_mul(&ty, &in[i].y, &in[i].z);
  10. fe25519_pack(out[i], &ty);
  11. }
  12. }
  13. void ge25519_batchpack_destructive_finish(bytes32 out, ge25519_p3 *unf)
  14. {
  15. fe25519 tx;
  16. // z of unfinished is inverted
  17. fe25519_mul(&tx, &unf->x, &unf->z);
  18. out[31] ^= fe25519_getparity(&tx) << 7;
  19. }