Finalise bls spec tests

This commit is contained in:
Kirk Baird
2019-05-21 12:46:22 +10:00
parent 6bab62e629
commit 7a96ad130e
10 changed files with 295 additions and 55 deletions

View File

@@ -16,7 +16,7 @@ use tree_hash::tree_hash_ssz_encoding_as_vector;
/// serialization).
#[derive(Debug, Clone, Eq)]
pub struct FakePublicKey {
bytes: Vec<u8>
bytes: Vec<u8>,
}
impl FakePublicKey {
@@ -34,14 +34,14 @@ impl FakePublicKey {
/// Returns the underlying point as compressed bytes.
///
/// Identical to `self.as_uncompressed_bytes()`.
fn as_bytes(&self) -> Vec<u8> {
pub fn as_bytes(&self) -> Vec<u8> {
self.bytes.clone()
}
/// Converts compressed bytes to FakePublicKey
pub fn from_bytes(bytes: &[u8]) -> Result<Self, DecodeError> {
Ok(Self {
bytes: bytes.to_vec()
bytes: bytes.to_vec(),
})
}
@@ -63,6 +63,11 @@ impl FakePublicKey {
let end_bytes = &bytes[bytes.len().saturating_sub(6)..bytes.len()];
hex_encode(end_bytes)
}
// Returns itself
pub fn as_raw(&self) -> &Self {
self
}
}
impl fmt::Display for FakePublicKey {