Fix SSZ for bls fake_crypto features

This commit is contained in:
Paul Hauner
2019-05-13 12:23:06 +10:00
parent eb62b5842d
commit 03fee2fb97
2 changed files with 38 additions and 2 deletions

View File

@@ -3,7 +3,7 @@ use cached_tree_hash::cached_tree_hash_ssz_encoding_as_vector;
use serde::de::{Deserialize, Deserializer};
use serde::ser::{Serialize, Serializer};
use serde_hex::{encode as hex_encode, PrefixedHexVisitor};
use ssz::{ssz_encode, Decodable, DecodeError, Encodable};
use ssz::{ssz_encode, Decodable, DecodeError};
use tree_hash::tree_hash_ssz_encoding_as_vector;
/// A BLS aggregate signature.
@@ -57,6 +57,24 @@ impl FakeAggregateSignature {
) -> bool {
true
}
/// Convert bytes to fake BLS aggregate signature
pub fn from_bytes(bytes: &[u8]) -> Result<Self, DecodeError> {
if bytes.len() != BLS_AGG_SIG_BYTE_SIZE {
Err(DecodeError::InvalidByteLength {
len: bytes.len(),
expected: BLS_AGG_SIG_BYTE_SIZE,
})
} else {
Ok(Self {
bytes: bytes.to_vec(),
})
}
}
pub fn as_bytes(&self) -> Vec<u8> {
self.bytes.clone()
}
}
impl_ssz!(