Skip to content

Commit 8bcd0a8

Browse files
committed
pairing-product for ML-KZG; update change log
1 parent a9ca644 commit 8bcd0a8

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Pending
44

5+
- [\#98](https://github.com/arkworks-rs/poly-commit/pull/98) Use pairing-product to accelerate `KZG` and `multilinear_pc` verifications.
6+
57
### Breaking changes
68

79
- [\#82](https://github.com/arkworks-rs/poly-commit/pull/82) Function parameter `opening_challenge: F` for `open`,

src/multilinear_pc/mod.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -194,39 +194,39 @@ impl<E: PairingEngine> MultilinearPC<E> {
194194
value: E::Fr,
195195
proof: &Proof<E>,
196196
) -> bool {
197-
let left = E::pairing(
198-
commitment.g_product.into_projective() - &vk.g.mul(value),
199-
vk.h,
200-
);
201197

202198
let scalar_size = E::Fr::MODULUS_BIT_SIZE as usize;
203199
let window_size = FixedBase::get_mul_window_size(vk.nv);
204200

205-
let g_table = FixedBase::get_window_table(scalar_size, window_size, vk.g.into_projective());
206-
let g_mul: Vec<E::G1Projective> = FixedBase::msm(scalar_size, window_size, &g_table, point);
201+
let g_table = FixedBase::get_window_table(
202+
scalar_size,
203+
window_size,
204+
vk.g.into_projective(),
205+
);
206+
let g_mul: Vec<E::G1Projective> =
207+
FixedBase::msm(scalar_size, window_size, &g_table, point);
207208

208-
let pairing_lefts: Vec<_> = (0..vk.nv)
209-
.map(|i| vk.g_mask_random[i].into_projective() - &g_mul[i])
210-
.collect();
211-
let pairing_lefts: Vec<E::G1Affine> =
212-
E::G1Projective::batch_normalization_into_affine(&pairing_lefts);
213-
let pairing_lefts: Vec<E::G1Prepared> = pairing_lefts
214-
.into_iter()
215-
.map(|x| E::G1Prepared::from(x))
209+
let mut g1_vec: Vec<_> = (0..vk.nv)
210+
.map(|i| vk.g_mask_random[i].into_projective() - g_mul[i])
216211
.collect();
212+
g1_vec.push(vk.g.mul(value) - commitment.g_product.into_projective());
217213

218-
let pairing_rights: Vec<E::G2Prepared> = proof
219-
.proofs
220-
.iter()
221-
.map(|x| E::G2Prepared::from(*x))
222-
.collect();
214+
let g1_vec: Vec<E::G1Affine> = E::G1Projective::batch_normalization_into_affine(&g1_vec);
215+
let tmp = g1_vec[vk.nv];
223216

224-
let pairings: Vec<_> = pairing_lefts
217+
let mut pairings: Vec<_> = g1_vec
225218
.into_iter()
226-
.zip(pairing_rights.into_iter())
219+
.take(vk.nv)
220+
.map(E::G1Prepared::from)
221+
.zip(proof.proofs.iter().map(|&x| E::G2Prepared::from(x)))
227222
.collect();
228-
let right = E::product_of_pairings(pairings.iter());
229-
left == right
223+
224+
pairings.push((
225+
E::G1Prepared::from(tmp),
226+
E::G2Prepared::from(vk.h),
227+
));
228+
229+
E::product_of_pairings(pairings.iter()) == E::Fqk::one()
230230
}
231231
}
232232

0 commit comments

Comments
 (0)