From a169d8a1c5017ca073b8c9b863620bfdbd7f52f5 Mon Sep 17 00:00:00 2001 From: daxpedda Date: Sun, 1 Aug 2021 01:40:59 +0200 Subject: [PATCH] Fix small numbers (#221) --- src/map_to_curve.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/map_to_curve.rs b/src/map_to_curve.rs index 630329a..baa9ff1 100644 --- a/src/map_to_curve.rs +++ b/src/map_to_curve.rs @@ -77,11 +77,14 @@ impl GroupWithMapToCurve for p256_::ProjectivePoint { let uniform_bytes = expand_message_xmd::(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, ))) } }