Skip to content

Commit

Permalink
remove enforcement on number of shares
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec committed Jun 26, 2023
1 parent 339bd63 commit 0381d67
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 31 deletions.
1 change: 0 additions & 1 deletion ferveo-python/ferveo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
SharedSecret,
ValidatorMessage,
ThresholdEncryptionError,
InvalidShareNumberParameter,
InvalidDkgStateToDeal,
InvalidDkgStateToAggregate,
InvalidDkgStateToVerify,
Expand Down
4 changes: 0 additions & 4 deletions ferveo-python/ferveo/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,6 @@ class ThresholdEncryptionError(Exception):
pass


class InvalidShareNumberParameter(Exception):
pass


class InvalidDkgStateToDeal(Exception):
pass

Expand Down
8 changes: 0 additions & 8 deletions ferveo/src/bindings_python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ impl From<FerveoPythonError> 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("")
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -593,10 +589,6 @@ pub fn make_ferveo_py_module(py: Python<'_>, m: &PyModule) -> PyResult<()> {
"ThresholdEncryptionError",
py.get_type::<ThresholdEncryptionError>(),
)?;
m.add(
"InvalidShareNumberParameter",
py.get_type::<InvalidShareNumberParameter>(),
)?;
m.add(
"InvalidDkgStateToDeal",
py.get_type::<InvalidDkgStateToDeal>(),
Expand Down
12 changes: 2 additions & 10 deletions ferveo/src/dkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -78,12 +76,6 @@ impl<E: Pairing> PubliclyVerifiableDkg<E> {
dkg_params: &DkgParams,
me: &Validator<E>,
) -> Result<Self> {
// 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::<E::ScalarField>::new(
dkg_params.shares_num as usize,
Expand Down
4 changes: 0 additions & 4 deletions ferveo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 0 additions & 4 deletions ferveo/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
pub fn is_power_of_2(n: u32) -> bool {
n != 0 && (n & (n - 1)) == 0
}

pub fn is_sorted<I>(data: I) -> bool
where
I: IntoIterator,
Expand Down

0 comments on commit 0381d67

Please sign in to comment.