diff --git a/poly-commit/src/linear_codes/mod.rs b/poly-commit/src/linear_codes/mod.rs index 30b524c0..614f6445 100644 --- a/poly-commit/src/linear_codes/mod.rs +++ b/poly-commit/src/linear_codes/mod.rs @@ -106,7 +106,7 @@ where fn poly_to_vec(polynomial: &P) -> Vec; /// Represent the query point as a vector of Field elements. - fn point_to_vec(point: P::Point) -> Vec; + fn point_to_vec(point: &P::Point) -> &Vec; /// Arrange the coefficients of the polynomial into a matrix, /// and apply encoding to each row. @@ -162,7 +162,7 @@ where P: Polynomial, S: CryptographicSponge, C: Config + 'static, - Vec: Borrow<::Input>, + for<'a> &'a Vec: Borrow<::Input>, H::Output: Into + Send, C::Leaf: Sized + Clone + Default + Send + AsRef, H: CRHScheme + 'static, @@ -192,9 +192,7 @@ where rng: &mut R, ) -> Result { let leaf_hash_param = ::setup(rng).unwrap(); - let two_to_one_hash_param = ::setup(rng) - .unwrap() - .clone(); + let two_to_one_hash_param = ::setup(rng).unwrap(); let col_hash_params = ::setup(rng).unwrap(); let pp = L::setup::( max_degree, @@ -254,7 +252,7 @@ where let ext_mat_cols = ext_mat.cols(); let leaves: Vec = cfg_into_iter!(ext_mat_cols) .map(|col| { - H::evaluate(ck.col_hash_params(), col) + H::evaluate(ck.col_hash_params(), &col) .map_err(|_| Error::HashingError) .unwrap() }) @@ -349,7 +347,7 @@ where None }; - let point_vec = L::point_to_vec(point.clone()); + let point_vec = L::point_to_vec(point); sponge.absorb(&point_vec); proof_array.push(LinCodePCProof { @@ -415,7 +413,7 @@ where // 1. Seed the transcript with the point and the recieved vector // TODO Consider removing the evaluation point from the transcript. - let point_vec = L::point_to_vec(point.clone()); + let point_vec = L::point_to_vec(&point); sponge.absorb(&point_vec); sponge.absorb(&proof.opening.v); @@ -428,7 +426,7 @@ where .columns .iter() .map(|c| { - H::evaluate(vk.col_hash_params(), c.clone()) + H::evaluate(vk.col_hash_params(), c) .map_err(|_| Error::HashingError) .unwrap() .into() @@ -438,13 +436,13 @@ where // 4. Verify the paths for each of the leaf hashes - this is only run once, // even if we have a well-formedness check (i.e., we save sending and checking the columns). // See "Concrete optimizations to the commitment scheme", p.12 of [Brakedown](https://eprint.iacr.org/2021/1043.pdf). - for (j, (leaf, q_j)) in col_hashes.iter().zip(indices.iter()).enumerate() { + for (j, (leaf, q_j)) in col_hashes.into_iter().zip(indices.iter()).enumerate() { let path = &proof.opening.paths[j]; if path.leaf_index != *q_j { return Err(Error::InvalidCommitment); } - path.verify(leaf_hash_param, two_to_one_hash_param, root, leaf.clone()) + path.verify(leaf_hash_param, two_to_one_hash_param, root, leaf) .map_err(|_| Error::InvalidCommitment)?; } diff --git a/poly-commit/src/linear_codes/multilinear_brakedown/mod.rs b/poly-commit/src/linear_codes/multilinear_brakedown/mod.rs index bcfd9f0a..8785fb6c 100644 --- a/poly-commit/src/linear_codes/multilinear_brakedown/mod.rs +++ b/poly-commit/src/linear_codes/multilinear_brakedown/mod.rs @@ -92,7 +92,7 @@ where polynomial.to_evaluations() } - fn point_to_vec(point:

>::Point) -> Vec { + fn point_to_vec(point: &

>::Point) -> &Vec { point } @@ -103,7 +103,7 @@ where left_len: usize, _right_len: usize, ) -> (Vec, Vec) { - let point: Vec = Self::point_to_vec(point.clone()); + let point: &Vec = Self::point_to_vec(point); let split = log2(left_len) as usize; let left = &point[..split];