From f551579e328409a6360ca2a01dfe59854de0e5a2 Mon Sep 17 00:00:00 2001 From: Daniel Knopik Date: Wed, 15 Jan 2025 13:35:40 +0100 Subject: [PATCH] add `deserialize_uncompressed` to `GenericSignature` --- crypto/bls/src/generic_signature.rs | 3 +++ crypto/bls/src/impls/blst.rs | 4 ++++ crypto/bls/src/impls/fake_crypto.rs | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/crypto/bls/src/generic_signature.rs b/crypto/bls/src/generic_signature.rs index 4bb9c1597b..e0a5ff6cdc 100644 --- a/crypto/bls/src/generic_signature.rs +++ b/crypto/bls/src/generic_signature.rs @@ -40,6 +40,9 @@ pub trait TSignature: Sized + Clone { /// Deserialize `self` from compressed bytes. fn deserialize(bytes: &[u8]) -> Result; + /// Serialize `self` from uncompressed bytes. + fn deserialize_uncompressed(bytes: &[u8]) -> Result; + /// Returns `true` if `self` is a signature across `msg` by `pubkey`. fn verify(&self, pubkey: &GenericPublicKey, msg: Hash256) -> bool; } diff --git a/crypto/bls/src/impls/blst.rs b/crypto/bls/src/impls/blst.rs index 1937247a4f..aef1e9695c 100644 --- a/crypto/bls/src/impls/blst.rs +++ b/crypto/bls/src/impls/blst.rs @@ -198,6 +198,10 @@ impl TSignature for blst_core::Signature { Self::from_bytes(bytes).map_err(Into::into) } + fn deserialize_uncompressed(bytes: &[u8]) -> Result { + Self::deserialize(bytes).map_err(Into::into) + } + fn verify(&self, pubkey: &blst_core::PublicKey, msg: Hash256) -> bool { // Public keys have already been checked for subgroup and infinity // Check Signature inside function for subgroup diff --git a/crypto/bls/src/impls/fake_crypto.rs b/crypto/bls/src/impls/fake_crypto.rs index f0884e0e6b..b2ac208da8 100644 --- a/crypto/bls/src/impls/fake_crypto.rs +++ b/crypto/bls/src/impls/fake_crypto.rs @@ -119,6 +119,10 @@ impl TSignature for Signature { Ok(signature) } + fn deserialize_uncompressed(bytes: &[u8]) -> Result { + Self::deserialize(bytes) + } + fn verify(&self, _pubkey: &PublicKey, _msg: Hash256) -> bool { true }