Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

77 righe
2.2 KiB

  1. package sidh
  2. import . "github.com/cloudflare/p751sidh/p751toolbox"
  3. type DomainParams struct {
  4. // P, Q and R=P-Q base points
  5. Affine_P, Affine_Q, Affine_R ExtensionFieldElement
  6. // Max size of secret key for x-torsion group
  7. SecretBitLen uint
  8. // MaskBytes
  9. MaskBytes []byte
  10. // Size of a compuatation strategy for x-torsion group
  11. IsogenyStrategy []uint32
  12. }
  13. type SidhParams struct {
  14. Id PrimeFieldId
  15. // The secret key size, in bytes.
  16. SecretKeySize int
  17. // The public key size, in bytes.
  18. PublicKeySize int
  19. // The shared secret size, in bytes.
  20. SharedSecretSize uint
  21. // 2- and 3-torsion group parameter definitions
  22. A, B DomainParams
  23. // Sample rate to obtain a value in [0,3^238]
  24. SampleRate uint
  25. // Length of SIKE secret message. Must be one of {24,32,40},
  26. // depending on size of prime field used (see [SIKE], 1.4 and 5.1)
  27. MsgLen uint
  28. // Length of SIKE ephemeral KEM key (see [SIKE], 1.4 and 5.1)
  29. KemSize uint
  30. }
  31. // Keeps mapping: SIDH prime field ID to domain parameters
  32. var sidhParams = make(map[PrimeFieldId]SidhParams)
  33. // Params returns domain parameters corresponding to finite field and identified by
  34. // `id` provieded by the caller. Function panics in case `id` wasn't registered earlier.
  35. func Params(id PrimeFieldId) *SidhParams {
  36. if val, ok := sidhParams[id]; ok {
  37. return &val
  38. }
  39. panic("sidh: SIDH Params ID unregistered")
  40. }
  41. func init() {
  42. p751 := SidhParams{
  43. Id: FP_751,
  44. SecretKeySize: P751_SecretKeySize,
  45. PublicKeySize: P751_PublicKeySize,
  46. SharedSecretSize: P751_SharedSecretSize,
  47. A: DomainParams{
  48. Affine_P: P751_affine_PA,
  49. Affine_Q: P751_affine_QA,
  50. Affine_R: P751_affine_RA,
  51. SecretBitLen: P751_SecretBitLenA,
  52. MaskBytes: []byte{P751_MaskAliceByte1, P751_MaskAliceByte2, P751_MaskAliceByte3},
  53. IsogenyStrategy: P751_AliceIsogenyStrategy[:],
  54. },
  55. B: DomainParams{
  56. Affine_P: P751_affine_PB,
  57. Affine_Q: P751_affine_QB,
  58. Affine_R: P751_affine_RB,
  59. SecretBitLen: P751_SecretBitLenB,
  60. MaskBytes: []byte{P751_MaskBobByte},
  61. IsogenyStrategy: P751_BobIsogenyStrategy[:],
  62. },
  63. MsgLen: 32,
  64. // SIKEp751 provides 192 bit of classical security ([SIKE], 5.1)
  65. KemSize: 24,
  66. SampleRate: P751_SampleRate,
  67. }
  68. sidhParams[FP_751] = p751
  69. }