Skip to content

Commit

Permalink
Added an assertion to check for correct parameters in PrmProof::new
Browse files Browse the repository at this point in the history
  • Loading branch information
fjarri committed Dec 1, 2024
1 parent 132bc3d commit f6cd680
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion synedrion/src/cggmp21/sigma/prm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl<P: SchemeParams> PrmProof<P> {
setup: &RPParams<P::Paillier>,
aux: &impl Hashable,
) -> Self {
// TODO: check that secret.public_modulus == setup.public_modulus?
debug_assert!(&secret.modulus() == setup.modulus());
let proof_secret = PrmSecret::<P>::random(rng, secret);
let commitment = PrmCommitment::new(&proof_secret, setup.base());

Expand Down
8 changes: 8 additions & 0 deletions synedrion/src/paillier/ring_pedersen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ impl<P: PaillierParams> RPSecret<P> {
pub fn totient_nonzero(&self) -> SecretBox<NonZero<P::Uint>> {
self.primes.totient_nonzero()
}

pub fn modulus(&self) -> P::Uint {
*self.primes.modulus_wire().modulus()
}
}

/// The expanded representation of ring-Pedersen parameters.
Expand Down Expand Up @@ -88,6 +92,10 @@ impl<P: PaillierParams> RPParams<P> {
&self.power
}

pub fn modulus(&self) -> &P::Uint {
self.modulus.modulus()
}

pub fn modulus_bounded(&self) -> Bounded<P::Uint> {
self.modulus.modulus_bounded()
}
Expand Down
4 changes: 4 additions & 0 deletions synedrion/src/paillier/rsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ impl<P: PaillierParams> PublicModulusWire<P> {
Self(primes.p.expose_secret().mul_wide(primes.q.expose_secret()))
}

pub fn modulus(&self) -> &P::Uint {
&self.0
}

pub fn into_precomputed(self) -> PublicModulus<P> {
PublicModulus::new(self)
}
Expand Down

0 comments on commit f6cd680

Please sign in to comment.