From 6d3ae5380d8043c8715058d111142db7eb918278 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Tue, 4 Feb 2025 14:20:43 +0100 Subject: [PATCH] Arrabbiata/curve: implement squeeze_challenge Alias for sponge.challenge() --- arrabbiata/src/curve.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/arrabbiata/src/curve.rs b/arrabbiata/src/curve.rs index 7f0d265c0c..f8a44aefe0 100644 --- a/arrabbiata/src/curve.rs +++ b/arrabbiata/src/curve.rs @@ -88,6 +88,20 @@ where sponge: &mut DefaultFqSponge, 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::ScalarField; } impl ArrabbiataCurve for Affine { @@ -136,6 +150,13 @@ impl ArrabbiataCurve for Affine { ) { sponge.absorb_g(comms) } + + fn squeeze_challenge( + sponge: &mut DefaultFqSponge, + ) -> Self::ScalarField { + // This gives a 128 bits value. + sponge.challenge() + } } impl ArrabbiataCurve for Affine { @@ -184,4 +205,11 @@ impl ArrabbiataCurve for Affine { ) { sponge.absorb_g(comms) } + + fn squeeze_challenge( + sponge: &mut DefaultFqSponge, + ) -> Self::ScalarField { + // This gives a 128 bits value. + sponge.challenge() + } }