mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 16:01:04 +00:00
Make BEEFY client keystore generic over BEEFY AuthorityId type (#2258)
This is the significant step to make BEEFY client able to handle both ECDSA and (ECDSA, BLS) type signature. The idea is having BEEFY Client generic on crypto types makes migration to new types smoother. This makes the BEEFY Keystore generic over AuthorityId and extends its tests to cover the case when the AuthorityId is of type (ECDSA, BLS12-377) --------- Co-authored-by: Davide Galassi <davxy@datawok.net> Co-authored-by: Robert Hambrock <roberthambrock@gmail.com>
This commit is contained in:
@@ -355,6 +355,24 @@ pub trait Keystore: Send + Sync {
|
||||
msg: &[u8],
|
||||
) -> Result<Option<ecdsa_bls377::Signature>, Error>;
|
||||
|
||||
/// Hashes the `message` using keccak256 and then signs it using ECDSA
|
||||
/// algorithm. It does not affect the behavior of BLS12-377 component. It generates
|
||||
/// BLS12-377 Signature according to IETF standard.
|
||||
///
|
||||
/// Receives [`KeyTypeId`] and a [`ecdsa_bls377::Public`] key to be able to map
|
||||
/// them to a private key that exists in the keystore.
|
||||
///
|
||||
/// Returns an [`ecdsa_bls377::Signature`] or `None` in case the given `key_type`
|
||||
/// and `public` combination doesn't exist in the keystore.
|
||||
/// An `Err` will be returned if generating the signature itself failed.
|
||||
#[cfg(feature = "bls-experimental")]
|
||||
fn ecdsa_bls377_sign_with_keccak256(
|
||||
&self,
|
||||
key_type: KeyTypeId,
|
||||
public: &ecdsa_bls377::Public,
|
||||
msg: &[u8],
|
||||
) -> Result<Option<ecdsa_bls377::Signature>, Error>;
|
||||
|
||||
/// Insert a new secret key.
|
||||
fn insert(&self, key_type: KeyTypeId, suri: &str, public: &[u8]) -> Result<(), ()>;
|
||||
|
||||
@@ -661,6 +679,16 @@ impl<T: Keystore + ?Sized> Keystore for Arc<T> {
|
||||
(**self).ecdsa_bls377_sign(key_type, public, msg)
|
||||
}
|
||||
|
||||
#[cfg(feature = "bls-experimental")]
|
||||
fn ecdsa_bls377_sign_with_keccak256(
|
||||
&self,
|
||||
key_type: KeyTypeId,
|
||||
public: &ecdsa_bls377::Public,
|
||||
msg: &[u8],
|
||||
) -> Result<Option<ecdsa_bls377::Signature>, Error> {
|
||||
(**self).ecdsa_bls377_sign_with_keccak256(key_type, public, msg)
|
||||
}
|
||||
|
||||
fn insert(&self, key_type: KeyTypeId, suri: &str, public: &[u8]) -> Result<(), ()> {
|
||||
(**self).insert(key_type, suri, public)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user