From 30aa3e2c88706e7f2c88d857843e90073152c273 Mon Sep 17 00:00:00 2001 From: Peter Nose Date: Mon, 21 Oct 2024 10:37:35 +0200 Subject: [PATCH] secret-sharing/src/churp/dealer: Limit loop for polynomial generation --- .changelog/5914.trivial.md | 0 secret-sharing/src/churp/dealer.rs | 4 +++- secret-sharing/src/churp/errors.rs | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 .changelog/5914.trivial.md diff --git a/.changelog/5914.trivial.md b/.changelog/5914.trivial.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/secret-sharing/src/churp/dealer.rs b/secret-sharing/src/churp/dealer.rs index aab3b9130d0..abe188b841a 100644 --- a/secret-sharing/src/churp/dealer.rs +++ b/secret-sharing/src/churp/dealer.rs @@ -138,7 +138,7 @@ where // should execute once with an extremely high probability, // so there is no need to optimize it by randomly selecting // only the problematic coefficients. - loop { + for _ in 0..5 { let bp = BivariatePolynomial::::random(deg_x, deg_y, rng); let i = deg_x as usize; @@ -154,6 +154,8 @@ where return Ok(bp); } + + Err(Error::PolynomialGenerationFailed.into()) } } diff --git a/secret-sharing/src/churp/errors.rs b/secret-sharing/src/churp/errors.rs index 6e4d4a9aa07..e362472bcc2 100644 --- a/secret-sharing/src/churp/errors.rs +++ b/secret-sharing/src/churp/errors.rs @@ -22,6 +22,8 @@ pub enum Error { MergingNotFinished, #[error("polynomial degree mismatch")] PolynomialDegreeMismatch, + #[error("polynomial generation failed")] + PolynomialGenerationFailed, #[error("shareholder encoding failed")] ShareholderEncodingFailed, #[error("shareholder proactivization already completed")]