Skip to content

Commit

Permalink
remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec committed Jan 20, 2023
1 parent 8bd2888 commit 002d407
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 50 deletions.
44 changes: 1 addition & 43 deletions ferveo-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ use ark_serialize::{

pub mod keypair;
pub use keypair::*;
use std::cmp::Ordering;

#[derive(Clone, Debug, CanonicalSerialize, CanonicalDeserialize)]
#[derive(Clone, Debug, CanonicalSerialize, CanonicalDeserialize, PartialEq)]
/// Represents an external validator
pub struct ExternalValidator<E: PairingEngine> {
/// The established address of the validator
Expand All @@ -17,53 +16,12 @@ pub struct ExternalValidator<E: PairingEngine> {
pub public_key: PublicKey<E>,
}

impl<E: PairingEngine> PartialEq for ExternalValidator<E> {
fn eq(&self, other: &Self) -> bool {
(&self.address) == (&other.address)
}
}

impl<E: PairingEngine> Eq for ExternalValidator<E> {}

impl<E: PairingEngine> PartialOrd for ExternalValidator<E> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.address.cmp(&other.address))
}
}

impl<E: PairingEngine> Ord for ExternalValidator<E> {
fn cmp(&self, other: &Self) -> Ordering {
self.address.cmp(&other.address)
}
}

#[derive(Clone, Debug, CanonicalSerialize, CanonicalDeserialize)]
pub struct Validator<E: PairingEngine> {
pub validator: ExternalValidator<E>,
pub share_index: usize,
}

impl<E: PairingEngine> PartialEq for Validator<E> {
fn eq(&self, other: &Self) -> bool {
(&self.validator, self.share_index)
== (&other.validator, other.share_index)
}
}

impl<E: PairingEngine> Eq for Validator<E> {}

impl<E: PairingEngine> PartialOrd for Validator<E> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.validator.cmp(&other.validator))
}
}

impl<E: PairingEngine> Ord for Validator<E> {
fn cmp(&self, other: &Self) -> Ordering {
self.validator.cmp(&other.validator)
}
}

impl Rng for ark_std::rand::prelude::StdRng {}

pub trait Rng: ark_std::rand::CryptoRng + ark_std::rand::RngCore {}
Expand Down
2 changes: 1 addition & 1 deletion ferveo/benches/benchmarks/pvdkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub fn setup_dkg(
shares_num: 4,
retry_after: 2,
},
me,
&me,
keypairs[validator],
)
.expect("Setup failed")
Expand Down
2 changes: 1 addition & 1 deletion ferveo/examples/pvdkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub fn setup_dkg(
shares_num: shares,
retry_after: 1,
},
me,
&me,
keypairs[validator],
)
.expect("Setup failed")
Expand Down
10 changes: 5 additions & 5 deletions ferveo/src/dkg/pv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl<E: PairingEngine> PubliclyVerifiableDkg<E> {
pub fn new(
validators: Vec<ExternalValidator<E>>,
params: Params,
me: ExternalValidator<E>,
me: &ExternalValidator<E>,
session_keypair: ferveo_common::Keypair<E>,
) -> Result<Self> {
use ark_std::UniformRand;
Expand All @@ -45,7 +45,7 @@ impl<E: PairingEngine> PubliclyVerifiableDkg<E> {
// keep track of the owner of this instance in the validator set
let me = validators
.iter()
.position(|probe| me.address == probe.address)
.position(|probe| me == probe)
.context(
"could not find this validator in the provided validator set",
)?;
Expand Down Expand Up @@ -158,7 +158,7 @@ impl<E: PairingEngine> PubliclyVerifiableDkg<E> {
// an address keyed hashmap after partitioning the shares shares
// in the [`new`] method
let sender = self.validators
.iter().position(|probe| sender.address == probe.validator.address)
.iter().position(|probe| sender == &probe.validator)
.context("dkg received unknown dealer")?;
if self.vss.contains_key(&(sender as u32)) {
Err(anyhow!("Repeat dealer {}", sender))
Expand Down Expand Up @@ -310,7 +310,7 @@ pub(crate) mod test_common {
shares_num,
retry_after: 2,
},
me,
&me,
keypairs[my_index],
)
.expect("Setup failed")
Expand Down Expand Up @@ -395,7 +395,7 @@ mod test_dkg_init {
shares_num: 8,
retry_after: 2,
},
ExternalValidator::<EllipticCurve> {
&ExternalValidator::<EllipticCurve> {
address: "non-existant-validator".into(),
public_key: keypair.public(),
},
Expand Down

0 comments on commit 002d407

Please sign in to comment.