2018-07-23 23:18:38 +01:00
|
|
|
package sidh
|
|
|
|
|
2018-09-11 12:02:29 +01:00
|
|
|
import (
|
|
|
|
. "github.com/henrydcase/nobs/dh/sidh/internal/isogeny"
|
|
|
|
p503 "github.com/henrydcase/nobs/dh/sidh/p503"
|
|
|
|
p751 "github.com/henrydcase/nobs/dh/sidh/p751"
|
|
|
|
)
|
2018-07-23 23:18:38 +01:00
|
|
|
|
|
|
|
// Keeps mapping: SIDH prime field ID to domain parameters
|
2018-09-11 12:02:29 +01:00
|
|
|
var sidhParams = make(map[uint8]SidhParams)
|
2018-07-23 23:18:38 +01:00
|
|
|
|
|
|
|
// 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.
|
2018-09-11 12:02:29 +01:00
|
|
|
func Params(id uint8) *SidhParams {
|
2018-07-23 23:18:38 +01:00
|
|
|
if val, ok := sidhParams[id]; ok {
|
|
|
|
return &val
|
|
|
|
}
|
|
|
|
panic("sidh: SIDH Params ID unregistered")
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2018-09-11 12:02:29 +01:00
|
|
|
p503 := SidhParams{
|
|
|
|
Id: FP_503,
|
|
|
|
PublicKeySize: p503.P503_PublicKeySize,
|
|
|
|
SharedSecretSize: p503.P503_SharedSecretSize,
|
|
|
|
A: DomainParams{
|
|
|
|
Affine_P: p503.P503_affine_PA,
|
|
|
|
Affine_Q: p503.P503_affine_QA,
|
|
|
|
Affine_R: p503.P503_affine_RA,
|
|
|
|
SecretBitLen: p503.P503_SecretBitLenA,
|
|
|
|
SecretByteLen: uint((p503.P503_SecretBitLenA + 7) / 8),
|
2018-12-03 23:07:01 +00:00
|
|
|
IsogenyStrategy: p503.P503_AliceIsogenyStrategy[:],
|
2018-09-11 12:02:29 +01:00
|
|
|
},
|
|
|
|
B: DomainParams{
|
|
|
|
Affine_P: p503.P503_affine_PB,
|
|
|
|
Affine_Q: p503.P503_affine_QB,
|
|
|
|
Affine_R: p503.P503_affine_RB,
|
|
|
|
SecretBitLen: p503.P503_SecretBitLenB,
|
|
|
|
SecretByteLen: uint((p503.P503_SecretBitLenB + 7) / 8),
|
2018-12-03 23:07:01 +00:00
|
|
|
IsogenyStrategy: p503.P503_BobIsogenyStrategy[:],
|
2018-09-11 12:02:29 +01:00
|
|
|
},
|
2018-12-03 23:07:01 +00:00
|
|
|
OneFp2: p503.P503OneFp2,
|
|
|
|
HalfFp2: p503.P503HalfFp2,
|
2018-09-11 12:02:29 +01:00
|
|
|
MsgLen: 24,
|
2019-02-19 14:44:11 +00:00
|
|
|
// SIKEp503 provides 128 bit of classical security ([SIKE], 5.1)
|
2018-12-03 23:07:01 +00:00
|
|
|
KemSize: 16,
|
|
|
|
Bytelen: p503.P503_Bytelen,
|
|
|
|
Op: p503.FieldOperations(),
|
2018-09-11 12:02:29 +01:00
|
|
|
}
|
|
|
|
|
2018-07-23 23:18:38 +01:00
|
|
|
p751 := SidhParams{
|
|
|
|
Id: FP_751,
|
2018-09-11 12:02:29 +01:00
|
|
|
PublicKeySize: p751.P751_PublicKeySize,
|
|
|
|
SharedSecretSize: p751.P751_SharedSecretSize,
|
2018-07-23 23:18:38 +01:00
|
|
|
A: DomainParams{
|
2018-09-11 12:02:29 +01:00
|
|
|
Affine_P: p751.P751_affine_PA,
|
|
|
|
Affine_Q: p751.P751_affine_QA,
|
|
|
|
Affine_R: p751.P751_affine_RA,
|
|
|
|
IsogenyStrategy: p751.P751_AliceIsogenyStrategy[:],
|
|
|
|
SecretBitLen: p751.P751_SecretBitLenA,
|
|
|
|
SecretByteLen: uint((p751.P751_SecretBitLenA + 7) / 8),
|
2018-07-23 23:18:38 +01:00
|
|
|
},
|
|
|
|
B: DomainParams{
|
2018-09-11 12:02:29 +01:00
|
|
|
Affine_P: p751.P751_affine_PB,
|
|
|
|
Affine_Q: p751.P751_affine_QB,
|
|
|
|
Affine_R: p751.P751_affine_RB,
|
|
|
|
IsogenyStrategy: p751.P751_BobIsogenyStrategy[:],
|
|
|
|
SecretBitLen: p751.P751_SecretBitLenB,
|
|
|
|
SecretByteLen: uint((p751.P751_SecretBitLenB + 7) / 8),
|
2018-07-23 23:18:38 +01:00
|
|
|
},
|
2018-12-03 23:07:01 +00:00
|
|
|
OneFp2: p751.P751OneFp2,
|
|
|
|
HalfFp2: p751.P751HalfFp2,
|
2018-09-11 12:02:29 +01:00
|
|
|
MsgLen: 32,
|
2018-07-23 23:18:38 +01:00
|
|
|
// SIKEp751 provides 192 bit of classical security ([SIKE], 5.1)
|
2018-12-03 23:07:01 +00:00
|
|
|
KemSize: 24,
|
|
|
|
Bytelen: p751.P751_Bytelen,
|
|
|
|
Op: p751.FieldOperations(),
|
2018-07-23 23:18:38 +01:00
|
|
|
}
|
|
|
|
|
2018-09-11 12:02:29 +01:00
|
|
|
sidhParams[FP_503] = p503
|
2018-07-23 23:18:38 +01:00
|
|
|
sidhParams[FP_751] = p751
|
|
|
|
}
|