Skip to content

Commit

Permalink
Use FixedBaseMSM for structured setup
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvantyagi authored and Pratyush committed Sep 15, 2020
1 parent 1894c01 commit e45028f
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions ip_proofs/src/tipa/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use algebra::{
bytes::ToBytes,
curves::{PairingEngine, ProjectiveCurve},
fields::Field,
fields::{Field, PrimeField},
groups::Group,
msm::FixedBaseMSM,
to_bytes, UniformRand,
};
use digest::Digest;
Expand Down Expand Up @@ -327,18 +328,30 @@ where
}
}

pub fn structured_generators_scalar_power<G: Group>(
pub fn structured_generators_scalar_power<G: ProjectiveCurve>(
num: usize,
g: &G,
s: &G::ScalarField,
) -> Vec<G> {
let mut generators = Vec::new();
assert!(num > 0);
let mut powers_of_scalar = vec![];
let mut pow_s = G::ScalarField::one();
for _ in 0..num {
generators.push(g.mul(&pow_s));
powers_of_scalar.push(pow_s);
pow_s *= s;
}
generators

let window_size = FixedBaseMSM::get_mul_window_size(num);

let scalar_bits = G::ScalarField::size_in_bits();
let g_table = FixedBaseMSM::get_window_table(scalar_bits, window_size, g.clone());
let powers_of_g = FixedBaseMSM::multi_scalar_mul::<G>(
scalar_bits,
window_size,
&g_table,
&powers_of_scalar,
);
powers_of_g
}

fn polynomial_evaluation_product_form_from_transcript<F: Field>(
Expand Down

0 comments on commit e45028f

Please sign in to comment.