mirror of
https://github.com/saymrwulf/betrusted-curve25519-dalek-source.git
synced 2026-09-06 20:41:11 +00:00
add some more rigorous test cases
catch the case that the 14th limb overflows into the 15th at the final carry propagate step
This commit is contained in:
parent
6e6ac6ade4
commit
f61a91c6b6
1 changed files with 46 additions and 3 deletions
49
src/field.rs
49
src/field.rs
|
|
@ -606,7 +606,7 @@ mod test {
|
|||
// test multiplier. two input registers: (r0, r1), one output register (r31).
|
||||
let num_src_regs = 2;
|
||||
let reg_window = 0;
|
||||
let num_tests = 15;
|
||||
let num_tests = 21;
|
||||
let loading_address = 0; // microcode loading address
|
||||
|
||||
let mcode = assemble_engine25519!(
|
||||
|
|
@ -788,8 +788,51 @@ mod test {
|
|||
write_helper(&mut file, b);
|
||||
write_helper(&mut file, q);
|
||||
|
||||
// 12-15
|
||||
for _ in 0..4 {
|
||||
// 12
|
||||
let a = FieldElement::from_bytes(&[
|
||||
0x94, 0xc2, 0xf9, 0x3b, 0xb7, 0xe7, 0xe5, 0x78,
|
||||
0x22, 0x23, 0x00, 0x14, 0x55, 0x41, 0x56, 0x05,
|
||||
0xb0, 0xfe, 0x1d, 0x61, 0x0d, 0x0b, 0x08, 0xc9,
|
||||
0x22, 0x3a, 0xc4, 0x55, 0xcd, 0xb0, 0x93, 0x52,
|
||||
]);
|
||||
let b = FieldElement::from_bytes(&[
|
||||
0x17, 0x0c, 0x1e, 0x93, 0xea, 0x6e, 0x51, 0xc0,
|
||||
0xcb, 0xf9, 0x48, 0xe7, 0x60, 0x36, 0x1f, 0xaf,
|
||||
0x65, 0x8d, 0xf2, 0xe9, 0x36, 0xd2, 0x71, 0x00,
|
||||
0x94, 0x56, 0x48, 0x55, 0x1c, 0xe9, 0x48, 0x1d,
|
||||
]);
|
||||
let q = &a * &b;
|
||||
// 08 55 8c eb 97 70 ea b5 da c7 eb 83 d1 3a b3 a7
|
||||
// 99 31 f4 be 87 3c 26 e9 1c d0 9c 82 08 da 5c 0d
|
||||
write_helper(&mut file, a);
|
||||
write_helper(&mut file, b);
|
||||
write_helper(&mut file, q);
|
||||
|
||||
// 13
|
||||
let a = FieldElement::from_bytes(&[
|
||||
0x6d, 0xad, 0x72, 0xf8, 0x64, 0x1b, 0x8f, 0x43,
|
||||
0xba, 0x50, 0xb5, 0x83, 0xe1, 0x5f, 0xd6, 0x43,
|
||||
0x9b, 0xb2, 0xbc, 0x60, 0xae, 0x92, 0x3a, 0xdb,
|
||||
0x05, 0x83, 0x4a, 0xd6, 0x19, 0x36, 0x95, 0x87,
|
||||
]);
|
||||
let b = FieldElement::from_bytes(&[
|
||||
0xe4, 0x34, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
]);
|
||||
let q = &a * &b;
|
||||
// 000002a6 bc74dd8d 2e43fe6f 23132ca5 d3e70179 c129465a 7c4d49cc ccf864a7
|
||||
write_helper(&mut file, a);
|
||||
write_helper(&mut file, b);
|
||||
write_helper(&mut file, q);
|
||||
// 0xa7, 0x64, 0xf8, 0xcc, 0xcc, 0x49, 0x4d, 0x7c,
|
||||
// 0x5a, 0x46, 0x29, 0xc1, 0x79, 0x01, 0xe7, 0xd3,
|
||||
// 0xa5, 0x2c, 0x13, 0x23, 0x6f, 0xfe, 0x43, 0x2e,
|
||||
// 0x8d, 0xdd, 0x74, 0xbc, 0xa6, 0x02, 0x00, 0x00,
|
||||
|
||||
// 14-21
|
||||
for _ in 0..8 {
|
||||
let a = FieldElement::from_bytes(&rand::thread_rng().gen::<[u8; 32]>());
|
||||
let b = FieldElement::from_bytes(&rand::thread_rng().gen::<[u8; 32]>());
|
||||
let q = &a * &b;
|
||||
|
|
|
|||
Loading…
Reference in a new issue