diff --git a/beacon_chain/utils/bls/src/aggregate_signature.rs b/beacon_chain/utils/bls/src/aggregate_signature.rs index 90bf44702..6012f78c1 100644 --- a/beacon_chain/utils/bls/src/aggregate_signature.rs +++ b/beacon_chain/utils/bls/src/aggregate_signature.rs @@ -6,7 +6,7 @@ use bls_aggregates::AggregateSignature as RawAggregateSignature; /// /// This struct is a wrapper upon a base type and provides helper functions (e.g., SSZ /// serialization). -#[derive(Debug, PartialEq, Clone, Default)] +#[derive(Debug, PartialEq, Clone, Default, Eq)] pub struct AggregateSignature(RawAggregateSignature); impl AggregateSignature { diff --git a/beacon_chain/utils/bls/src/keypair.rs b/beacon_chain/utils/bls/src/keypair.rs index 51a61f8f7..1cce9c10e 100644 --- a/beacon_chain/utils/bls/src/keypair.rs +++ b/beacon_chain/utils/bls/src/keypair.rs @@ -1,6 +1,6 @@ use super::{PublicKey, SecretKey}; -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct Keypair { pub sk: SecretKey, pub pk: PublicKey, diff --git a/beacon_chain/utils/bls/src/public_key.rs b/beacon_chain/utils/bls/src/public_key.rs index 49dbc9e4b..62543589f 100644 --- a/beacon_chain/utils/bls/src/public_key.rs +++ b/beacon_chain/utils/bls/src/public_key.rs @@ -1,12 +1,13 @@ use super::SecretKey; use bls_aggregates::PublicKey as RawPublicKey; -use ssz::{decode_ssz_list, Decodable, DecodeError, Encodable, SszStream}; +use ssz::{decode_ssz_list, ssz_encode, Decodable, DecodeError, Encodable, SszStream}; +use std::hash::{Hash, Hasher}; /// A single BLS signature. /// /// This struct is a wrapper upon a base type and provides helper functions (e.g., SSZ /// serialization). -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Clone, Eq)] pub struct PublicKey(RawPublicKey); impl PublicKey { @@ -34,6 +35,12 @@ impl Decodable for PublicKey { } } +impl Hash for PublicKey { + fn hash(&self, state: &mut H) { + ssz_encode(self).hash(state) + } +} + #[cfg(test)] mod tests { use super::super::ssz::ssz_encode; diff --git a/beacon_chain/utils/bls/src/secret_key.rs b/beacon_chain/utils/bls/src/secret_key.rs index 7c4383695..e86e8dec0 100644 --- a/beacon_chain/utils/bls/src/secret_key.rs +++ b/beacon_chain/utils/bls/src/secret_key.rs @@ -5,7 +5,7 @@ use ssz::{decode_ssz_list, Decodable, DecodeError, Encodable, SszStream}; /// /// This struct is a wrapper upon a base type and provides helper functions (e.g., SSZ /// serialization). -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Clone, Eq)] pub struct SecretKey(RawSecretKey); impl SecretKey { diff --git a/beacon_chain/utils/bls/src/signature.rs b/beacon_chain/utils/bls/src/signature.rs index 242908e21..f70c5029e 100644 --- a/beacon_chain/utils/bls/src/signature.rs +++ b/beacon_chain/utils/bls/src/signature.rs @@ -6,7 +6,7 @@ use bls_aggregates::Signature as RawSignature; /// /// This struct is a wrapper upon a base type and provides helper functions (e.g., SSZ /// serialization). -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Clone, Eq)] pub struct Signature(RawSignature); impl Signature {