Skip to content

Commit 85fca2c

Browse files
manel1874jfdreis
andcommitted
feat: update no small factor zkp to cggmp24 version
Co-authored-by: jfdreis <josevtnreis@gmail.com> Signed-off-by: manel1874 <manel1874@gmail.com>
1 parent a3d33e6 commit 85fca2c

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

paillier-zk/src/no_small_factor.rs

+6-17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! ZK-proof for factoring of a RSA modulus. Called Пfac or Rfac in the CGGMP21
1+
//! ZK-proof for factoring of a RSA modulus. Called Пfac or Rfac in the CGGMP24
22
//! paper.
33
//!
44
//! ## Description
@@ -145,8 +145,6 @@ pub struct Commitment {
145145
pub b: Integer,
146146
#[udigest(as = crate::common::encoding::Integer)]
147147
pub t: Integer,
148-
#[udigest(as = crate::common::encoding::Integer)]
149-
pub sigma: Integer,
150148
}
151149

152150
/// Verifier's challenge to prover. Can be obtained deterministically by
@@ -198,7 +196,6 @@ pub mod interactive {
198196
let beta = Integer::from_rng_pm(&n_root_modulo, &mut rng);
199197
let mu = Integer::from_rng_pm(&l_n_circ_modulo, &mut rng);
200198
let nu = Integer::from_rng_pm(&l_n_circ_modulo, &mut rng);
201-
let sigma = Integer::from_rng_pm(&(&two_to_l * &n_n_circ).complete(), &mut rng);
202199
let r = Integer::from_rng_pm(&(&two_to_l_plus_e * &n_n_circ).complete(), &mut rng);
203200
let x = Integer::from_rng_pm(&l_e_n_circ_modulo, &mut rng);
204201
let y = Integer::from_rng_pm(&l_e_n_circ_modulo, &mut rng);
@@ -209,14 +206,7 @@ pub mod interactive {
209206
let b = aux.combine(&beta, &y)?;
210207
let t = aux.rsa_modulo.combine(&q, &alpha, &aux.t, &r)?;
211208

212-
let commitment = Commitment {
213-
p,
214-
q,
215-
a,
216-
b,
217-
t,
218-
sigma,
219-
};
209+
let commitment = Commitment { p, q, a, b, t };
220210
let private_commitment = PrivateCommitment {
221211
alpha,
222212
beta,
@@ -239,18 +229,17 @@ pub mod interactive {
239229
/// Compute proof for given data and prior protocol values
240230
pub fn prove(
241231
pdata: PrivateData,
242-
comm: &Commitment,
243232
pcomm: &PrivateCommitment,
244233
challenge: &Challenge,
245234
) -> Result<Proof, Error> {
246-
let sigma_circ = (&comm.sigma - &pcomm.nu * pdata.p).complete();
235+
let nu_p = (&pcomm.nu * pdata.p).complete();
247236

248237
Ok(Proof {
249238
z1: (&pcomm.alpha + challenge * pdata.p).complete(),
250239
z2: (&pcomm.beta + challenge * pdata.q).complete(),
251240
w1: (&pcomm.x + challenge * &pcomm.mu).complete(),
252241
w2: (&pcomm.y + challenge * &pcomm.nu).complete(),
253-
v: &pcomm.r + challenge * sigma_circ,
242+
v: &pcomm.r - challenge * nu_p,
254243
})
255244
}
256245

@@ -279,7 +268,7 @@ pub mod interactive {
279268
}
280269
// check 3
281270
{
282-
let r = aux.combine(data.n, &commitment.sigma)?;
271+
let r = aux.pow_mod(&aux.s, data.n)?;
283272
let q_to_z1 = aux.pow_mod(&commitment.q, &proof.z1)?;
284273
let t_to_v = aux.pow_mod(&aux.t, &proof.v)?;
285274
let lhs = (q_to_z1 * t_to_v).modulo(&aux.rsa_modulo);
@@ -328,7 +317,7 @@ pub mod non_interactive {
328317
) -> Result<Proof, Error> {
329318
let (commitment, pcomm) = super::interactive::commit(aux, data, pdata, security, rng)?;
330319
let challenge = challenge::<D>(shared_state, aux, data, &commitment, security);
331-
let proof = super::interactive::prove(pdata, &commitment, &pcomm, &challenge)?;
320+
let proof = super::interactive::prove(pdata, &pcomm, &challenge)?;
332321
Ok(Proof { commitment, proof })
333322
}
334323

0 commit comments

Comments
 (0)