Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

185 linhas
6.1 KiB

  1. package sike
  2. const (
  3. // Number of uint64 limbs used to store field element
  4. FP_WORDS = 7
  5. )
  6. // Used internally by this package
  7. // -------------------------------
  8. var (
  9. p = Fp{
  10. 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFDC1767AE2FFFFFF,
  11. 0x7BC65C783158AEA3, 0x6CFC5FD681C52056, 0x2341F27177344,
  12. }
  13. // 2*p434
  14. pX2 = Fp{
  15. 0xFFFFFFFFFFFFFFFE, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFB82ECF5C5FFFFFF,
  16. 0xF78CB8F062B15D47, 0xD9F8BFAD038A40AC, 0x4683E4E2EE688,
  17. }
  18. // p434 + 1
  19. p1 = Fp{
  20. 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0xFDC1767AE3000000,
  21. 0x7BC65C783158AEA3, 0x6CFC5FD681C52056, 0x0002341F27177344,
  22. }
  23. // R^2=(2^448)^2 mod p
  24. pR2 = Fp{
  25. 0x28E55B65DCD69B30, 0xACEC7367768798C2, 0xAB27973F8311688D, 0x175CC6AF8D6C7C0B,
  26. 0xABCD92BF2DDE347E, 0x69E16A61C7686D9A, 0x000025A89BCDD12A,
  27. }
  28. // 1/2 * R mod p
  29. half = Fp2{
  30. A: Fp{
  31. 0x0000000000003A16, 0x0000000000000000, 0x0000000000000000, 0x5C87FA027E000000,
  32. 0x6C00D27DAACFD66A, 0x74992A2A2FBBA086, 0x0000767753DE976D},
  33. }
  34. // 1*R mod p
  35. one = Fp2{
  36. A: Fp{
  37. 0x000000000000742C, 0x0000000000000000, 0x0000000000000000, 0xB90FF404FC000000,
  38. 0xD801A4FB559FACD4, 0xE93254545F77410C, 0x0000ECEEA7BD2EDA},
  39. }
  40. // 6*R mod p
  41. six = Fp2{
  42. A: Fp{
  43. 0x000000000002B90A, 0x0000000000000000, 0x0000000000000000, 0x5ADCCB2822000000,
  44. 0x187D24F39F0CAFB4, 0x9D353A4D394145A0, 0x00012559A0403298},
  45. }
  46. Params SidhParams
  47. )
  48. func init() {
  49. Params = SidhParams{
  50. // SIDH public key byte size.
  51. PublicKeySize: 330,
  52. // SIDH shared secret byte size.
  53. SharedSecretSize: 110,
  54. InitCurve: ProjectiveCurveParameters{
  55. A: six,
  56. C: one,
  57. },
  58. A: DomainParams{
  59. // The x-coordinate of PA
  60. Affine_P: Fp2{
  61. A: Fp{
  62. 0x05ADF455C5C345BF, 0x91935C5CC767AC2B, 0xAFE4E879951F0257, 0x70E792DC89FA27B1,
  63. 0xF797F526BB48C8CD, 0x2181DB6131AF621F, 0x00000A1C08B1ECC4,
  64. },
  65. B: Fp{
  66. 0x74840EB87CDA7788, 0x2971AA0ECF9F9D0B, 0xCB5732BDF41715D5, 0x8CD8E51F7AACFFAA,
  67. 0xA7F424730D7E419F, 0xD671EB919A179E8C, 0x0000FFA26C5A924A,
  68. },
  69. },
  70. // The x-coordinate of QA
  71. Affine_Q: Fp2{
  72. A: Fp{
  73. 0xFEC6E64588B7273B, 0xD2A626D74CBBF1C6, 0xF8F58F07A78098C7, 0xE23941F470841B03,
  74. 0x1B63EDA2045538DD, 0x735CFEB0FFD49215, 0x0001C4CB77542876,
  75. },
  76. B: Fp{
  77. 0xADB0F733C17FFDD6, 0x6AFFBD037DA0A050, 0x680EC43DB144E02F, 0x1E2E5D5FF524E374,
  78. 0xE2DDA115260E2995, 0xA6E4B552E2EDE508, 0x00018ECCDDF4B53E,
  79. },
  80. },
  81. // The x-coordinate of RA = PA-QA
  82. Affine_R: Fp2{
  83. A: Fp{
  84. 0x01BA4DB518CD6C7D, 0x2CB0251FE3CC0611, 0x259B0C6949A9121B, 0x60E17AC16D2F82AD,
  85. 0x3AA41F1CE175D92D, 0x413FBE6A9B9BC4F3, 0x00022A81D8D55643,
  86. },
  87. B: Fp{
  88. 0xB8ADBC70FC82E54A, 0xEF9CDDB0D5FADDED, 0x5820C734C80096A0, 0x7799994BAA96E0E4,
  89. 0x044961599E379AF8, 0xDB2B94FBF09F27E2, 0x0000B87FC716C0C6,
  90. },
  91. },
  92. // Max size of secret key for 2-torsion group, corresponds to 2^e2 - 1
  93. SecretBitLen: 216,
  94. // SecretBitLen in bytes.
  95. SecretByteLen: 28,
  96. // 2-torsion group computation strategy
  97. IsogenyStrategy: []uint32{
  98. 0x30, 0x1C, 0x10, 0x08, 0x04, 0x02, 0x01, 0x01, 0x02, 0x01,
  99. 0x01, 0x04, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x08, 0x04,
  100. 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x04, 0x02, 0x01, 0x01,
  101. 0x02, 0x01, 0x01, 0x0D, 0x07, 0x04, 0x02, 0x01, 0x01, 0x02,
  102. 0x01, 0x01, 0x03, 0x02, 0x01, 0x01, 0x01, 0x01, 0x05, 0x04,
  103. 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01,
  104. 0x15, 0x0C, 0x07, 0x04, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01,
  105. 0x03, 0x02, 0x01, 0x01, 0x01, 0x01, 0x05, 0x03, 0x02, 0x01,
  106. 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x09, 0x05, 0x03,
  107. 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x04,
  108. 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01},
  109. },
  110. B: DomainParams{
  111. // The x-coordinate of PB
  112. Affine_P: Fp2{
  113. A: Fp{
  114. 0x6E5497556EDD48A3, 0x2A61B501546F1C05, 0xEB919446D049887D, 0x5864A4A69D450C4F,
  115. 0xB883F276A6490D2B, 0x22CC287022D5F5B9, 0x0001BED4772E551F,
  116. },
  117. B: Fp{
  118. 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
  119. 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
  120. },
  121. },
  122. // The x-coordinate of QB
  123. Affine_Q: Fp2{
  124. A: Fp{
  125. 0xFAE2A3F93D8B6B8E, 0x494871F51700FE1C, 0xEF1A94228413C27C, 0x498FF4A4AF60BD62,
  126. 0xB00AD2A708267E8A, 0xF4328294E017837F, 0x000034080181D8AE,
  127. },
  128. B: Fp{
  129. 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
  130. 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
  131. },
  132. },
  133. // The x-coordinate of RB = PB - QB
  134. Affine_R: Fp2{
  135. A: Fp{
  136. 0x283B34FAFEFDC8E4, 0x9208F44977C3E647, 0x7DEAE962816F4E9A, 0x68A2BA8AA262EC9D,
  137. 0x8176F112EA43F45B, 0x02106D022634F504, 0x00007E8A50F02E37,
  138. },
  139. B: Fp{
  140. 0xB378B7C1DA22CCB1, 0x6D089C99AD1D9230, 0xEBE15711813E2369, 0x2B35A68239D48A53,
  141. 0x445F6FD138407C93, 0xBEF93B29A3F6B54B, 0x000173FA910377D3,
  142. },
  143. },
  144. // Size of secret key for 3-torsion group, corresponds to log_2(3^e3) - 1.
  145. SecretBitLen: 217,
  146. // SecretBitLen in bytes.
  147. SecretByteLen: 28,
  148. // 3-torsion group computation strategy
  149. IsogenyStrategy: []uint32{
  150. 0x42, 0x21, 0x11, 0x09, 0x05, 0x03, 0x02, 0x01, 0x01, 0x01,
  151. 0x01, 0x02, 0x01, 0x01, 0x01, 0x04, 0x02, 0x01, 0x01, 0x01,
  152. 0x02, 0x01, 0x01, 0x08, 0x04, 0x02, 0x01, 0x01, 0x01, 0x02,
  153. 0x01, 0x01, 0x04, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x10,
  154. 0x08, 0x04, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x04,
  155. 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x08, 0x04, 0x02, 0x01,
  156. 0x01, 0x02, 0x01, 0x01, 0x04, 0x02, 0x01, 0x01, 0x02, 0x01,
  157. 0x01, 0x20, 0x10, 0x08, 0x04, 0x03, 0x01, 0x01, 0x01, 0x01,
  158. 0x02, 0x01, 0x01, 0x04, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01,
  159. 0x08, 0x04, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x04, 0x02,
  160. 0x01, 0x01, 0x02, 0x01, 0x01, 0x10, 0x08, 0x04, 0x02, 0x01,
  161. 0x01, 0x02, 0x01, 0x01, 0x04, 0x02, 0x01, 0x01, 0x02, 0x01,
  162. 0x01, 0x08, 0x04, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x04,
  163. 0x02, 0x01, 0x01, 0x02, 0x01, 0x01},
  164. },
  165. OneFp2: one,
  166. HalfFp2: half,
  167. MsgLen: 16,
  168. // SIKEp434 provides 128 bit of classical security ([SIKE], 5.1)
  169. KemSize: 16,
  170. // ceil(434+7/8)
  171. Bytelen: 55,
  172. CiphertextSize: 16 + 330,
  173. }
  174. }