Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ impl LagrangeCoefficients {
// Compute the value at 0 of the i-th Lagrange polynomial that is `0` at the
// other data points but `1` at `x_i`.
let mut denom = Scalar::one();
let x_i = samples[i].clone();
for x_j in samples.iter().filter(|x_j| **x_j != x_i) {
denom *= x_j - &x_i;
for (j, x_j) in samples.iter().enumerate() {
if j != i {
denom *= x_j - &samples[i];
}
}

denominator.push(denom);
Expand Down Expand Up @@ -152,6 +153,11 @@ impl LagrangeCoefficients {
&self.coefficients
}

/// Return the Lagrange coefficients, consuming self
pub fn into_coefficients(self) -> Vec<Scalar> {
self.coefficients
}

/// Given a list of samples `(x, f(x) * g)` for a set of unique `x`, some
/// polynomial `f`, and some integer `g`, returns `f(value) * g`.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,7 @@ fn compute_transcript(
let indices = NodeIndices::from_slice(&reshare_x)
.expect("Cannot fail because all x are distinct.");

LagrangeCoefficients::at_zero(&indices)
.coefficients()
.to_vec()
LagrangeCoefficients::at_zero(&indices).into_coefficients()
};

let mut combined = vec![];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,7 @@ impl PublicCoefficients {

let indices = NodeIndices::from_slice(samples).map_err(|_| ThresholdError::DuplicateX)?;

Ok(LagrangeCoefficients::at_zero(&indices)
.coefficients()
.to_vec())
Ok(LagrangeCoefficients::at_zero(&indices).into_coefficients())
}
}

Expand Down
Loading