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.
 
 
 
 
 

140 lines
3.7 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, 0xFF, 0xFF,
  10. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  11. 0xFF, 0xFF, 0xFF, 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, 0xFF, 0xFF,
  13. 0xFF, 0x01
  14. };
  15. const word_t SCALARMUL_FIXED_WINDOW_ADJUSTMENT[2*SCALAR_WORDS] = {
  16. U64LE(0xbf15dbca0ae7f294),
  17. U64LE(0x04273ba96570e0ba),
  18. U64LE(0xc94750a1813ac0fb),
  19. U64LE(0xea4939b8b9037a08),
  20. U64LE(0x0000000000000002),
  21. U64LE(0x0000000000000000),
  22. U64LE(0x0000000000000000),
  23. U64LE(0x0000000000000000),
  24. 0x80,
  25. U64LE(0x7e2bb79415cfe529),
  26. U64LE(0x084e7752cae1c175),
  27. U64LE(0x928ea143027581f6),
  28. U64LE(0xd49273717206f411),
  29. U64LE(0x0000000000000005),
  30. U64LE(0x0000000000000000),
  31. U64LE(0x0000000000000000),
  32. U64LE(0x0000000000000000),
  33. 0x0
  34. };
  35. const struct affine_t goldilocks_base_point = {
  36. {{{
  37. #ifdef USE_P521_3x3_TRANSPOSE
  38. U58LE(0x02a940a2f19ba6c),
  39. U58LE(0x3331c90d2c6ba52),
  40. U58LE(0x2878a3bfd9f42fc),
  41. 0,
  42. U58LE(0x03ec4cd920e2a8c),
  43. U58LE(0x0c6203913f6ecc5),
  44. U58LE(0x06277e432c8a5ac),
  45. 0,
  46. U58LE(0x1d568fc99c6059d),
  47. U58LE(0x1b2063b22fcf270),
  48. U58LE(0x0752cb45c48648b),
  49. 0
  50. #else
  51. U58LE(0x02a940a2f19ba6c),
  52. U58LE(0x03ec4cd920e2a8c),
  53. U58LE(0x1d568fc99c6059d),
  54. U58LE(0x3331c90d2c6ba52),
  55. U58LE(0x0c6203913f6ecc5),
  56. U58LE(0x1b2063b22fcf270),
  57. U58LE(0x2878a3bfd9f42fc),
  58. U58LE(0x06277e432c8a5ac),
  59. U58LE(0x0752cb45c48648b)
  60. #endif
  61. }}},
  62. {{{ 12 }}}
  63. };
  64. static const word_t curve_prime_order_lo[(261+WORD_BITS-1)/WORD_BITS] = {
  65. U64LE(0xbf15dbca0ae7f295),
  66. U64LE(0x4273ba96570e0ba),
  67. U64LE(0xc94750a1813ac0fb),
  68. U64LE(0xea4939b8b9037a08),
  69. 2
  70. };
  71. const struct barrett_prime_t curve_prime_order = {
  72. GOLDI_FIELD_WORDS,
  73. 7 % WORD_BITS,
  74. sizeof(curve_prime_order_lo)/sizeof(curve_prime_order_lo[0]),
  75. curve_prime_order_lo
  76. };
  77. const field_a_t
  78. sqrt_d_minus_1 = {{{
  79. #ifdef USE_P521_3x3_TRANSPOSE
  80. U58LE(0x1e2be72c1c81990),
  81. U58LE(0x207dfc238a33e46),
  82. U58LE(0x2264cfb418c4c30),
  83. 0,
  84. U58LE(0x1135002ad596c69),
  85. U58LE(0x0e30107cd79d1f6),
  86. U58LE(0x0524b9e715937f5),
  87. 0,
  88. U58LE(0x2ab3a257a22666d),
  89. U58LE(0x2d80cc2936a1824),
  90. U58LE(0x0a9ea3ac10d6aed),
  91. 0
  92. #else
  93. U58LE(0x1e2be72c1c81990),
  94. U58LE(0x1135002ad596c69),
  95. U58LE(0x2ab3a257a22666d),
  96. U58LE(0x207dfc238a33e46),
  97. U58LE(0x0e30107cd79d1f6),
  98. U58LE(0x2d80cc2936a1824),
  99. U58LE(0x2264cfb418c4c30),
  100. U58LE(0x0524b9e715937f5),
  101. U58LE(0x0a9ea3ac10d6aed)
  102. #endif
  103. }}};
  104. const field_a_t
  105. sqrt_minus_d = {{{
  106. #ifdef USE_P521_3x3_TRANSPOSE
  107. U58LE(0x375d668ef98910e),
  108. U58LE(0x2e033a89e955dfc),
  109. U58LE(0x11539170515b2da),
  110. 0,
  111. U58LE(0x1d88a078877dc00),
  112. U58LE(0x38dac4db4b0312c),
  113. U58LE(0x009993c0e8ee528),
  114. 0,
  115. U58LE(0x34829cd5d7c1584),
  116. U58LE(0x2c688534aa9c317),
  117. U58LE(0x0d07656ee612ae6),
  118. 0
  119. #else
  120. U58LE(0x375d668ef98910e),
  121. U58LE(0x1d88a078877dc00),
  122. U58LE(0x34829cd5d7c1584),
  123. U58LE(0x2e033a89e955dfc),
  124. U58LE(0x38dac4db4b0312c),
  125. U58LE(0x2c688534aa9c317),
  126. U58LE(0x11539170515b2da),
  127. U58LE(0x009993c0e8ee528),
  128. U58LE(0x0d07656ee612ae6)
  129. #endif
  130. }}};