Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arrabbiata/curve: implement squeeze_challenge #3026

Open
wants to merge 1 commit into
base: dw/bugging-me-this-plurial
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
}
}
Loading