Use Rust's TryInto for [u8; 32]
Co-authored-by: Conrado Gouvea <conradoplg@gmail.com>
This commit is contained in:
parent
edffbdd596
commit
282c3b16ac
|
@ -149,15 +149,7 @@ pub(crate) fn test_non_adjacent_form_for_scalar<Scalar: NonAdjacentForm>(w: usiz
|
|||
.expect("The reconstructed scalar is negative.")
|
||||
.to_bytes_le();
|
||||
|
||||
// Check that the reconstructed scalar is not too big.
|
||||
assert!(reconstructed_scalar.len() <= 32);
|
||||
|
||||
// Convert the reconstructed scalar to a fixed byte array so we can compare it with the orginal
|
||||
// scalar.
|
||||
let mut reconstructed_scalar_bytes: [u8; 32] = [0; 32];
|
||||
for (i, byte) in reconstructed_scalar.iter().enumerate() {
|
||||
reconstructed_scalar_bytes[i] = *byte;
|
||||
}
|
||||
let reconstructed_scalar_bytes: [u8; 32] = reconstructed_scalar.try_into().unwrap();
|
||||
|
||||
// Check that the reconstructed scalar matches the original one.
|
||||
assert_eq!(reconstructed_scalar_bytes, scalar.inner_to_bytes());
|
||||
|
|
Loading…
Reference in New Issue