You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

50 lines
1.3 KiB

  1. /**
  2. * @cond internal
  3. * @file f_arithmetic.c
  4. * @copyright
  5. * Copyright (c) 2014 Cryptography Research, Inc. \n
  6. * Released under the MIT License. See LICENSE.txt for license information.
  7. * @author Mike Hamburg
  8. * @brief Field-specific arithmetic.
  9. */
  10. #include "field.h"
  11. const gf MODULUS = {FIELD_LITERAL(
  12. 0xfffffffffffffff, 0xfffffffffffffff, 0xfffffffffffffff, 0xfffffffffffffff,
  13. 0xffffffffffffffe, 0xfffffffffffffff, 0xfffffffffffffff, 0xfffffffffffffff
  14. )};
  15. void
  16. gf_isr (
  17. gf_a_t a,
  18. const gf_a_t x
  19. ) {
  20. gf_a_t L0, L1, L2, L3;
  21. gf_sqr ( L2, x );
  22. gf_mul ( L1, x, L2 );
  23. gf_sqrn ( L0, L1, 2 );
  24. gf_mul ( L2, L1, L0 );
  25. gf_sqrn ( L0, L2, 4 );
  26. gf_mul ( L1, L2, L0 );
  27. gf_sqr ( L0, L1 );
  28. gf_mul ( L2, x, L0 );
  29. gf_sqrn ( L0, L2, 8 );
  30. gf_mul ( L2, L1, L0 );
  31. gf_sqrn ( L0, L2, 17 );
  32. gf_mul ( L1, L2, L0 );
  33. gf_sqrn ( L0, L1, 17 );
  34. gf_mul ( L1, L2, L0 );
  35. gf_sqrn ( L3, L1, 17 );
  36. gf_mul ( L0, L2, L3 );
  37. gf_sqrn ( L2, L0, 51 );
  38. gf_mul ( L0, L1, L2 );
  39. gf_sqrn ( L1, L0, 119 );
  40. gf_mul ( L2, L0, L1 );
  41. gf_sqr ( L0, L2 );
  42. gf_mul ( L1, x, L0 );
  43. gf_sqrn ( L0, L1, 239 );
  44. gf_mul ( a, L2, L0 );
  45. }