From 0381d676d52b101499fa2f60b2ac9c6562511992 Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Mon, 26 Jun 2023 15:25:04 +0200
Subject: [PATCH] remove enforcement on number of shares
---
ferveo-python/ferveo/__init__.py | 1 -
ferveo-python/ferveo/__init__.pyi | 4 ----
ferveo/src/bindings_python.rs | 8 --------
ferveo/src/dkg.rs | 12 ++----------
ferveo/src/lib.rs | 4 ----
ferveo/src/utils.rs | 4 ----
6 files changed, 2 insertions(+), 31 deletions(-)
diff --git a/ferveo-python/ferveo/__init__.py b/ferveo-python/ferveo/__init__.py
index fbaab504..3f0b872e 100644
--- a/ferveo-python/ferveo/__init__.py
+++ b/ferveo-python/ferveo/__init__.py
@@ -16,7 +16,6 @@
SharedSecret,
ValidatorMessage,
ThresholdEncryptionError,
- InvalidShareNumberParameter,
InvalidDkgStateToDeal,
InvalidDkgStateToAggregate,
InvalidDkgStateToVerify,
diff --git a/ferveo-python/ferveo/__init__.pyi b/ferveo-python/ferveo/__init__.pyi
index 170e98b0..bd0ecfa2 100644
--- a/ferveo-python/ferveo/__init__.pyi
+++ b/ferveo-python/ferveo/__init__.pyi
@@ -198,10 +198,6 @@ class ThresholdEncryptionError(Exception):
pass
-class InvalidShareNumberParameter(Exception):
- pass
-
-
class InvalidDkgStateToDeal(Exception):
pass
diff --git a/ferveo/src/bindings_python.rs b/ferveo/src/bindings_python.rs
index c324e76f..52782f1e 100644
--- a/ferveo/src/bindings_python.rs
+++ b/ferveo/src/bindings_python.rs
@@ -34,9 +34,6 @@ impl From for PyErr {
Error::ThresholdEncryptionError(err) => {
ThresholdEncryptionError::new_err(err.to_string())
}
- Error::InvalidShareNumberParameter(actual) => {
- InvalidShareNumberParameter::new_err(actual.to_string())
- }
Error::InvalidDkgStateToDeal => {
InvalidDkgStateToDeal::new_err("")
}
@@ -111,7 +108,6 @@ impl Debug for FerveoPythonError {
}
create_exception!(exceptions, ThresholdEncryptionError, PyException);
-create_exception!(exceptions, InvalidShareNumberParameter, PyValueError);
create_exception!(exceptions, InvalidDkgStateToDeal, PyRuntimeError);
create_exception!(exceptions, InvalidDkgStateToAggregate, PyRuntimeError);
create_exception!(exceptions, InvalidDkgStateToVerify, PyRuntimeError);
@@ -593,10 +589,6 @@ pub fn make_ferveo_py_module(py: Python<'_>, m: &PyModule) -> PyResult<()> {
"ThresholdEncryptionError",
py.get_type::(),
)?;
- m.add(
- "InvalidShareNumberParameter",
- py.get_type::(),
- )?;
m.add(
"InvalidDkgStateToDeal",
py.get_type::(),
diff --git a/ferveo/src/dkg.rs b/ferveo/src/dkg.rs
index 9607718f..666e68df 100644
--- a/ferveo/src/dkg.rs
+++ b/ferveo/src/dkg.rs
@@ -9,10 +9,8 @@ use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde_with::serde_as;
use crate::{
- aggregate,
- utils::{is_power_of_2, is_sorted},
- AggregatedPvss, Error, EthereumAddress, PubliclyVerifiableParams,
- PubliclyVerifiableSS, Pvss, Result, Validator,
+ aggregate, utils::is_sorted, AggregatedPvss, Error, EthereumAddress,
+ PubliclyVerifiableParams, PubliclyVerifiableSS, Pvss, Result, Validator,
};
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
@@ -78,12 +76,6 @@ impl PubliclyVerifiableDkg {
dkg_params: &DkgParams,
me: &Validator,
) -> Result {
- // Make sure that the number of shares is a power of 2 for the FFT to work (Radix-2 FFT domain is being used)
- if !is_power_of_2(dkg_params.shares_num) {
- return Err(Error::InvalidShareNumberParameter(
- dkg_params.shares_num,
- ));
- }
let domain =
ark_poly::MixedRadixEvaluationDomain::::new(
dkg_params.shares_num as usize,
diff --git a/ferveo/src/lib.rs b/ferveo/src/lib.rs
index 7e1b3657..c520b3f3 100644
--- a/ferveo/src/lib.rs
+++ b/ferveo/src/lib.rs
@@ -31,10 +31,6 @@ pub enum Error {
#[error(transparent)]
ThresholdEncryptionError(#[from] tpke::Error),
- /// Number of shares parameter must be a power of two
- #[error("Number of shares parameter must be a power of two. Got {0}")]
- InvalidShareNumberParameter(u32),
-
/// DKG is not in a valid state to deal PVSS shares
#[error("Invalid DKG state to deal PVSS shares")]
InvalidDkgStateToDeal,
diff --git a/ferveo/src/utils.rs b/ferveo/src/utils.rs
index 62277430..b8b67b10 100644
--- a/ferveo/src/utils.rs
+++ b/ferveo/src/utils.rs
@@ -1,7 +1,3 @@
-pub fn is_power_of_2(n: u32) -> bool {
- n != 0 && (n & (n - 1)) == 0
-}
-
pub fn is_sorted(data: I) -> bool
where
I: IntoIterator,