Skip to content

Commit 2311f39

Browse files
committed
add comments on P equals Q case in add_mont function
1 parent 0834f30 commit 2311f39

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

g16ckt/src/gadgets/bn254/g1.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,9 @@ impl G1Projective {
156156

157157
impl G1Projective {
158158
// http://koclab.cs.ucsb.edu/teaching/ccs130h/2018/09projective.pdf
159+
/// Caution: Use this function only if P != +- Q
159160
#[component]
160-
pub fn add_montgomery<C: CircuitContext>(
161+
pub(crate) fn add_montgomery<C: CircuitContext>(
161162
circuit: &mut C,
162163
p: &G1Projective,
163164
q: &G1Projective,
@@ -391,6 +392,9 @@ impl G1Projective {
391392
));
392393
}
393394

395+
// given two bases M and N which were both known in compile time,
396+
// user can not find non-zero scalars 'a' and 'b' that should give [a]M = [b]N
397+
// The problem would be DLOG hard
394398
let mut acc = to_be_added[0].clone();
395399
for add in to_be_added.iter().skip(1) {
396400
let new_acc = Self::add_montgomery(circuit, &acc, add);

g16ckt/src/gadgets/bn254/g2.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ impl G2Projective {
207207

208208
impl G2Projective {
209209
// http://koclab.cs.ucsb.edu/teaching/ccs130h/2018/09projective.pdf
210+
/// Caution: Use this function only if P != +- Q
210211
#[component]
211212
pub fn add_montgomery<C: CircuitContext>(
212213
circuit: &mut C,

g16ckt/src/gadgets/groth16.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ pub fn groth16_verify<C: CircuitContext>(
8080

8181
// Add the constant term gamma_abc_g1[0] in Montgomery form
8282
let gamma0_m = G1Projective::as_montgomery(vk.gamma_abc_g1[0].into_group());
83+
// gamma0_m is known in compile time, user can not find a value of `msm_temp` that's equal to `gamma0_m`
84+
// The problem would be DLOG hard
8385
let msm =
8486
G1Projective::add_montgomery(circuit, &msm_temp, &G1Projective::new_constant(&gamma0_m));
8587

0 commit comments

Comments
 (0)