Add CryptoStore::ecdsa_sign_prehashed() (#8838)

* Pair::sign_prehashed()

* add CryptoStore::ecdsa_sign_prehashed()

* add test for testing keystore

* address review comments
This commit is contained in:
Andreas Doerr
2021-05-18 16:07:45 +02:00
committed by GitHub
parent b5f23bfd1c
commit ed39290f91
4 changed files with 122 additions and 2 deletions
+28
View File
@@ -194,6 +194,20 @@ pub trait CryptoStore: Send + Sync {
public: &sr25519::Public,
transcript_data: VRFTranscriptData,
) -> Result<Option<VRFSignature>, Error>;
/// Sign pre-hashed
///
/// Signs a pre-hashed message with the private key that matches
/// the ECDSA public key passed.
///
/// Returns the SCALE encoded signature if key is found and supported,
/// `None` if the key doesn't exist or an error when something failed.
async fn ecdsa_sign_prehashed(
&self,
id: KeyTypeId,
public: &ecdsa::Public,
msg: &[u8; 32],
) -> Result<Option<ecdsa::Signature>, Error>;
}
/// Sync version of the CryptoStore
@@ -353,6 +367,20 @@ pub trait SyncCryptoStore: CryptoStore + Send + Sync {
public: &sr25519::Public,
transcript_data: VRFTranscriptData,
) -> Result<Option<VRFSignature>, Error>;
/// Sign pre-hashed
///
/// Signs a pre-hashed message with the private key that matches
/// the ECDSA public key passed.
///
/// Returns the SCALE encoded signature if key is found and supported,
/// `None` if the key doesn't exist or an error when something failed.
fn ecdsa_sign_prehashed(
&self,
id: KeyTypeId,
public: &ecdsa::Public,
msg: &[u8; 32],
) -> Result<Option<ecdsa::Signature>, Error>;
}
/// A pointer to a keystore.