Skip to content

Commit

Permalink
Minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
moCello committed Dec 11, 2023
1 parent e23eef1 commit 3dbd60a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/dusk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ impl JubJubExtended {
/// a member of the prime-order subgroup, we return it. If not, we increment
/// the counter and try to de-serialize again.
///
/// **Note:** This implementation of `hash_to_point` is not ideal, in the
/// long run we want to implement an algorithm outlined
/// **Note:** This implementation of `hash_to_point` is not constant time,
/// in the long run we want to implement an algorithm outlined
/// [here](https://datatracker.ietf.org/doc/html/rfc9380), but we start with
/// this implementation in order to be able to use the API already.
pub fn hash_to_point(input: &[u8]) -> Self {
Expand All @@ -237,13 +237,15 @@ impl JubJubExtended {
.update(input)
.update(&counter.to_le_bytes())
.finalize();
let bytes = state.as_bytes();

array.copy_from_slice(&bytes[..32]);
array.copy_from_slice(&state.as_bytes()[..32]);

// check if we hit a point on the curve
if let Ok(point) =
<JubJubAffine as Serializable<32>>::from_bytes(&array)
{
// check if this point is part of the correct subgroup and not
// the identity
if point.is_prime_order().into() {
return point.into();
}
Expand Down

0 comments on commit 3dbd60a

Please sign in to comment.