sc25519_window4.c 532 B

123456789101112131415161718192021222324252627
  1. #include "sc25519.h"
  2. void sc25519_window4(signed char r[64], const sc25519 *s)
  3. {
  4. char carry;
  5. int i;
  6. for(i=0;i<16;i++)
  7. r[i] = (s->v[0] >> (4*i)) & 15;
  8. for(i=0;i<16;i++)
  9. r[i+16] = (s->v[1] >> (4*i)) & 15;
  10. for(i=0;i<16;i++)
  11. r[i+32] = (s->v[2] >> (4*i)) & 15;
  12. for(i=0;i<16;i++)
  13. r[i+48] = (s->v[3] >> (4*i)) & 15;
  14. /* Making it signed */
  15. carry = 0;
  16. for(i=0;i<63;i++)
  17. {
  18. r[i] += carry;
  19. r[i+1] += r[i] >> 4;
  20. r[i] &= 15;
  21. carry = r[i] >> 3;
  22. r[i] -= carry << 4;
  23. }
  24. r[63] += carry;
  25. }