Fix small numbers (#221)

This commit is contained in:
daxpedda
2021-07-31 16:40:59 -07:00
committed by GitHub
parent e491c1b533
commit a169d8a1c5
+6 -3
View File
@@ -77,11 +77,14 @@ impl GroupWithMapToCurve for p256_::ProjectivePoint {
let uniform_bytes = expand_message_xmd::<H>(input, dst, crate::group::p256::L)?;
#[allow(clippy::borrow_interior_mutable_const)]
let bytes =
BigInt::from_bytes_be(Sign::Plus, &uniform_bytes).mod_floor(&crate::group::p256::R);
let mut bytes = BigInt::from_bytes_be(Sign::Plus, &uniform_bytes)
.mod_floor(&crate::group::p256::R)
.to_bytes_be()
.1;
bytes.resize(32, 0);
Ok(p256_::Scalar::from_bytes_reduced(GenericArray::from_slice(
&bytes.to_bytes_be().1,
&bytes,
)))
}
}