From ad7285827bf05cee7b55df1f497c3f22d34fbab7 Mon Sep 17 00:00:00 2001 From: jkwoods Date: Tue, 7 Nov 2023 16:17:35 -0500 Subject: [PATCH 1/9] make s_i scalars --- src/provider/ipa_pc.rs | 52 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/provider/ipa_pc.rs b/src/provider/ipa_pc.rs index af1f3714..e2cc9d8b 100644 --- a/src/provider/ipa_pc.rs +++ b/src/provider/ipa_pc.rs @@ -661,6 +661,58 @@ where }) } + fn verification_scalars( + &self, + n: usize, + transcript: &mut Transcript, + ) -> Result<(Vec, Vec, Vec), ProofVerifyError> { + let lg_n = self.L_vec.len(); + if lg_n >= 32 { + // 4 billion multiplications should be enough for anyone + // and this check prevents overflow in 1< Date: Wed, 8 Nov 2023 19:59:28 -0500 Subject: [PATCH 2/9] why not working --- src/provider/ipa_pc.rs | 51 ++++++++++++++++++++++++++-------------- src/provider/pedersen.rs | 3 ++- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/provider/ipa_pc.rs b/src/provider/ipa_pc.rs index e2cc9d8b..c35e79d2 100644 --- a/src/provider/ipa_pc.rs +++ b/src/provider/ipa_pc.rs @@ -665,15 +665,15 @@ where &self, n: usize, transcript: &mut Transcript, - ) -> Result<(Vec, Vec, Vec), ProofVerifyError> { - let lg_n = self.L_vec.len(); + ) -> Result<(Vec, Vec, Vec), NovaError> { + let lg_n = self.P_L_vec.len(); if lg_n >= 32 { // 4 billion multiplications should be enough for anyone // and this check prevents overflow in 1<::commit(&gens, &[G::Scalar::one()], &G::Scalar::zero()); - let g_to_a = CE::::commit(&gens_y, &a_vec, &G::Scalar::zero()); // g^a*h^0 = g^a + let g_to_a = CE::::commit(&gens_y, &[a], &G::Scalar::zero()); // g^a*h^0 = g^a let h_to_z2 = CE::::commit(&gens_y, &[G::Scalar::zero()], &self.z_2); // g^0 * h^z2 = h^z2 let g_hat_plus_g_to_a = g_hat + g_to_a; diff --git a/src/provider/pedersen.rs b/src/provider/pedersen.rs index 4b37fc26..76c09474 100644 --- a/src/provider/pedersen.rs +++ b/src/provider/pedersen.rs @@ -21,7 +21,8 @@ use serde::{Deserialize, Serialize}; /// A type that holds commitment generators #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct CommitmentGens { - gens: Vec, + /// generator vector + pub gens: Vec, h: G::PreprocessedGroupElement, _p: PhantomData, } From b552c5e708feb9739f83ecce44f54741991f8f27 Mon Sep 17 00:00:00 2001 From: jkwoods Date: Wed, 8 Nov 2023 22:46:46 -0500 Subject: [PATCH 3/9] batch inv --- Cargo.toml | 1 + src/provider/ipa_pc.rs | 49 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 9a113f56..e2ec1e95 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,6 +34,7 @@ flate2 = "1.0" bitvec = "1.0" byteorder = "1.4.3" thiserror = "1.0" +zeroize = { version = "1.5", default-features = false } [target.'cfg(any(target_arch = "x86_64", target_arch = "aarch64"))'.dependencies] pasta-msm = { version = "0.1.0", package = "lurk-pasta-msm" } diff --git a/src/provider/ipa_pc.rs b/src/provider/ipa_pc.rs index c35e79d2..65ceb87d 100644 --- a/src/provider/ipa_pc.rs +++ b/src/provider/ipa_pc.rs @@ -661,6 +661,53 @@ where }) } + fn batch_invert(inputs: &mut [G::Scalar]) -> G::Scalar { + // This code is essentially identical to the FieldElement + // implementation, and is documented there. Unfortunately, + // it's not easy to write it generically, since here we want + // to use `UnpackedScalar`s internally, and `Scalar`s + // externally, but there's no corresponding distinction for + // field elements. + + let n = inputs.len(); + let one = G::Scalar::one(); + + // Place scratch storage in a Zeroizing wrapper to wipe it when + // we pass out of scope. + let scratch = vec![one; n]; + // let mut scratch = Zeroizing::new(scratch_vec); + + // Keep an accumulator of all of the previous products + let mut acc = G::Scalar::one(); + + // Pass through the input vector, recording the previous + // products in the scratch space + for (input, scratch) in inputs.iter().zip(scratch.iter_mut()) { + *scratch = acc; + + acc = acc * input; + } + + // acc is nonzero iff all inputs are nonzero + debug_assert!(acc != G::Scalar::zero()); + + // Compute the inverse of all products + acc = acc.invert().unwrap(); + + // We need to return the product of all inverses later + let ret = acc; + + // Pass through the vector backwards to compute the inverses + // in place + for (input, scratch) in inputs.iter_mut().rev().zip(scratch.iter().rev()) { + let tmp = acc * input.clone(); + *input = acc * scratch; + acc = tmp; + } + + ret + } + fn verification_scalars( &self, n: usize, @@ -688,7 +735,7 @@ where // inverses let mut challenges_inv = challenges.clone(); - let prod_all_inv = G::Scalar::batch_invert(&mut challenges_inv); + let prod_all_inv = Self::batch_invert(&mut challenges_inv); // squares of challenges & inverses for i in 0..lg_n { From 06d446a2ddcf0b49f9402662f9a6472decc6e723 Mon Sep 17 00:00:00 2001 From: jkwoods Date: Thu, 9 Nov 2023 14:20:12 -0500 Subject: [PATCH 4/9] compilation, tests suspiciously all pass --- src/provider/ipa_pc.rs | 72 +++++++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 22 deletions(-) diff --git a/src/provider/ipa_pc.rs b/src/provider/ipa_pc.rs index 65ceb87d..a9e43090 100644 --- a/src/provider/ipa_pc.rs +++ b/src/provider/ipa_pc.rs @@ -508,7 +508,7 @@ where )) } - fn bullet_reduce_verifier( + /*fn bullet_reduce_verifier( P: &Commitment, P_L: &Commitment, P_R: &Commitment, @@ -549,7 +549,7 @@ where let P_prime = *P_L * chal_square + *P + *P_R * chal_inverse_square; Ok((P_prime, a_vec_prime, gens_prime)) - } + }*/ /// prover inner product argument pub fn prove( @@ -674,7 +674,7 @@ where // Place scratch storage in a Zeroizing wrapper to wipe it when // we pass out of scope. - let scratch = vec![one; n]; + let mut scratch = vec![one; n]; // let mut scratch = Zeroizing::new(scratch_vec); // Keep an accumulator of all of the previous products @@ -785,10 +785,9 @@ where // Scaling to be compatible with Bulletproofs figure 1 let chal = G::Scalar::challenge(b"r", transcript); // sample a random challenge for scaling commitment let gens_y = gens_y.scale(&chal); - let mut P = U.comm_x_vec + U.comm_y * chal; + let P = U.comm_x_vec + U.comm_y * chal; - let mut gens = gens.clone(); - let mut a_vec = U.a_vec.clone(); + let a_vec = U.a_vec.clone(); // Step 1 in Hyrax's figure 7. /* for i in 0..self.P_L_vec.len() { @@ -804,21 +803,29 @@ where } */ - let (u_sq, u_inv_sq, s) = self.verification_scalars(n, transcript)?; + let (mut u_sq, mut u_inv_sq, s) = self.verification_scalars(n, transcript)?; - gens.gens = G::vartime_multiscalar_mul(&s, &gens.gens); + let g_hat = G::vartime_multiscalar_mul(&s, &gens.get_gens()); let a = inner_product(&a_vec[..], &s[..]); - let Ls = self.P_L_vec.iter().map(|p| p.decompress()).collect(); + let mut Ls: Vec = self + .P_L_vec + .iter() + .map(|p| p.decompress().unwrap().reinterpret_as_generator()) + .collect(); + let mut Rs: Vec = self + .P_R_vec + .iter() + .map(|p| p.decompress().unwrap().reinterpret_as_generator()) + .collect(); - let Rs = self.P_R_vec.iter().map(|p| p.decompress()).collect(); + Ls.append(&mut Rs); + Ls.push(P.reinterpret_as_generator()); u_sq.append(&mut u_inv_sq); u_sq.push(G::Scalar::one()); - Ls.append(&mut Rs); - Ls.push(P.clone()); - P.comm = G::vartime_multiscalar_mul(&u_sq, &Ls[..]); + let P_comm = G::vartime_multiscalar_mul(&u_sq, &Ls[..]); // Step 3 in Hyrax's Figure 7 self.beta.append_to_transcript(b"beta", transcript); @@ -826,17 +833,38 @@ where let chal = G::Scalar::challenge(b"chal_z", transcript); - let P_plus_beta = P * chal + self.beta.decompress().unwrap(); - let P_plus_beta_to_a = P_plus_beta * a; - let left_hand_side = P_plus_beta_to_a + self.delta.decompress().unwrap(); + let left_hand_side = G::vartime_multiscalar_mul( + &[(chal * a), a, G::Scalar::one()], + &[ + P_comm.preprocessed(), + self.beta.decompress().unwrap().reinterpret_as_generator(), + self.delta.decompress().unwrap().reinterpret_as_generator(), + ], + ); + /* + let P_plus_beta = P * chal + self.beta.decompress().unwrap(); + let P_plus_beta_to_a = P_plus_beta * a; + let left_hand_side = P_plus_beta_to_a + self.delta.decompress().unwrap(); + */ + // g_hat^z1 * g^(a*z1) * h^z2 + let right_hand_side = G::vartime_multiscalar_mul( + &[self.z_1, (self.z_1 * a), self.z_2], + &[ + g_hat.preprocessed(), + gens_y.get_gens()[0].clone(), + gens_y.get_blinding_gen(), + ], + ); - let g_hat = CE::::commit(&gens, &[G::Scalar::one()], &G::Scalar::zero()); - let g_to_a = CE::::commit(&gens_y, &[a], &G::Scalar::zero()); // g^a*h^0 = g^a - let h_to_z2 = CE::::commit(&gens_y, &[G::Scalar::zero()], &self.z_2); // g^0 * h^z2 = h^z2 + /*let g_hat = gens_g; // Check? //CE::::commit(&gens, &[G::Scalar::one()], &G::Scalar::zero()); - let g_hat_plus_g_to_a = g_hat + g_to_a; - let val_to_z1 = g_hat_plus_g_to_a * self.z_1; - let right_hand_side = val_to_z1 + h_to_z2; + let g_to_a = G::vartime_multiscalar_mul(&[a], gens_y.get_gens()); //CE::::commit(&gens_y, &[a], &G::Scalar::zero()); // g^a*h^0 = g^a + let h_to_z2 = G::vartime_multiscalar_mul(&[a], gens_y.get_gens()); //CE::::commit(&gens_y, &[G::Scalar::zero()], &self.z_2); // g^0 * h^z2 = h^z2 + + let g_hat_plus_g_to_a = g_hat + g_to_a; + let val_to_z1 = g_hat_plus_g_to_a * self.z_1; + let right_hand_side = val_to_z1 + h_to_z2; + */ if left_hand_side == right_hand_side { Ok(()) From dfd57d253a619c57c802b27507b0c8f25023a6af Mon Sep 17 00:00:00 2001 From: jkwoods Date: Thu, 9 Nov 2023 14:48:21 -0500 Subject: [PATCH 5/9] alright, convinced --- src/provider/ipa_pc.rs | 75 +++--------------------------------------- 1 file changed, 4 insertions(+), 71 deletions(-) diff --git a/src/provider/ipa_pc.rs b/src/provider/ipa_pc.rs index a9e43090..c893cc92 100644 --- a/src/provider/ipa_pc.rs +++ b/src/provider/ipa_pc.rs @@ -508,49 +508,6 @@ where )) } - /*fn bullet_reduce_verifier( - P: &Commitment, - P_L: &Commitment, - P_R: &Commitment, - a_vec: &[G::Scalar], - gens: &CommitmentGens, - transcript: &mut Transcript, - ) -> Result< - ( - Commitment, // P' - Vec, // a_vec' - CommitmentGens, // gens' - ), - NovaError, - > { - let n = a_vec.len(); - - P_L.append_to_transcript(b"L", transcript); - P_R.append_to_transcript(b"R", transcript); - - let chal = G::Scalar::challenge(b"challenge_r", transcript); - - // println!("Challenge in bullet_reduce_verifier {:?}", chal); - - let chal_square = chal * chal; - let chal_inverse = chal.invert().unwrap(); - let chal_inverse_square = chal_inverse * chal_inverse; - - // This takes care of splitting them in half and multiplying left half - // by chal_inverse and right half by chal - let gens_prime = gens.fold(&chal_inverse, &chal); - - let a_vec_prime = a_vec[0..n / 2] - .par_iter() - .zip(a_vec[n / 2..n].par_iter()) - .map(|(a_L, a_R)| *a_L * chal_inverse + chal * *a_R) - .collect::>(); - - let P_prime = *P_L * chal_square + *P + *P_R * chal_inverse_square; - - Ok((P_prime, a_vec_prime, gens_prime)) - }*/ - /// prover inner product argument pub fn prove( gens: &CommitmentGens, @@ -661,6 +618,7 @@ where }) } + // from Spartan, notably without the zeroizing buffer fn batch_invert(inputs: &mut [G::Scalar]) -> G::Scalar { // This code is essentially identical to the FieldElement // implementation, and is documented there. Unfortunately, @@ -708,6 +666,7 @@ where ret } + // copied almost directly from the Spartan method, with some type massaging fn verification_scalars( &self, n: usize, @@ -745,7 +704,7 @@ where let challenges_sq = challenges; let challenges_inv_sq = challenges_inv; - // s values inductively - wtf is happening here? check + // s values inductively let mut s = Vec::with_capacity(n); s.push(prod_all_inv); for i in 1..n { @@ -790,18 +749,6 @@ where let a_vec = U.a_vec.clone(); // Step 1 in Hyrax's figure 7. - /* for i in 0..self.P_L_vec.len() { - let P_L = self.P_L_vec[i].decompress().unwrap(); - let P_R = self.P_R_vec[i].decompress().unwrap(); - - let (P_prime, a_vec_prime, gens_prime) = - Self::bullet_reduce_verifier(&P, &P_L, &P_R, &a_vec, &gens, transcript)?; - - P = P_prime; - a_vec = a_vec_prime; - gens = gens_prime; - } - */ let (mut u_sq, mut u_inv_sq, s) = self.verification_scalars(n, transcript)?; @@ -841,11 +788,7 @@ where self.delta.decompress().unwrap().reinterpret_as_generator(), ], ); - /* - let P_plus_beta = P * chal + self.beta.decompress().unwrap(); - let P_plus_beta_to_a = P_plus_beta * a; - let left_hand_side = P_plus_beta_to_a + self.delta.decompress().unwrap(); - */ + // g_hat^z1 * g^(a*z1) * h^z2 let right_hand_side = G::vartime_multiscalar_mul( &[self.z_1, (self.z_1 * a), self.z_2], @@ -856,16 +799,6 @@ where ], ); - /*let g_hat = gens_g; // Check? //CE::::commit(&gens, &[G::Scalar::one()], &G::Scalar::zero()); - - let g_to_a = G::vartime_multiscalar_mul(&[a], gens_y.get_gens()); //CE::::commit(&gens_y, &[a], &G::Scalar::zero()); // g^a*h^0 = g^a - let h_to_z2 = G::vartime_multiscalar_mul(&[a], gens_y.get_gens()); //CE::::commit(&gens_y, &[G::Scalar::zero()], &self.z_2); // g^0 * h^z2 = h^z2 - - let g_hat_plus_g_to_a = g_hat + g_to_a; - let val_to_z1 = g_hat_plus_g_to_a * self.z_1; - let right_hand_side = val_to_z1 + h_to_z2; - */ - if left_hand_side == right_hand_side { Ok(()) } else { From 4fd29437fac3e05dafd11ed813a3e2f16e1caf16 Mon Sep 17 00:00:00 2001 From: jkwoods Date: Thu, 9 Nov 2023 15:03:39 -0500 Subject: [PATCH 6/9] comments, clippy --- src/provider/.ipa_pc.rs.swp | Bin 0 -> 16384 bytes src/provider/ipa_pc.rs | 12 +++++++----- src/spartan/direct.rs | 7 ++----- 3 files changed, 9 insertions(+), 10 deletions(-) create mode 100644 src/provider/.ipa_pc.rs.swp diff --git a/src/provider/.ipa_pc.rs.swp b/src/provider/.ipa_pc.rs.swp new file mode 100644 index 0000000000000000000000000000000000000000..358a5c1f1327a08b97e9489b0d27d9d786059314 GIT binary patch literal 16384 zcmeHOU5q4E6)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P_vhjIed?89EM#Js9NNeKz1vad`_j0A`IS0?DBWNSRK0xcN98RP;u%XGsW0yEAZl912;4SEI6sYPG3V zetWq2+a>yjEx#^i-y;>%Z1Xk7QM8xqklELMvOLZ31QsR5C^1X1mF0uxKyHn*I2HM5 z>fgRs6?DOf>fWdiN}tfD>lYQQ)hFc#sZ>CIkY%Yn8Llz|y20ir3SXfhSe8B(jz_zv y%yxA6L%o{qWGlyTxKrEj*q#cJOg?mc^H!YU5?^s*$;9vg#JCjhWJG#wpYbouU=_ju literal 0 HcmV?d00001 diff --git a/src/provider/ipa_pc.rs b/src/provider/ipa_pc.rs index c893cc92..5b0f4574 100644 --- a/src/provider/ipa_pc.rs +++ b/src/provider/ipa_pc.rs @@ -643,7 +643,7 @@ where for (input, scratch) in inputs.iter().zip(scratch.iter_mut()) { *scratch = acc; - acc = acc * input; + acc *= input; } // acc is nonzero iff all inputs are nonzero @@ -658,7 +658,7 @@ where // Pass through the vector backwards to compute the inverses // in place for (input, scratch) in inputs.iter_mut().rev().zip(scratch.iter().rev()) { - let tmp = acc * input.clone(); + let tmp = acc * *input; *input = acc * scratch; acc = tmp; } @@ -748,10 +748,10 @@ where let a_vec = U.a_vec.clone(); - // Step 1 in Hyrax's figure 7. - + // calculate all the exponent challenges (s) and inverses at once let (mut u_sq, mut u_inv_sq, s) = self.verification_scalars(n, transcript)?; + // do all the exponentiations at once (Hyrax, Fig. 7, step 4, all rounds) let g_hat = G::vartime_multiscalar_mul(&s, &gens.get_gens()); let a = inner_product(&a_vec[..], &s[..]); @@ -774,12 +774,14 @@ where let P_comm = G::vartime_multiscalar_mul(&u_sq, &Ls[..]); - // Step 3 in Hyrax's Figure 7 + // Step 3 in Hyrax's Figure 8 self.beta.append_to_transcript(b"beta", transcript); self.delta.append_to_transcript(b"delta", transcript); let chal = G::Scalar::challenge(b"chal_z", transcript); + // Step 5 in Hyrax's Figure 8 + // P^(chal*a) * beta^a * delta^1 let left_hand_side = G::vartime_multiscalar_mul( &[(chal * a), a, G::Scalar::one()], &[ diff --git a/src/spartan/direct.rs b/src/spartan/direct.rs index b6778af9..a5e11e6c 100644 --- a/src/spartan/direct.rs +++ b/src/spartan/direct.rs @@ -467,7 +467,7 @@ mod tests { // verify the SNARK let z_out = circuit.output(&z_0); - let io = z_0.into_iter().chain(z_out.into_iter()).collect::>(); + let io = z_0.into_iter().chain(z_out).collect::>(); let res = snark.cap_verify(&vk, &io, &com_v); assert!(res.is_ok()); } @@ -542,10 +542,7 @@ mod tests { let snark = res.unwrap(); // verify the SNARK - let io = input - .into_iter() - .chain(output.clone().into_iter()) - .collect::>(); + let io = input.into_iter().chain(output.clone()).collect::>(); let res = snark.verify(&vk, &io); assert!(res.is_ok()); From 5984c9b291304b89bbcc6257f5514c364fc7299a Mon Sep 17 00:00:00 2001 From: jkwoods Date: Thu, 9 Nov 2023 15:03:55 -0500 Subject: [PATCH 7/9] comments, clippy --- src/provider/.ipa_pc.rs.swp | Bin 16384 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/provider/.ipa_pc.rs.swp diff --git a/src/provider/.ipa_pc.rs.swp b/src/provider/.ipa_pc.rs.swp deleted file mode 100644 index 358a5c1f1327a08b97e9489b0d27d9d786059314..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeHOU5q4E6)ygfAB81`5FfZR=ukcM_UsP?sNITVRn0Cmx1Rh!??~m%=f-_=KLMPFz)9$cl&zqR2+L1WE#f<_d3t4_ijX~ct|!P_a(f3jdWvB0BHOa$SoGa+Jk zB8tORug&8LFLLb2ZN%r8@@(Q%eU%0(4Gh)5mB!vZyX8^8VRVFDv*YN{QB`B5fl33F z1}Y6y8mKf-X`s?TrGZKV|C<^}qDzcVVQJ^<<*n$~^9Eku($D90yFbwXrtV+Y?SCHV z|EKQ%v~Is&Pms;?hVBn^|EmN2uj~F;_kTG;A&0QBnG?;>?+0Peb9~DR_?j7oUXX|~;|5=Kd{E^?N}zQT2;)?< z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9 Nov 2023 15:35:39 -0500 Subject: [PATCH 8/9] clean up --- Cargo.toml | 1 - src/provider/ipa_pc.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e2ec1e95..9a113f56 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,6 @@ flate2 = "1.0" bitvec = "1.0" byteorder = "1.4.3" thiserror = "1.0" -zeroize = { version = "1.5", default-features = false } [target.'cfg(any(target_arch = "x86_64", target_arch = "aarch64"))'.dependencies] pasta-msm = { version = "0.1.0", package = "lurk-pasta-msm" } diff --git a/src/provider/ipa_pc.rs b/src/provider/ipa_pc.rs index 5b0f4574..5432d902 100644 --- a/src/provider/ipa_pc.rs +++ b/src/provider/ipa_pc.rs @@ -633,7 +633,7 @@ where // Place scratch storage in a Zeroizing wrapper to wipe it when // we pass out of scope. let mut scratch = vec![one; n]; - // let mut scratch = Zeroizing::new(scratch_vec); + //let mut scratch = Zeroizing::new(scratch_vec); // Keep an accumulator of all of the previous products let mut acc = G::Scalar::one(); From f41cd99644d5729622e3b871cd72115a4598bbc6 Mon Sep 17 00:00:00 2001 From: jkwoods Date: Thu, 9 Nov 2023 15:44:00 -0500 Subject: [PATCH 9/9] clean up --- src/provider/pedersen.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/provider/pedersen.rs b/src/provider/pedersen.rs index 76c09474..4b37fc26 100644 --- a/src/provider/pedersen.rs +++ b/src/provider/pedersen.rs @@ -21,8 +21,7 @@ use serde::{Deserialize, Serialize}; /// A type that holds commitment generators #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct CommitmentGens { - /// generator vector - pub gens: Vec, + gens: Vec, h: G::PreprocessedGroupElement, _p: PhantomData, }