Skip to content

Commit 55c00e5

Browse files
committed
bug fix: take only necessary number of generator points
1 parent 45a78b6 commit 55c00e5

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/range_proof/mod.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,20 +163,16 @@ impl RangeProof {
163163
P: Borrow<RangeProof>,
164164
V: AsRef<[RistrettoPoint]>
165165
{
166-
println!("Verifying batch!");
167166
let mut nm: usize = 0;
168167
let mut dyn_bases_count:usize = 0;
169168
let batch = proofs.into_iter().map(|(p, vcs, n)| {
170169
let m = vcs.as_ref().len();
171170
let v = p.borrow().prepare_verification(n, vcs, &mut transcript.clone(), rng);
172171
dyn_bases_count += m /*V*/ + 4 /*A,S,T1,T2*/ + 2*p.borrow().ipp_proof.L_vec.len() /*{L,R}*/;
173-
println!("Current nm = {:?}, n,m = {:?},{:?}", nm, n, m);
174172
nm = nm.max(n*m);
175173
v
176174
}).collect::<Vec<_>>(); // we need to collect here so that nm and dyn_bases_count are computed.
177175

178-
println!("Batch size = {:?}", batch.len());
179-
180176
if gens.G.len() < nm {
181177
return Err(
182178
"The generators view does not have enough generators for the largest proof",
@@ -191,9 +187,6 @@ impl RangeProof {
191187
let mut dynamic_base_scalars: Vec<Scalar> = Vec::with_capacity(dyn_bases_count);
192188
let mut dynamic_bases: Vec<RistrettoPoint> = Vec::with_capacity(dyn_bases_count);
193189

194-
println!("Static scalars = {:?}", nm);
195-
println!("Dynamic scalars = {:?}", dyn_bases_count);
196-
197190
// All statements are added up. Each scalar in each statement
198191
// already has a challenge pre-multiplied in `prepare_verification`.
199192
for verification in batch {
@@ -221,8 +214,8 @@ impl RangeProof {
221214
.chain(dynamic_base_scalars.iter()),
222215
iter::once(&gens.pedersen_generators.B)
223216
.chain(iter::once(&gens.pedersen_generators.B_blinding))
224-
.chain(gens.G.iter())
225-
.chain(gens.H.iter())
217+
.chain(gens.G.iter().take(nm))
218+
.chain(gens.H.iter().take(nm))
226219
.chain(dynamic_bases.iter()),
227220
);
228221

@@ -589,6 +582,11 @@ mod tests {
589582
batch_verify_helper(&[(64, 1), (32, 2), (16, 4)]);
590583
}
591584

585+
#[test]
586+
fn batch_verify_mvp_failure() {
587+
batch_verify_helper(&[(4,1),(2,2)]);
588+
}
589+
592590
#[test]
593591
fn batch_verify_n_differ_m_differ_total_256() {
594592
batch_verify_helper(&[(16, 1), (32, 2), (64, 4)]);

0 commit comments

Comments
 (0)