Skip to content

Commit 51596f8

Browse files
committed
improve KZG10 verification speed
1 parent a6def66 commit 51596f8

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/kzg10/mod.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,15 @@ where
291291
if let Some(random_v) = proof.random_v {
292292
inner -= &vk.gamma_g.mul(random_v);
293293
}
294-
let lhs = E::pairing(inner, vk.h);
295-
296-
let inner = vk.beta_h.into_projective() - &vk.h.mul(point);
297-
let rhs = E::pairing(proof.w, inner);
298-
299-
end_timer!(check_time, || format!("Result: {}", lhs == rhs));
300-
Ok(lhs == rhs)
294+
let inner2 = vk.beta_h.into_projective() - &vk.h.mul(point);
295+
296+
let pairing_prod_inputs:Vec<(E::G1Prepared, E::G2Prepared)> = vec![
297+
((-inner).into_affine().into(), vk.h.into()),
298+
(proof.w.into(), inner2.into_affine().into()),
299+
];
300+
let res = E::product_of_pairings(pairing_prod_inputs.iter()) == E::Fqk::one();
301+
end_timer!(check_time, || format!("Result: {}", res));
302+
Ok(res)
301303
}
302304

303305
/// Check that each `proof_i` in `proofs` is a valid proof of evaluation for

0 commit comments

Comments
 (0)