Add new tree_hash crate project wide.

This commit is contained in:
Paul Hauner
2019-04-16 14:25:43 +10:00
parent b8c4c3308a
commit f69b56ad60
13 changed files with 18 additions and 17 deletions

View File

@@ -5,7 +5,8 @@ use bls_aggregates::{
use serde::de::{Deserialize, Deserializer};
use serde::ser::{Serialize, Serializer};
use serde_hex::{encode as hex_encode, HexVisitor};
use ssz::{decode, hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::{decode, Decodable, DecodeError, Encodable, SszStream};
use tree_hash::impl_tree_hash_for_ssz_bytes;
/// A BLS aggregate signature.
///
@@ -165,11 +166,7 @@ impl<'de> Deserialize<'de> for AggregateSignature {
}
}
impl TreeHash for AggregateSignature {
fn tree_hash_root(&self) -> Vec<u8> {
hash(&self.as_bytes())
}
}
impl_tree_hash_for_ssz_bytes!(AggregateSignature);
#[cfg(test)]
mod tests {

View File

@@ -4,7 +4,8 @@ use hex::encode as hex_encode;
use serde::de::{Deserialize, Deserializer};
use serde::ser::{Serialize, Serializer};
use serde_hex::HexVisitor;
use ssz::{decode, hash, ssz_encode, Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::{decode, ssz_encode, Decodable, DecodeError, Encodable, SszStream};
use tree_hash::impl_tree_hash_for_ssz_bytes;
/// A single BLS signature.
///
@@ -114,11 +115,7 @@ impl Decodable for Signature {
}
}
impl TreeHash for Signature {
fn tree_hash_root(&self) -> Vec<u8> {
hash(&self.as_bytes())
}
}
impl_tree_hash_for_ssz_bytes!(Signature);
impl Serialize for Signature {
/// Serde serialization is compliant the Ethereum YAML test format.