Skip to content

Commit

Permalink
Remove obsolete conversion i32->NiDkgTag
Browse files Browse the repository at this point in the history
  • Loading branch information
fspreiss committed Nov 5, 2024
1 parent c51dc23 commit fce1c63
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 52 deletions.
13 changes: 0 additions & 13 deletions rs/types/types/src/crypto/threshold_sig/ni_dkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,6 @@ impl fmt::Display for NiDkgTargetSubnet {
// }
// }

////////////////////
// TODO: check if we still need this
////////////////////////
impl From<&NiDkgTag> for i32 {
fn from(ni_dkg_tag: &NiDkgTag) -> Self {
match ni_dkg_tag {
NiDkgTag::LowThreshold => 1,
NiDkgTag::HighThreshold => 2,
NiDkgTag::HighThresholdForKey(_) => 3,
}
}
}

/// A dealer's contribution (called dealing) to distributed key generation.
#[derive(Clone, Eq, PartialEq, Hash, Debug, Deserialize, Serialize)]
pub struct NiDkgDealing {
Expand Down
39 changes: 0 additions & 39 deletions rs/types/types/src/crypto/threshold_sig/ni_dkg/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ use ic_crypto_internal_types::sign::threshold_sig::ni_dkg::ni_dkg_groth20_bls12_
Dealing, EncryptedShares, PublicCoefficientsBytes, ZKProofDec, ZKProofShare, NUM_CHUNKS,
NUM_ZK_REPETITIONS,
};
use ic_management_canister_types::{
EcdsaCurve, EcdsaKeyId, SchnorrAlgorithm, SchnorrKeyId, VetKdCurve, VetKdKeyId,
};
use strum::EnumCount;
use strum::IntoEnumIterator;

#[test]
fn should_correctly_convert_csp_dkg_dealing_to_dkg_dealing() {
Expand Down Expand Up @@ -306,37 +301,3 @@ fn empty_ni_csp_dkg_transcript() -> CspNiDkgTranscript {
receiver_data: Default::default(),
})
}

#[test]
fn should_correctly_convert_ni_dkg_tag_to_i32() {
assert_eq!(i32::from(&NiDkgTag::LowThreshold), 1);
assert_eq!(i32::from(&NiDkgTag::HighThreshold), 2);

for master_public_key_id in [
MasterPublicKeyId::Ecdsa(EcdsaKeyId {
curve: EcdsaCurve::Secp256k1,
name: "some key".to_string(),
}),
MasterPublicKeyId::Schnorr(SchnorrKeyId {
algorithm: SchnorrAlgorithm::Bip340Secp256k1,
name: "some key".to_string(),
}),
MasterPublicKeyId::Schnorr(SchnorrKeyId {
algorithm: SchnorrAlgorithm::Ed25519,
name: "some key".to_string(),
}),
MasterPublicKeyId::VetKd(VetKdKeyId {
curve: VetKdCurve::Bls12_381_G2,
name: "some key".to_string(),
}),
] {
assert_eq!(
i32::from(&NiDkgTag::HighThresholdForKey(master_public_key_id)),
3
);
}
assert_eq!(MasterPublicKeyId::COUNT, 3);
assert_eq!(EcdsaCurve::iter().count(), 1);
assert_eq!(SchnorrAlgorithm::iter().count(), 2);
assert_eq!(VetKdCurve::iter().count(), 1);
}

0 comments on commit fce1c63

Please sign in to comment.