package sidh import ( // p503 "github.com/cloudflare/p751sidh/p503toolbox" p751 "github.com/cloudflare/p751sidh/p751toolbox" . "github.com/cloudflare/p751sidh/internal/utils" ) type ctxCtor func() OperationContext type DomainParams struct { // P, Q and R=P-Q base points Affine_P, Affine_Q, Affine_R p751.ExtensionFieldElement // Max size of secret key for x-torsion group SecretBitLen uint // MaskBytes MaskBytes []byte // Size of a compuatation strategy for x-torsion group IsogenyStrategy []uint32 } type SidhParams struct { Id PrimeFieldId // The secret key size, in bytes. SecretKeySize int // The public key size, in bytes. PublicKeySize int // The shared secret size, in bytes. SharedSecretSize uint // 2- and 3-torsion group parameter definitions A, B DomainParams // Sample rate to obtain a value in [0,3^238] SampleRate uint // Length of SIKE secret message. Must be one of {24,32,40}, // depending on size of prime field used (see [SIKE], 1.4 and 5.1) MsgLen uint // Length of SIKE ephemeral KEM key (see [SIKE], 1.4 and 5.1) KemSize uint // Creates operation context op ctxCtor } // Keeps mapping: SIDH prime field ID to domain parameters var sidhParams = make(map[PrimeFieldId]SidhParams) // Params returns domain parameters corresponding to finite field and identified by // `id` provieded by the caller. Function panics in case `id` wasn't registered earlier. func Params(id PrimeFieldId) *SidhParams { if val, ok := sidhParams[id]; ok { return &val } panic("sidh: SIDH Params ID unregistered") } func init() { p751 := SidhParams{ Id: FP_751, SecretKeySize: p751.P751_SecretKeySize, PublicKeySize: p751.P751_PublicKeySize, SharedSecretSize: p751.P751_SharedSecretSize, A: DomainParams{ // OZAPTF: Probably not needed Affine_P: p751.P751_affine_PA, Affine_Q: p751.P751_affine_QA, Affine_R: p751.P751_affine_RA, SecretBitLen: p751.P751_SecretBitLenA, MaskBytes: []byte{p751.P751_MaskAliceByte1, p751.P751_MaskAliceByte2, p751.P751_MaskAliceByte3}, IsogenyStrategy: p751.P751_AliceIsogenyStrategy[:], }, B: DomainParams{ Affine_P: p751.P751_affine_PB, Affine_Q: p751.P751_affine_QB, Affine_R: p751.P751_affine_RB, SecretBitLen: p751.P751_SecretBitLenB, MaskBytes: []byte{p751.P751_MaskBobByte}, IsogenyStrategy: p751.P751_BobIsogenyStrategy[:], }, MsgLen: 32, // SIKEp751 provides 192 bit of classical security ([SIKE], 5.1) KemSize: 24, SampleRate: p751.P751_SampleRate, op: p751.NewCtx, } /* p503 := SidhParams{ Id: FP_503, SecretKeySize: P503_SecretKeySize, PublicKeySize: P503_PublicKeySize, SharedSecretSize: P503_SharedSecretSize, A: DomainParams{ Affine_P: P503_affine_PA, Affine_Q: P503_affine_QA, Affine_R: P503_affine_RA, SecretBitLen: P503_SecretBitLenA, MaskBytes: []byte{P503_MaskAliceByte1, P503_MaskAliceByte2, P503_MaskAliceByte3}, IsogenyStrategy: P503_AliceIsogenyStrategy[:], }, B: DomainParams{ Affine_P: P503_affine_PB, Affine_Q: P503_affine_QB, Affine_R: P503_affine_RB, SecretBitLen: P503_SecretBitLenB, MaskBytes: []byte{P751_MaskBobByte}, IsogenyStrategy: P751_BobIsogenyStrategy[:], }, MsgLen: 32, // SIKEp751 provides 192 bit of classical security ([SIKE], 5.1) KemSize: 24, SampleRate: P503_SampleRate, } */ sidhParams[FP_751] = p751 // sidhParams[FP_503] = p503 }