diff --git a/poseidon/src/sponge.rs b/poseidon/src/sponge.rs index be9ba0a319..5c1611c638 100644 --- a/poseidon/src/sponge.rs +++ b/poseidon/src/sponge.rs @@ -17,6 +17,7 @@ pub trait FqSponge { fn absorb_fq(&mut self, x: &[Fq]); /// Absorbs a base field point, that is a pair of `Fq` elements. + /// In the case of the point to infinity, the values `(0, 0)` are absorbed. fn absorb_g(&mut self, g: &[G]); /// Absorbs an element of the scalar field `Fr` --- it is done diff --git a/poseidon/tests/poseidon_tests.rs b/poseidon/tests/poseidon_tests.rs index 37cafe940f..85397db5d8 100644 --- a/poseidon/tests/poseidon_tests.rs +++ b/poseidon/tests/poseidon_tests.rs @@ -1,5 +1,6 @@ +use ark_ec::AffineRepr; use ark_ff::{Field, UniformRand}; -use mina_curves::pasta::{Fp, Fq, PallasParameters, VestaParameters}; +use mina_curves::pasta::{Fp, Fq, Pallas, PallasParameters, Vesta, VestaParameters}; use mina_poseidon::{ constants::{PlonkSpongeConstantsKimchi, PlonkSpongeConstantsLegacy}, pasta::{fp_kimchi, fp_legacy, fq_kimchi}, @@ -136,3 +137,25 @@ fn test_poseidon_pallas_kimchi_challenge_is_squeezed_to_128_bits() { let two_128 = Fq::from(2).pow([128]); assert!(challenge < two_128); } + +#[test] +fn test_poseidon_pallas_absorb_point_to_infinity() { + let mut sponge = DefaultFqSponge::::new( + fp_kimchi::static_params(), + ); + let point = Pallas::zero(); + sponge.absorb_g(&[point]); + let exp_output = [Fp::from(0); 3]; + assert_eq!(sponge.sponge.state, exp_output); +} + +#[test] +fn test_poseidon_vesta_absorb_point_to_infinity() { + let mut sponge = DefaultFqSponge::::new( + fq_kimchi::static_params(), + ); + let point = Vesta::zero(); + sponge.absorb_g(&[point]); + let exp_output = [Fq::from(0); 3]; + assert_eq!(sponge.sponge.state, exp_output); +}