diff --git a/src/group.rs b/src/group.rs index 6b3c9ec..00203b9 100644 --- a/src/group.rs +++ b/src/group.rs @@ -58,7 +58,7 @@ pub trait Group: Copy + Sized + for<'a> Mul<&'a ::Scalar, Output type UniformBytesLen: ArrayLength; /// Hashes a slice of pseudo-random bytes of the correct length to a curve point - fn hash_to_curve(uniform_bytes: &GenericArray) -> Self; + fn hash_to_curve(uniform_bytes: &GenericArray) -> Result; /// Get the base point for the group fn base_point() -> Self; @@ -128,14 +128,14 @@ impl Group for RistrettoPoint { } type UniformBytesLen = U64; - fn hash_to_curve(uniform_bytes: &GenericArray) -> Self { + fn hash_to_curve(uniform_bytes: &GenericArray) -> Result { // https://caniuse.rs/features/array_gt_32_impls let bits: [u8; 64] = { let mut bytes = [0u8; 64]; bytes.copy_from_slice(uniform_bytes); bytes }; - RistrettoPoint::from_uniform_bytes(&bits) + Ok(RistrettoPoint::from_uniform_bytes(&bits)) } fn base_point() -> Self { diff --git a/src/map_to_curve.rs b/src/map_to_curve.rs index 8854844..04e0bdf 100644 --- a/src/map_to_curve.rs +++ b/src/map_to_curve.rs @@ -43,9 +43,9 @@ impl GroupWithMapToCurve for RistrettoPoint { fn map_to_curve(msg: &[u8], dst: &[u8]) -> Result { let uniform_bytes = expand_message_xmd::(msg, dst, ::OutputSize::to_usize())?; - Ok(::hash_to_curve( + ::hash_to_curve( &GenericArray::clone_from_slice(&uniform_bytes[..]), - )) + ) } fn hash_to_scalar(