cargo fmt
This commit is contained in:
parent
812ab51091
commit
43e451f103
64
src/fq.rs
64
src/fq.rs
|
@ -646,7 +646,8 @@ fn test_from_bytes_vartime() {
|
|||
Fq::from_bytes_vartime([
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0
|
||||
]).unwrap(),
|
||||
])
|
||||
.unwrap(),
|
||||
Fq::zero()
|
||||
);
|
||||
|
||||
|
@ -654,7 +655,8 @@ fn test_from_bytes_vartime() {
|
|||
Fq::from_bytes_vartime([
|
||||
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0
|
||||
]).unwrap(),
|
||||
])
|
||||
.unwrap(),
|
||||
Fq::one()
|
||||
);
|
||||
|
||||
|
@ -662,45 +664,41 @@ fn test_from_bytes_vartime() {
|
|||
Fq::from_bytes_vartime([
|
||||
254, 255, 255, 255, 1, 0, 0, 0, 2, 72, 3, 0, 250, 183, 132, 88, 245, 79, 188, 236, 239,
|
||||
79, 140, 153, 111, 5, 197, 172, 89, 177, 36, 24
|
||||
]).unwrap(),
|
||||
])
|
||||
.unwrap(),
|
||||
R2
|
||||
);
|
||||
|
||||
// -1 should work
|
||||
assert!(
|
||||
Fq::from_bytes_vartime([
|
||||
0, 0, 0, 0, 255, 255, 255, 255, 254, 91, 254, 255, 2, 164, 189, 83, 5, 216, 161, 9, 8,
|
||||
216, 57, 51, 72, 125, 157, 41, 83, 167, 237, 115
|
||||
]).is_some()
|
||||
);
|
||||
assert!(Fq::from_bytes_vartime([
|
||||
0, 0, 0, 0, 255, 255, 255, 255, 254, 91, 254, 255, 2, 164, 189, 83, 5, 216, 161, 9, 8, 216,
|
||||
57, 51, 72, 125, 157, 41, 83, 167, 237, 115
|
||||
])
|
||||
.is_some());
|
||||
|
||||
// modulus is invalid
|
||||
assert!(
|
||||
Fq::from_bytes_vartime([
|
||||
1, 0, 0, 0, 255, 255, 255, 255, 254, 91, 254, 255, 2, 164, 189, 83, 5, 216, 161, 9, 8,
|
||||
216, 57, 51, 72, 125, 157, 41, 83, 167, 237, 115
|
||||
]).is_none()
|
||||
);
|
||||
assert!(Fq::from_bytes_vartime([
|
||||
1, 0, 0, 0, 255, 255, 255, 255, 254, 91, 254, 255, 2, 164, 189, 83, 5, 216, 161, 9, 8, 216,
|
||||
57, 51, 72, 125, 157, 41, 83, 167, 237, 115
|
||||
])
|
||||
.is_none());
|
||||
|
||||
// Anything larger than the modulus is invalid
|
||||
assert!(
|
||||
Fq::from_bytes_vartime([
|
||||
2, 0, 0, 0, 255, 255, 255, 255, 254, 91, 254, 255, 2, 164, 189, 83, 5, 216, 161, 9, 8,
|
||||
216, 57, 51, 72, 125, 157, 41, 83, 167, 237, 115
|
||||
]).is_none()
|
||||
);
|
||||
assert!(
|
||||
Fq::from_bytes_vartime([
|
||||
1, 0, 0, 0, 255, 255, 255, 255, 254, 91, 254, 255, 2, 164, 189, 83, 5, 216, 161, 9, 8,
|
||||
216, 58, 51, 72, 125, 157, 41, 83, 167, 237, 115
|
||||
]).is_none()
|
||||
);
|
||||
assert!(
|
||||
Fq::from_bytes_vartime([
|
||||
1, 0, 0, 0, 255, 255, 255, 255, 254, 91, 254, 255, 2, 164, 189, 83, 5, 216, 161, 9, 8,
|
||||
216, 57, 51, 72, 125, 157, 41, 83, 167, 237, 116
|
||||
]).is_none()
|
||||
);
|
||||
assert!(Fq::from_bytes_vartime([
|
||||
2, 0, 0, 0, 255, 255, 255, 255, 254, 91, 254, 255, 2, 164, 189, 83, 5, 216, 161, 9, 8, 216,
|
||||
57, 51, 72, 125, 157, 41, 83, 167, 237, 115
|
||||
])
|
||||
.is_none());
|
||||
assert!(Fq::from_bytes_vartime([
|
||||
1, 0, 0, 0, 255, 255, 255, 255, 254, 91, 254, 255, 2, 164, 189, 83, 5, 216, 161, 9, 8, 216,
|
||||
58, 51, 72, 125, 157, 41, 83, 167, 237, 115
|
||||
])
|
||||
.is_none());
|
||||
assert!(Fq::from_bytes_vartime([
|
||||
1, 0, 0, 0, 255, 255, 255, 255, 254, 91, 254, 255, 2, 164, 189, 83, 5, 216, 161, 9, 8, 216,
|
||||
57, 51, 72, 125, 157, 41, 83, 167, 237, 116
|
||||
])
|
||||
.is_none());
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
64
src/fr.rs
64
src/fr.rs
|
@ -589,7 +589,8 @@ fn test_from_bytes_vartime() {
|
|||
Fr::from_bytes_vartime([
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0
|
||||
]).unwrap(),
|
||||
])
|
||||
.unwrap(),
|
||||
Fr::zero()
|
||||
);
|
||||
|
||||
|
@ -597,7 +598,8 @@ fn test_from_bytes_vartime() {
|
|||
Fr::from_bytes_vartime([
|
||||
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0
|
||||
]).unwrap(),
|
||||
])
|
||||
.unwrap(),
|
||||
Fr::one()
|
||||
);
|
||||
|
||||
|
@ -605,47 +607,43 @@ fn test_from_bytes_vartime() {
|
|||
Fr::from_bytes_vartime([
|
||||
217, 7, 150, 185, 179, 11, 248, 37, 80, 231, 182, 102, 47, 214, 21, 243, 244, 20, 136,
|
||||
235, 238, 20, 37, 147, 198, 85, 145, 71, 111, 252, 166, 9
|
||||
]).unwrap(),
|
||||
])
|
||||
.unwrap(),
|
||||
R2
|
||||
);
|
||||
|
||||
// -1 should work
|
||||
assert!(
|
||||
Fr::from_bytes_vartime([
|
||||
182, 44, 247, 214, 94, 14, 151, 208, 130, 16, 200, 204, 147, 32, 104, 166, 0, 59, 52,
|
||||
1, 1, 59, 103, 6, 169, 175, 51, 101, 234, 180, 125, 14
|
||||
]).is_some()
|
||||
);
|
||||
assert!(Fr::from_bytes_vartime([
|
||||
182, 44, 247, 214, 94, 14, 151, 208, 130, 16, 200, 204, 147, 32, 104, 166, 0, 59, 52, 1, 1,
|
||||
59, 103, 6, 169, 175, 51, 101, 234, 180, 125, 14
|
||||
])
|
||||
.is_some());
|
||||
|
||||
// modulus is invalid
|
||||
assert!(
|
||||
Fr::from_bytes_vartime([
|
||||
183, 44, 247, 214, 94, 14, 151, 208, 130, 16, 200, 204, 147, 32, 104, 166, 0, 59, 52,
|
||||
1, 1, 59, 103, 6, 169, 175, 51, 101, 234, 180, 125, 14
|
||||
]).is_none()
|
||||
);
|
||||
assert!(Fr::from_bytes_vartime([
|
||||
183, 44, 247, 214, 94, 14, 151, 208, 130, 16, 200, 204, 147, 32, 104, 166, 0, 59, 52, 1, 1,
|
||||
59, 103, 6, 169, 175, 51, 101, 234, 180, 125, 14
|
||||
])
|
||||
.is_none());
|
||||
|
||||
// Anything larger than the modulus is invalid
|
||||
assert!(
|
||||
Fr::from_bytes_vartime([
|
||||
184, 44, 247, 214, 94, 14, 151, 208, 130, 16, 200, 204, 147, 32, 104, 166, 0, 59, 52,
|
||||
1, 1, 59, 103, 6, 169, 175, 51, 101, 234, 180, 125, 14
|
||||
]).is_none()
|
||||
);
|
||||
assert!(Fr::from_bytes_vartime([
|
||||
184, 44, 247, 214, 94, 14, 151, 208, 130, 16, 200, 204, 147, 32, 104, 166, 0, 59, 52, 1, 1,
|
||||
59, 103, 6, 169, 175, 51, 101, 234, 180, 125, 14
|
||||
])
|
||||
.is_none());
|
||||
|
||||
assert!(
|
||||
Fr::from_bytes_vartime([
|
||||
183, 44, 247, 214, 94, 14, 151, 208, 130, 16, 200, 204, 147, 32, 104, 166, 0, 59, 52,
|
||||
1, 1, 59, 104, 6, 169, 175, 51, 101, 234, 180, 125, 14
|
||||
]).is_none()
|
||||
);
|
||||
assert!(Fr::from_bytes_vartime([
|
||||
183, 44, 247, 214, 94, 14, 151, 208, 130, 16, 200, 204, 147, 32, 104, 166, 0, 59, 52, 1, 1,
|
||||
59, 104, 6, 169, 175, 51, 101, 234, 180, 125, 14
|
||||
])
|
||||
.is_none());
|
||||
|
||||
assert!(
|
||||
Fr::from_bytes_vartime([
|
||||
183, 44, 247, 214, 94, 14, 151, 208, 130, 16, 200, 204, 147, 32, 104, 166, 0, 59, 52,
|
||||
1, 1, 59, 103, 6, 169, 175, 51, 101, 234, 180, 125, 15
|
||||
]).is_none()
|
||||
);
|
||||
assert!(Fr::from_bytes_vartime([
|
||||
183, 44, 247, 214, 94, 14, 151, 208, 130, 16, 200, 204, 147, 32, 104, 166, 0, 59, 52, 1, 1,
|
||||
59, 103, 6, 169, 175, 51, 101, 234, 180, 125, 15
|
||||
])
|
||||
.is_none());
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Reference in New Issue