2019-03-29 22:13:53 +00:00
|
|
|
package sike
|
|
|
|
|
|
|
|
const (
|
|
|
|
// Number of uint64 limbs used to store field element
|
|
|
|
FP_WORDS = 8
|
|
|
|
)
|
|
|
|
|
|
|
|
// Used internally by this package
|
|
|
|
// -------------------------------
|
2019-06-28 14:27:44 +01:00
|
|
|
var (
|
|
|
|
p = Fp{
|
|
|
|
0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xABFFFFFFFFFFFFFF,
|
|
|
|
0x13085BDA2211E7A0, 0x1B9BF6C87B7E7DAF, 0x6045C6BDDA77A4D0, 0x004066F541811E1E,
|
|
|
|
}
|
2019-03-29 22:13:53 +00:00
|
|
|
|
2019-06-28 14:27:44 +01:00
|
|
|
// 2*503
|
|
|
|
pX2 = Fp{
|
|
|
|
0xFFFFFFFFFFFFFFFE, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0x57FFFFFFFFFFFFFF,
|
|
|
|
0x2610B7B44423CF41, 0x3737ED90F6FCFB5E, 0xC08B8D7BB4EF49A0, 0x0080CDEA83023C3C,
|
|
|
|
}
|
2019-03-29 22:13:53 +00:00
|
|
|
|
2019-06-28 14:27:44 +01:00
|
|
|
// p503 + 1
|
|
|
|
p1 = Fp{
|
|
|
|
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0xAC00000000000000,
|
|
|
|
0x13085BDA2211E7A0, 0x1B9BF6C87B7E7DAF, 0x6045C6BDDA77A4D0, 0x004066F541811E1E,
|
|
|
|
}
|
2019-03-29 22:13:53 +00:00
|
|
|
|
2019-06-28 14:27:44 +01:00
|
|
|
// R^2=(2^512)^2 mod p
|
|
|
|
pR2 = Fp{
|
|
|
|
0x5289A0CF641D011F, 0x9B88257189FED2B9, 0xA3B365D58DC8F17A, 0x5BC57AB6EFF168EC,
|
|
|
|
0x9E51998BD84D4423, 0xBF8999CBAC3B5695, 0x46E9127BCE14CDB6, 0x003F6CFCE8B81771,
|
|
|
|
}
|
2019-03-29 22:13:53 +00:00
|
|
|
|
2019-06-28 14:27:44 +01:00
|
|
|
// 1/2 * R mod p
|
|
|
|
half = Fp2{
|
|
|
|
A: Fp{
|
|
|
|
0x00000000000001FC, 0x0000000000000000, 0x0000000000000000, 0xB000000000000000,
|
|
|
|
0x3B69BB2464785D2A, 0x36824A2AF0FE9896, 0xF5899F427A94F309, 0x0033B15203C83BB8},
|
|
|
|
}
|
2019-03-29 22:13:53 +00:00
|
|
|
|
2019-06-28 14:27:44 +01:00
|
|
|
// 1*R mod p
|
|
|
|
one = Fp2{
|
|
|
|
A: Fp{
|
|
|
|
0x00000000000003F9, 0x0000000000000000, 0x0000000000000000, 0xB400000000000000,
|
|
|
|
0x63CB1A6EA6DED2B4, 0x51689D8D667EB37D, 0x8ACD77C71AB24142, 0x0026FBAEC60F5953},
|
|
|
|
}
|
2019-06-25 18:21:00 +01:00
|
|
|
|
2019-06-28 14:27:44 +01:00
|
|
|
// 6*R mod p
|
|
|
|
six = Fp2{
|
|
|
|
A: Fp{
|
|
|
|
0x00000000000017D8, 0x0000000000000000, 0x0000000000000000, 0xE000000000000000,
|
|
|
|
0x30B1E6E3A51520FA, 0xB13BC3BF6FFB3992, 0x8045412EEB3E3DED, 0x0069182E2159DBB8},
|
|
|
|
}
|
2019-03-29 22:13:53 +00:00
|
|
|
|
2019-06-28 14:27:44 +01:00
|
|
|
Params SidhParams
|
|
|
|
)
|
2019-03-29 22:13:53 +00:00
|
|
|
|
|
|
|
func init() {
|
|
|
|
Params = SidhParams{
|
|
|
|
// SIDH public key byte size.
|
|
|
|
PublicKeySize: 378,
|
|
|
|
// SIDH shared secret byte size.
|
|
|
|
SharedSecretSize: 126,
|
2019-06-25 18:21:00 +01:00
|
|
|
InitCurve: ProjectiveCurveParameters{
|
|
|
|
A: six,
|
|
|
|
C: one,
|
|
|
|
},
|
2019-03-29 22:13:53 +00:00
|
|
|
A: DomainParams{
|
|
|
|
// The x-coordinate of PA
|
|
|
|
Affine_P: Fp2{
|
|
|
|
A: Fp{
|
2019-06-25 18:21:00 +01:00
|
|
|
0x5D083011589AD893, 0xADFD8D2CB67D0637, 0x330C9AC34FFB6361, 0xF0D47489A2E805A2,
|
|
|
|
0x27E2789259C6B8DC, 0x63866A2C121931B9, 0x8D4C65A7137DCF44, 0x003A183AE5967B3F,
|
2019-03-29 22:13:53 +00:00
|
|
|
},
|
|
|
|
B: Fp{
|
2019-06-25 18:21:00 +01:00
|
|
|
0x7E3541B8C96D1519, 0xD3ADAEEC0D61A26C, 0xC0A2219CE7703DD9, 0xFF3E46658FCDBC52,
|
|
|
|
0xD5B38DEAE6E196FF, 0x1AAC826364956D58, 0xEC9F4875B9A5F27A, 0x001B0B475AB99843,
|
2019-03-29 22:13:53 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
// The x-coordinate of QA
|
|
|
|
Affine_Q: Fp2{
|
|
|
|
A: Fp{
|
2019-06-25 18:21:00 +01:00
|
|
|
0x4D83695107D03BAD, 0x221F3299005E2FCF, 0x78E6AE22F30DECF2, 0x6D982DB5111253E4,
|
|
|
|
0x504C80A8AB4526A8, 0xEFD0C3AA210BB024, 0xCB77483501DC6FCF, 0x001052544A96BDF3,
|
2019-03-29 22:13:53 +00:00
|
|
|
},
|
|
|
|
B: Fp{
|
2019-06-25 18:21:00 +01:00
|
|
|
0x0D74FE3402BCAE47, 0xDF5B8CDA832D8AED, 0xB86BCF06E4BD837E, 0x892A2933A0FA1F63,
|
|
|
|
0x9F88FC67B6CCB461, 0x822926EA9DDA3AC8, 0xEAC8DDE5855425ED, 0x000618FE6DA37A80,
|
2019-03-29 22:13:53 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
// The x-coordinate of RA = PA-QA
|
|
|
|
Affine_R: Fp2{
|
|
|
|
A: Fp{
|
2019-06-29 22:42:05 +01:00
|
|
|
0x1D9D32D2DC877C17, 0x5517CD8F71D5B02B, 0x395AFB8F6B60C117, 0x3AE31AC85F9098C8,
|
|
|
|
0x5F5341C198450848, 0xF8C609DBEA435C6A, 0xD832BC7EDC7BA5E4, 0x002AD98AA6968BF5,
|
2019-03-29 22:13:53 +00:00
|
|
|
},
|
|
|
|
B: Fp{
|
2019-06-29 22:42:05 +01:00
|
|
|
0xC466CAB0F73C2E5B, 0x7B1817148FB2CF9C, 0x873E87C099E470A0, 0xBB17AC6D17A7BAC1,
|
|
|
|
0xA146FDCD0F2E2A58, 0x88B311E9CEAB6201, 0x37604CF5C7951757, 0x0006804071C74BF9,
|
2019-03-29 22:13:53 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
// Max size of secret key for 2-torsion group, corresponds to 2^e2 - 1
|
|
|
|
SecretBitLen: 250,
|
|
|
|
// SecretBitLen in bytes.
|
|
|
|
SecretByteLen: uint((250 + 7) / 8),
|
|
|
|
// 2-torsion group computation strategy
|
|
|
|
IsogenyStrategy: []uint32{
|
|
|
|
0x3D, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x04, 0x02, 0x01,
|
|
|
|
0x01, 0x02, 0x01, 0x01, 0x08, 0x04, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x04, 0x02,
|
|
|
|
0x01, 0x01, 0x02, 0x01, 0x01, 0x10, 0x08, 0x04, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01,
|
|
|
|
0x04, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x08, 0x04, 0x02, 0x01, 0x01, 0x02, 0x01,
|
|
|
|
0x01, 0x04, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x1D, 0x10, 0x08, 0x04, 0x02, 0x01,
|
|
|
|
0x01, 0x02, 0x01, 0x01, 0x04, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x08, 0x04, 0x02,
|
|
|
|
0x01, 0x01, 0x02, 0x01, 0x01, 0x04, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x0D, 0x08,
|
|
|
|
0x04, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x04, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01,
|
|
|
|
0x05, 0x04, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01},
|
|
|
|
},
|
|
|
|
B: DomainParams{
|
|
|
|
// The x-coordinate of PB
|
|
|
|
Affine_P: Fp2{
|
|
|
|
A: Fp{
|
2019-06-25 18:21:00 +01:00
|
|
|
0xDF630FC5FB2468DB, 0xC30C5541C102040E, 0x3CDC9987B76511FC, 0xF54B5A09353D0CDD,
|
|
|
|
0x3ADBA8E00703C42F, 0x8253F9303DDC95D0, 0x62D30778763ABFD7, 0x001CD00FB581CD55,
|
2019-03-29 22:13:53 +00:00
|
|
|
},
|
|
|
|
B: Fp{
|
2019-06-25 18:21:00 +01:00
|
|
|
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
|
|
|
|
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
|
2019-03-29 22:13:53 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
// The x-coordinate of QB
|
|
|
|
Affine_Q: Fp2{
|
|
|
|
A: Fp{
|
2019-06-25 18:21:00 +01:00
|
|
|
0x2E3457A12B429261, 0x311F94E89627DCF8, 0x5B71C98FD1DB73F6, 0x3671DB7DCFC21541,
|
|
|
|
0xB6D1484C9FE0CF4F, 0x19CD110717356E35, 0xF4F9FB00AC9919DF, 0x0035BC124D38A70B,
|
2019-03-29 22:13:53 +00:00
|
|
|
},
|
|
|
|
B: Fp{
|
|
|
|
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
|
|
|
|
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// The x-coordinate of RB = PB - QB
|
|
|
|
Affine_R: Fp2{
|
|
|
|
A: Fp{
|
2019-06-25 18:21:00 +01:00
|
|
|
0x2E08BB99413D2952, 0xD3021467CD088D72, 0x21017AF859752245, 0x26314ED8FFD9DE5C,
|
|
|
|
0x4AF43C73344B6686, 0xCFA1F91149DF0993, 0xF327A95365587A89, 0x000DBF54E03D3906,
|
2019-03-29 22:13:53 +00:00
|
|
|
},
|
|
|
|
B: Fp{
|
2019-06-29 22:42:05 +01:00
|
|
|
0x03E03FF342F5F304, 0x993D604D7B4B6E56, 0x80412F4D9280E71F, 0x0FFDC9EF990B3982,
|
|
|
|
0xE584E64C51604931, 0x1374F42AC8B0BBD7, 0x07D5BC37DFA41A5F, 0x00396CCFD61FD34C,
|
2019-03-29 22:13:53 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
// Size of secret key for 3-torsion group, corresponds to log_2(3^e3) - 1.
|
|
|
|
SecretBitLen: 252,
|
|
|
|
// SecretBitLen in bytes.
|
|
|
|
SecretByteLen: uint((252 + 7) / 8),
|
|
|
|
// 3-torsion group computation strategy
|
|
|
|
IsogenyStrategy: []uint32{
|
|
|
|
0x47, 0x26, 0x15, 0x0D, 0x08, 0x04, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x04, 0x02,
|
|
|
|
0x01, 0x01, 0x02, 0x01, 0x01, 0x05, 0x04, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02,
|
|
|
|
0x01, 0x01, 0x01, 0x09, 0x05, 0x03, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01,
|
|
|
|
0x01, 0x04, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x11, 0x09, 0x05, 0x03, 0x02,
|
|
|
|
0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x04, 0x02, 0x01, 0x01, 0x01, 0x02,
|
|
|
|
0x01, 0x01, 0x08, 0x04, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x04, 0x02, 0x01,
|
|
|
|
0x01, 0x02, 0x01, 0x01, 0x21, 0x11, 0x09, 0x05, 0x03, 0x02, 0x01, 0x01, 0x01, 0x01,
|
|
|
|
0x02, 0x01, 0x01, 0x01, 0x04, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x08, 0x04,
|
|
|
|
0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x04, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01,
|
|
|
|
0x10, 0x08, 0x04, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x04, 0x02, 0x01, 0x01,
|
|
|
|
0x02, 0x01, 0x01, 0x08, 0x04, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x04, 0x02, 0x01,
|
|
|
|
0x01, 0x02, 0x01, 0x01},
|
|
|
|
},
|
2019-06-25 18:21:00 +01:00
|
|
|
OneFp2: one,
|
|
|
|
HalfFp2: half,
|
2019-03-29 22:13:53 +00:00
|
|
|
MsgLen: 24,
|
|
|
|
// SIKEp503 provides 128 bit of classical security ([SIKE], 5.1)
|
2019-06-25 18:21:00 +01:00
|
|
|
KemSize: 24,
|
2019-03-29 22:13:53 +00:00
|
|
|
// ceil(503+7/8)
|
2019-05-06 11:42:26 +01:00
|
|
|
Bytelen: 63,
|
2019-06-25 18:21:00 +01:00
|
|
|
CiphertextSize: 24 + 378,
|
2019-03-29 22:13:53 +00:00
|
|
|
}
|
|
|
|
}
|