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.
 
 
 
 
 

44 lines
1.1 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. void
  12. gf_isr (
  13. gf_a_t a,
  14. const gf_a_t x
  15. ) {
  16. gf_a_t L0, L1, L2;
  17. gf_sqr ( L1, x );
  18. gf_mul ( L0, x, L1 );
  19. gf_sqrn ( L2, L0, 2 );
  20. gf_mul ( L1, L0, L2 );
  21. gf_sqrn ( L2, L1, 4 );
  22. gf_mul ( L0, L1, L2 );
  23. gf_sqrn ( L2, L0, 8 );
  24. gf_mul ( L1, L0, L2 );
  25. gf_sqrn ( L2, L1, 16 );
  26. gf_mul ( L0, L1, L2 );
  27. gf_sqrn ( L2, L0, 32 );
  28. gf_mul ( L1, L0, L2 );
  29. gf_sqr ( L2, L1 );
  30. gf_mul ( L0, x, L2 );
  31. gf_sqrn ( L2, L0, 64 );
  32. gf_mul ( L0, L1, L2 );
  33. gf_sqrn ( L2, L0, 129 );
  34. gf_mul ( L1, L0, L2 );
  35. gf_sqr ( L2, L1 );
  36. gf_mul ( L0, x, L2 );
  37. gf_sqrn ( L2, L0, 259 );
  38. gf_mul ( L1, L0, L2 );
  39. gf_sqr ( L0, L1 );
  40. gf_mul ( a, x, L0 );
  41. }