diff --git a/poly-commit/src/linear_codes/mod.rs b/poly-commit/src/linear_codes/mod.rs index 91181311..f710bc0f 100644 --- a/poly-commit/src/linear_codes/mod.rs +++ b/poly-commit/src/linear_codes/mod.rs @@ -392,6 +392,27 @@ where let two_to_one_hash_param: &<::TwoToOneHash as TwoToOneCRHScheme>::Parameters = vk.two_to_one_hash_param(); + // We need to collect so that we can both check the lengths and iterate. + let commitments: Vec<&LabeledCommitment> = + commitments.into_iter().collect(); + let values: Vec = values.into_iter().collect(); + + if commitments.len() != proof_array.len() { + return Err(Error::IncorrectInputLength(format!( + "commitments {}, but proof_array has length {}", + commitments.len(), + proof_array.len() + ))); + } + + if commitments.len() != values.len() { + return Err(Error::IncorrectInputLength(format!( + "commitments {}, but values has length {}", + commitments.len(), + values.len() + ))); + } + for (i, (labeled_commitment, value)) in commitments.into_iter().zip(values).enumerate() { let proof = &proof_array[i]; let commitment = labeled_commitment.commitment();