From 03c2cacf0185b901d1cd244f1ccff14b7926d9d7 Mon Sep 17 00:00:00 2001 From: Koukyosyumei Date: Sun, 29 Dec 2024 11:18:50 -0500 Subject: [PATCH] update --- .../modules/zksnark/tutorial_snark/protocol_3.rs | 9 +++------ .../modules/zksnark/tutorial_snark/protocol_5.rs | 16 ++++++++-------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/myzkp/src/modules/zksnark/tutorial_snark/protocol_3.rs b/myzkp/src/modules/zksnark/tutorial_snark/protocol_3.rs index b289c35..68a12ed 100644 --- a/myzkp/src/modules/zksnark/tutorial_snark/protocol_3.rs +++ b/myzkp/src/modules/zksnark/tutorial_snark/protocol_3.rs @@ -58,12 +58,9 @@ pub fn setup(g1: &G1Point, g2: &G2Point, qap: &QAP) -> (ProofKey3, Veri let r_i_s = qap.r_i_vec[i].eval(&s).sanitize(); let o_i_s = qap.o_i_vec[i].eval(&s).sanitize(); g1_checksum_vec.push( - g1.mul_ref( - ((beta_ell.mul_ref(&ell_i_s)) - .add_ref(&beta_r.mul_ref(&r_i_s)) - .add_ref(&beta_o.mul_ref(&o_i_s))) - .get_value(), - ), + g1 * ((beta_ell.mul_ref(&ell_i_s)) + .add_ref(&beta_r.mul_ref(&r_i_s)) + .add_ref(&beta_o.mul_ref(&o_i_s))), ); } diff --git a/myzkp/src/modules/zksnark/tutorial_snark/protocol_5.rs b/myzkp/src/modules/zksnark/tutorial_snark/protocol_5.rs index fdd347f..056466c 100644 --- a/myzkp/src/modules/zksnark/tutorial_snark/protocol_5.rs +++ b/myzkp/src/modules/zksnark/tutorial_snark/protocol_5.rs @@ -53,11 +53,11 @@ pub fn setup(g1: &G1Point, g2: &G2Point, qap: &QAP) -> (ProofKey5, Veri let rho_r = FqOrder::random_element(&[]); let rho_o = rho_ell.mul_ref(&rho_r); - let g1_ell = g1 * rho_ell.get_value(); - let g1_r = g1 * rho_r.get_value(); - let g2_r = g2 * rho_r.get_value(); - let g1_o = g1 * rho_o.get_value(); - let g2_o = g2 * rho_o.get_value(); + let g1_ell = g1 * &rho_ell; + let g1_r = g1 * &rho_r; + let g2_r = g2 * &rho_r; + let g1_o = g1 * &rho_o; + let g2_o = g2 * &rho_o; let mut g1_checksum_vec = Vec::with_capacity(qap.d); @@ -89,9 +89,9 @@ pub fn setup(g1: &G1Point, g2: &G2Point, qap: &QAP) -> (ProofKey5, Veri g1_checksum_vec: g1_checksum_vec, }, VerificationKey5 { - g2_alpha_ell: g2 * alpha_ell.get_value(), - g1_alpha_r: g1 * alpha_r.get_value(), - g2_alpha_o: g2 * alpha_o.get_value(), + g2_alpha_ell: g2 * &alpha_ell, + g1_alpha_r: g1 * &alpha_r, + g2_alpha_o: g2 * &alpha_o, g1_beta_eta: g1 * beta.get_value() * eta.get_value(), g2_beta_eta: g2 * beta.get_value() * eta.get_value(), g2_t_s: g2_o * qap.t.eval(&s).sanitize().get_value(),