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.
 
 
 
 
 

82 lines
2.5 KiB

  1. /* Copyright (c) 2014 Cryptography Research, Inc.
  2. * Released under the MIT License. See LICENSE.txt for license information.
  3. */
  4. #include "field.h"
  5. #include "magic.h"
  6. #include "barrett_field.h"
  7. /* FUTURE: automatically generate this file? */
  8. const uint8_t FIELD_MODULUS[FIELD_BYTES] = {
  9. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  10. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  11. /*!*/ 0xfe, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  12. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
  13. };
  14. const word_t SCALARMUL_FIXED_WINDOW_ADJUSTMENT[2*SCALAR_WORDS] = {
  15. U64LE(0xebec9967f5d3f5c2),
  16. U64LE(0x0aa09b49b16c9a02),
  17. U64LE(0x7f6126aec172cd8e),
  18. U64LE(0x00000007b027e54d),
  19. U64LE(0x0000000000000000),
  20. U64LE(0x0000000000000000),
  21. U64LE(0x4000000000000000),
  22. U64LE(0xc873d6d54a7bb0cf),
  23. U64LE(0xe933d8d723a70aad),
  24. U64LE(0xbb124b65129c96fd),
  25. U64LE(0x00000008335dc163),
  26. U64LE(0x0000000000000000),
  27. U64LE(0x0000000000000000),
  28. U64LE(0x0000000000000000)
  29. };
  30. const affine_a_t goldilocks_base_point = {{
  31. #ifdef USE_NEON_PERM
  32. {{{ 0xaed939f,0xc59d070,0xf0de840,0x5f065c3, 0xf4ba0c7,0xdf73324,0xc170033,0x3a6a26a,
  33. 0x4c63d96,0x4609845,0xf3932d9,0x1b4faff, 0x6147eaa,0xa2692ff,0x9cecfa9,0x297ea0e
  34. }}},
  35. #else
  36. {{{ U56LE(0xf0de840aed939f), U56LE(0xc170033f4ba0c7),
  37. U56LE(0xf3932d94c63d96), U56LE(0x9cecfa96147eaa),
  38. U56LE(0x5f065c3c59d070), U56LE(0x3a6a26adf73324),
  39. U56LE(0x1b4faff4609845), U56LE(0x297ea0ea2692ff)
  40. }}},
  41. #endif
  42. {{{ 19 }}}
  43. }};
  44. static const word_t curve_prime_order_lo[(224+WORD_BITS-1)/WORD_BITS] = {
  45. U64LE(0xdc873d6d54a7bb0d),
  46. U64LE(0xde933d8d723a70aa),
  47. U64LE(0x3bb124b65129c96f),
  48. 0x8335dc16
  49. };
  50. const struct barrett_prime_t curve_prime_order = {
  51. GOLDI_FIELD_WORDS,
  52. 62 % WORD_BITS,
  53. sizeof(curve_prime_order_lo)/sizeof(curve_prime_order_lo[0]),
  54. curve_prime_order_lo
  55. };
  56. const field_a_t
  57. sqrt_d_minus_1 = {{{
  58. #ifdef USE_NEON_PERM
  59. 0x6749f46,0x24d9770,0xd2e2183,0xa49f7b4,
  60. 0xb4f0179,0x8c5f656,0x888db42,0xdcac462,
  61. 0xbdeea38,0x748734a,0x5a189aa,0x49443b8,
  62. 0x6f14c06,0x0b25b7a,0x51e65ca,0x12fec0c
  63. #else
  64. U56LE(0xd2e21836749f46),
  65. U56LE(0x888db42b4f0179),
  66. U56LE(0x5a189aabdeea38),
  67. U56LE(0x51e65ca6f14c06),
  68. U56LE(0xa49f7b424d9770),
  69. U56LE(0xdcac4628c5f656),
  70. U56LE(0x49443b8748734a),
  71. U56LE(0x12fec0c0b25b7a)
  72. #endif
  73. }}};