diff --git a/src/lib.rs b/src/lib.rs index d5190d7..0293027 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -57,7 +57,7 @@ impl LinearCombination { } pub fn eval( - self, + &self, mut input_density: Option<&mut DensityTracker>, mut aux_density: Option<&mut DensityTracker>, input_assignment: &[E::Fr], @@ -66,7 +66,7 @@ impl LinearCombination { { let mut acc = E::Fr::zero(); - for (index, coeff) in self.0.into_iter() { + for &(index, coeff) in self.0.iter() { let mut tmp; match index { @@ -262,11 +262,9 @@ impl TestConstraintSystem { pub fn is_satisfied(&self) -> bool { for &(ref a, ref b, ref c) in &self.constraints { - // TODO: make eval not take self by value - - let mut a = a.clone().eval(None, None, &self.inputs, &self.aux); - let b = b.clone().eval(None, None, &self.inputs, &self.aux); - let c = c.clone().eval(None, None, &self.inputs, &self.aux); + let mut a = a.eval(None, None, &self.inputs, &self.aux); + let b = b.eval(None, None, &self.inputs, &self.aux); + let c = c.eval(None, None, &self.inputs, &self.aux); a.mul_assign(&b); diff --git a/src/multiexp.rs b/src/multiexp.rs index 7773790..c742b11 100644 --- a/src/multiexp.rs +++ b/src/multiexp.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use std::io; use bit_vec::{self, BitVec}; use std::iter; -use futures::{BoxFuture, Future}; +use futures::{Future}; use futures_cpupool::CpuPool; use super::Error; @@ -138,7 +138,7 @@ fn multiexp_inner( mut skip: u32, c: u32, handle_trivial: bool -) -> BoxFuture<::Projective, Error> +) -> Box::Projective, Error=Error>> where for<'a> &'a Q: QueryDensity, D: Send + Sync + 'static + Clone + AsRef, G: CurveAffine, @@ -206,21 +206,22 @@ fn multiexp_inner( if skip >= ::Fr::NUM_BITS { // There isn't another region. - this.boxed() + Box::new(this) } else { // There's another region more significant. Calculate and join it with // this region recursively. - this.join(multiexp_inner(pool, bases, density_map, exponents, skip, c, false)) - .map(move |(this, mut higher)| { - for _ in 0..c { - higher.double(); - } + Box::new( + this.join(multiexp_inner(pool, bases, density_map, exponents, skip, c, false)) + .map(move |(this, mut higher)| { + for _ in 0..c { + higher.double(); + } - higher.add_assign(&this); + higher.add_assign(&this); - higher - }) - .boxed() + higher + }) + ) } } @@ -233,7 +234,7 @@ pub fn multiexp( exponents: Arc::Fr as PrimeField>::Repr>>, // TODO // c: u32 -) -> BoxFuture<::Projective, Error> +) -> Box::Projective, Error=Error>> where for<'a> &'a Q: QueryDensity, D: Send + Sync + 'static + Clone + AsRef, G: CurveAffine,