Skip to content

Commit

Permalink
Arrabbiata/curve: implement squeeze_challenge
Browse files Browse the repository at this point in the history
Alias for sponge.challenge()
  • Loading branch information
dannywillems committed Feb 12, 2025
1 parent ad6a4cb commit 6d3ae53
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions arrabbiata/src/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ where
sponge: &mut DefaultFqSponge<Self::Params, Self::SpongeConstants>,
comms: &[Self],
);

/// Coin a challenge from the sponge.
/// Note that a challenge set might not be covering the whole set the scalar
/// field is defined on.
///
/// In particular, for the Pasta curves, a 128-bits value is expected as an
/// output.
///
/// This method is supposed to be an alias to `sponge.challenge()`.
/// However, it seems that the compiler requests some additional type
/// constraints if there is generic code over the trait `ArrabbiataCurve`.
fn squeeze_challenge(
sponge: &mut DefaultFqSponge<Self::Params, Self::SpongeConstants>,
) -> Self::ScalarField;
}

impl ArrabbiataCurve for Affine<PallasParameters> {
Expand Down Expand Up @@ -136,6 +150,13 @@ impl ArrabbiataCurve for Affine<PallasParameters> {
) {
sponge.absorb_g(comms)
}

fn squeeze_challenge(
sponge: &mut DefaultFqSponge<Self::Params, Self::SpongeConstants>,
) -> Self::ScalarField {
// This gives a 128 bits value.
sponge.challenge()
}
}

impl ArrabbiataCurve for Affine<VestaParameters> {
Expand Down Expand Up @@ -184,4 +205,11 @@ impl ArrabbiataCurve for Affine<VestaParameters> {
) {
sponge.absorb_g(comms)
}

fn squeeze_challenge(
sponge: &mut DefaultFqSponge<Self::Params, Self::SpongeConstants>,
) -> Self::ScalarField {
// This gives a 128 bits value.
sponge.challenge()
}
}

0 comments on commit 6d3ae53

Please sign in to comment.