(
public_inputs: &[<Bn254 as ark_Pairing>::ScalarField],
proof: &Proof<Bn254>,
vk: &VerifyingKey<Bn254>,
)
| 23 | |
| 24 | impl Verifier { |
| 25 | pub fn hinted_verify( |
| 26 | public_inputs: &[<Bn254 as ark_Pairing>::ScalarField], |
| 27 | proof: &Proof<Bn254>, |
| 28 | vk: &VerifyingKey<Bn254>, |
| 29 | ) -> (Script, Vec<Hint>) { |
| 30 | let mut hints = Vec::new(); |
| 31 | |
| 32 | let scalars = [ |
| 33 | vec![<Bn254 as ark_Pairing>::ScalarField::ONE], |
| 34 | public_inputs.to_owned(), |
| 35 | ] |
| 36 | .concat(); |
| 37 | let msm_g1 = |
| 38 | G1Projective::msm(&vk.gamma_abc_g1, &scalars).expect("failed to calculate msm"); |
| 39 | //let (hinted_msm, hint_msm) = hinted_msm_with_constant_bases(&vk.gamma_abc_g1, &scalars); |
| 40 | let (hinted_msm, hint_msm) = |
| 41 | hinted_msm_with_constant_bases_affine(&vk.gamma_abc_g1, &scalars); |
| 42 | hints.extend(hint_msm); |
| 43 | |
| 44 | // G1/G2 points for pairings |
| 45 | let (p1, p2, p3, p4) = (msm_g1.into_affine(), proof.c, vk.alpha_g1, proof.a); |
| 46 | let (q1, q2, q3, q4) = ( |
| 47 | vk.gamma_g2.into_group().neg().into_affine(), |
| 48 | vk.delta_g2.into_group().neg().into_affine(), |
| 49 | -vk.beta_g2, |
| 50 | proof.b, |
| 51 | ); |
| 52 | let t4 = q4; |
| 53 | |
| 54 | // hint from arkworks |
| 55 | let pairing = BnAffinePairing; |
| 56 | let f_without_3 = pairing |
| 57 | .multi_miller_loop_affine([p1, p2, p4], [q1, q2, q4]) |
| 58 | .0; |
| 59 | let (c, wi) = compute_c_wi(f_without_3); |
| 60 | let c_inv = c.inverse().unwrap(); |
| 61 | let result = f_without_3 * wi * (c_inv.pow(LAMBDA.to_u64_digits())); |
| 62 | println!("f_without_3: {:?}", f_without_3); |
| 63 | println!("result: {:?}", result); |
| 64 | |
| 65 | let q_prepared = [ |
| 66 | G2Prepared::from_affine(q1), |
| 67 | G2Prepared::from_affine(q2), |
| 68 | G2Prepared::from_affine(q3), |
| 69 | G2Prepared::from_affine(q4), |
| 70 | ]; |
| 71 | |
| 72 | let p_lst = vec![p1, p2, p3, p4]; |
| 73 | |
| 74 | let (hinted_script1, hint1) = Fq::hinted_inv(p1.y); |
| 75 | let (hinted_script2, hint2) = Fq::hinted_mul(1, p1.y.inverse().unwrap(), 0, p1.x.neg()); |
| 76 | let (hinted_script3, hint3) = hinted_from_eval_point(p2); |
| 77 | let (hinted_script4, hint4) = hinted_from_eval_point(p3); |
| 78 | let (hinted_script5, hint5) = hinted_from_eval_point(p4); |
| 79 | let (hinted_script6, hint6) = Pairing::hinted_quad_miller_loop_with_c_wi( |
| 80 | q_prepared.to_vec(), |
| 81 | c, |
| 82 | c_inv, |
nothing calls this directly
no test coverage detected