mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2024-12-25 13:07:18 +00:00
bls: debugging utils and fake sig fix
There was a discrepancy between the is_empty fields of fake signatures during testing, so I've added a small hack to set the is_empty field of a fake signature based on the byte content. Alternatively, we could just make it so that any fake signature is defined to be equal to any other.
This commit is contained in:
parent
64dca6fba7
commit
88790e6abe
@ -1,5 +1,4 @@
|
||||
use super::{PublicKey, BLS_PUBLIC_KEY_BYTE_SIZE};
|
||||
use milagro_bls::AggregatePublicKey as RawAggregatePublicKey;
|
||||
|
||||
/// A BLS aggregate public key.
|
||||
///
|
||||
|
@ -1,6 +1,5 @@
|
||||
use super::{SecretKey, BLS_PUBLIC_KEY_BYTE_SIZE};
|
||||
use cached_tree_hash::cached_tree_hash_ssz_encoding_as_vector;
|
||||
use milagro_bls::PublicKey as RawPublicKey;
|
||||
use serde::de::{Deserialize, Deserializer};
|
||||
use serde::ser::{Serialize, Serializer};
|
||||
use serde_hex::{encode as hex_encode, HexVisitor};
|
||||
|
@ -59,9 +59,10 @@ impl FakeSignature {
|
||||
expected: BLS_SIG_BYTE_SIZE,
|
||||
})
|
||||
} else {
|
||||
let is_empty = bytes.iter().all(|x| *x == 0);
|
||||
Ok(Self {
|
||||
bytes: bytes.to_vec(),
|
||||
is_empty: false,
|
||||
is_empty,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -101,6 +101,12 @@ impl Signature {
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.is_empty
|
||||
}
|
||||
|
||||
/// Display a signature as a hex string of its bytes.
|
||||
#[cfg(test)]
|
||||
pub fn as_hex_string(&self) -> String {
|
||||
hex_encode(self.as_bytes())
|
||||
}
|
||||
}
|
||||
|
||||
impl_ssz!(Signature, BLS_SIG_BYTE_SIZE, "Signature");
|
||||
|
Loading…
Reference in New Issue
Block a user