Add Eq traits for BLS newtypes
This commit is contained in:
parent
3891a6017a
commit
c9aaf4f1ca
@ -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
|
/// This struct is a wrapper upon a base type and provides helper functions (e.g., SSZ
|
||||||
/// serialization).
|
/// serialization).
|
||||||
#[derive(Debug, PartialEq, Clone, Default)]
|
#[derive(Debug, PartialEq, Clone, Default, Eq)]
|
||||||
pub struct AggregateSignature(RawAggregateSignature);
|
pub struct AggregateSignature(RawAggregateSignature);
|
||||||
|
|
||||||
impl AggregateSignature {
|
impl AggregateSignature {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use super::{PublicKey, SecretKey};
|
use super::{PublicKey, SecretKey};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct Keypair {
|
pub struct Keypair {
|
||||||
pub sk: SecretKey,
|
pub sk: SecretKey,
|
||||||
pub pk: PublicKey,
|
pub pk: PublicKey,
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
use super::SecretKey;
|
use super::SecretKey;
|
||||||
use bls_aggregates::PublicKey as RawPublicKey;
|
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.
|
/// A single BLS signature.
|
||||||
///
|
///
|
||||||
/// This struct is a wrapper upon a base type and provides helper functions (e.g., SSZ
|
/// This struct is a wrapper upon a base type and provides helper functions (e.g., SSZ
|
||||||
/// serialization).
|
/// serialization).
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone, Eq)]
|
||||||
pub struct PublicKey(RawPublicKey);
|
pub struct PublicKey(RawPublicKey);
|
||||||
|
|
||||||
impl PublicKey {
|
impl PublicKey {
|
||||||
@ -34,6 +35,12 @@ impl Decodable for PublicKey {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Hash for PublicKey {
|
||||||
|
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||||
|
ssz_encode(self).hash(state)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::super::ssz::ssz_encode;
|
use super::super::ssz::ssz_encode;
|
||||||
|
@ -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
|
/// This struct is a wrapper upon a base type and provides helper functions (e.g., SSZ
|
||||||
/// serialization).
|
/// serialization).
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone, Eq)]
|
||||||
pub struct SecretKey(RawSecretKey);
|
pub struct SecretKey(RawSecretKey);
|
||||||
|
|
||||||
impl SecretKey {
|
impl SecretKey {
|
||||||
|
@ -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
|
/// This struct is a wrapper upon a base type and provides helper functions (e.g., SSZ
|
||||||
/// serialization).
|
/// serialization).
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone, Eq)]
|
||||||
pub struct Signature(RawSignature);
|
pub struct Signature(RawSignature);
|
||||||
|
|
||||||
impl Signature {
|
impl Signature {
|
||||||
|
Loading…
Reference in New Issue
Block a user