diff --git a/src/multiexp.rs b/src/multiexp.rs index c742b11..89990fc 100644 --- a/src/multiexp.rs +++ b/src/multiexp.rs @@ -231,15 +231,19 @@ pub fn multiexp( pool: &CpuPool, bases: S, density_map: D, - exponents: Arc::Fr as PrimeField>::Repr>>, -// TODO -// c: u32 + exponents: Arc::Fr as PrimeField>::Repr>> ) -> Box::Projective, Error=Error>> where for<'a> &'a Q: QueryDensity, D: Send + Sync + 'static + Clone + AsRef, G: CurveAffine, S: SourceBuilder { + let c = if exponents.len() < 32 { + 3u32 + } else { + (f64::from(exponents.len() as u32)).ln().ceil() as u32 + }; + if let Some(query_size) = density_map.as_ref().get_query_size() { // If the density map has a known query size, it should not be // inconsistent with the number of exponents. @@ -247,7 +251,7 @@ pub fn multiexp( assert!(query_size == exponents.len()); } - multiexp_inner(pool, bases, density_map, exponents, 0, 12, true) + multiexp_inner(pool, bases, density_map, exponents, 0, c, true) } #[test] @@ -285,9 +289,7 @@ fn test_with_bls12() { &pool, (g, 0), FullDensity, - v, - // TODO - //7 + v ).wait().unwrap(); assert_eq!(naive, fast);