diff --git a/src/fec.rs b/src/fec.rs index 715ef2f832ed8cdc56bf118d29ea00b87835a62d..d41eb60c2cb2b61390ecd10a1f72c4c74350d438 100644 --- a/src/fec.rs +++ b/src/fec.rs @@ -31,14 +31,6 @@ pub struct Shard<F: PrimeField> { } impl<F: PrimeField> Shard<F> { - fn dual_combination(this: &Vec<F>, alpha: F, other: &Vec<F>, beta: F) -> Vec<F> { - this - .iter() - .zip(other.iter()) - .map(|(s, o)| s.mul(alpha) + o.mul(beta)) - .collect() - } - /// compute the linear combination between two [`Shard`]s /// /// if we denote the [`Shard`] itself and the other [`Shard`] by $s$ and $o$ respectively, the @@ -53,12 +45,23 @@ impl<F: PrimeField> Shard<F> { Shard { k: self.k, - linear_combination: Self::dual_combination(&self.linear_combination, alpha, &other.linear_combination, beta), + linear_combination: self + .linear_combination + .iter() + .zip(other.linear_combination.iter()) + .map(|(l, r)| l.mul(alpha) + r.mul(beta)) + .collect(), hash: self.hash.clone(), - data: Self::dual_combination(&self.data, alpha, &other.data, beta), + data: self + .data + .iter() + .zip(other.data.iter()) + .map(|(es, eo)| es.mul(alpha) + eo.mul(beta)) + .collect(), size: self.size, } } + } /// compute the linear combination between an arbitrary number of [`Shard`]s