Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 

83 Zeilen
2.6 KiB

  1. package sidh
  2. import (
  3. . "github.com/cloudflare/p751sidh/internal/isogeny"
  4. p503 "github.com/cloudflare/p751sidh/p503"
  5. p751 "github.com/cloudflare/p751sidh/p751"
  6. )
  7. // Keeps mapping: SIDH prime field ID to domain parameters
  8. var sidhParams = make(map[PrimeFieldId]SidhParams)
  9. // Params returns domain parameters corresponding to finite field and identified by
  10. // `id` provieded by the caller. Function panics in case `id` wasn't registered earlier.
  11. func Params(id PrimeFieldId) *SidhParams {
  12. if val, ok := sidhParams[id]; ok {
  13. return &val
  14. }
  15. panic("sidh: SIDH Params ID unregistered")
  16. }
  17. func init() {
  18. p503 := SidhParams{
  19. Id: FP_503,
  20. PublicKeySize: p503.P503_PublicKeySize,
  21. SharedSecretSize: p503.P503_SharedSecretSize,
  22. A: DomainParams{
  23. Affine_P: p503.P503_affine_PA,
  24. Affine_Q: p503.P503_affine_QA,
  25. Affine_R: p503.P503_affine_RA,
  26. SecretBitLen: p503.P503_SecretBitLenA,
  27. SecretByteLen: uint((p503.P503_SecretBitLenA + 7) / 8),
  28. IsogenyStrategy: p503.P503_AliceIsogenyStrategy[:],
  29. },
  30. B: DomainParams{
  31. Affine_P: p503.P503_affine_PB,
  32. Affine_Q: p503.P503_affine_QB,
  33. Affine_R: p503.P503_affine_RB,
  34. SecretBitLen: p503.P503_SecretBitLenB,
  35. SecretByteLen: uint((p503.P503_SecretBitLenB + 7) / 8),
  36. IsogenyStrategy: p503.P503_BobIsogenyStrategy[:],
  37. },
  38. OneFp2: p503.P503_OneFp2,
  39. HalfFp2: p503.P503_HalfFp2,
  40. MsgLen: 24,
  41. // SIKEp751 provides 128 bit of classical security ([SIKE], 5.1)
  42. KemSize: 16,
  43. Bytelen: p503.P503_Bytelen,
  44. Op: p503.FieldOperations(),
  45. }
  46. p751 := SidhParams{
  47. Id: FP_751,
  48. PublicKeySize: p751.P751_PublicKeySize,
  49. SharedSecretSize: p751.P751_SharedSecretSize,
  50. A: DomainParams{
  51. Affine_P: p751.P751_affine_PA,
  52. Affine_Q: p751.P751_affine_QA,
  53. Affine_R: p751.P751_affine_RA,
  54. IsogenyStrategy: p751.P751_AliceIsogenyStrategy[:],
  55. SecretBitLen: p751.P751_SecretBitLenA,
  56. SecretByteLen: uint((p751.P751_SecretBitLenA + 7) / 8),
  57. },
  58. B: DomainParams{
  59. Affine_P: p751.P751_affine_PB,
  60. Affine_Q: p751.P751_affine_QB,
  61. Affine_R: p751.P751_affine_RB,
  62. IsogenyStrategy: p751.P751_BobIsogenyStrategy[:],
  63. SecretBitLen: p751.P751_SecretBitLenB,
  64. SecretByteLen: uint((p751.P751_SecretBitLenB + 7) / 8),
  65. },
  66. OneFp2: p751.P751_OneFp2,
  67. HalfFp2: p751.P751_HalfFp2,
  68. MsgLen: 32,
  69. // SIKEp751 provides 192 bit of classical security ([SIKE], 5.1)
  70. KemSize: 24,
  71. Bytelen: p751.P751_Bytelen,
  72. Op: p751.FieldOperations(),
  73. }
  74. sidhParams[FP_503] = p503
  75. sidhParams[FP_751] = p751
  76. }