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
+21
View File
@@ -142,6 +142,15 @@ impl CryptoStore for LocalKeystore {
) -> std::result::Result<Option<VRFSignature>, TraitError> {
SyncCryptoStore::sr25519_vrf_sign(self, key_type, public, transcript_data)
}
async fn ecdsa_sign_prehashed(
&self,
id: KeyTypeId,
public: &ecdsa::Public,
msg: &[u8; 32],
) -> std::result::Result<Option<ecdsa::Signature>, TraitError> {
SyncCryptoStore::ecdsa_sign_prehashed(self, id, public, msg)
}
}
impl SyncCryptoStore for LocalKeystore {
@@ -301,6 +310,18 @@ impl SyncCryptoStore for LocalKeystore {
Ok(None)
}
}
fn ecdsa_sign_prehashed(
&self,
id: KeyTypeId,
public: &ecdsa::Public,
msg: &[u8; 32],
) -> std::result::Result<Option<ecdsa::Signature>, TraitError> {
let pair = self.0.read()
.key_pair_by_type::<ecdsa::Pair>(public, id)?;
pair.map(|k| k.sign_prehashed(msg)).map(Ok).transpose()
}
}
impl Into<SyncCryptoStorePtr> for LocalKeystore {