remove unnecessary loop in hash_to_scalar

This commit is contained in:
creating2morrow 2024-04-07 17:36:42 -04:00
parent 71b752e1e8
commit 0cf15df6d5

View file

@ -57,14 +57,7 @@ fn hash_to_scalar(s: Vec<&str>) -> Scalar {
hasher.update(&result); hasher.update(&result);
let hash = hasher.finalize().to_owned(); let hash = hasher.finalize().to_owned();
let mut hash_container: [u8; 32] = [0u8; 32]; let mut hash_container: [u8; 32] = [0u8; 32];
let mut index = 0; hex::decode_to_slice(result, &mut hash_container as &mut [u8]).unwrap_or_default();
for byte in result.as_bytes() {
if index == hash_container.len() - 1 {
break;
}
hash_container[index] = *byte;
index += 1;
}
let hash_value = BigInt::from_bytes_le(Sign::Plus, &hash_container); let hash_value = BigInt::from_bytes_le(Sign::Plus, &hash_container);
if hash_value < curve_l_as_big_int() { if hash_value < curve_l_as_big_int() {
return Scalar::from_bytes_mod_order(hash_container); return Scalar::from_bytes_mod_order(hash_container);