mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 23:21:06 +00:00
BEEFY: Define a BeefyVerify trait for signatures (#12299)
* Define CustomVerify trait Signed-off-by: Serban Iorga <serban@parity.io> * Use ECDSA CustomVerify for MultiSignature Signed-off-by: Serban Iorga <serban@parity.io> * beefy: small simplifications Signed-off-by: Serban Iorga <serban@parity.io> * Revert "Use ECDSA CustomVerify for MultiSignature" This reverts commit 136cff82505662dd92c864491814629d2bc349f0. * Revert "Define CustomVerify trait" This reverts commit adf91e9e6d1bdea6f00831f6067b74c3d945f9a2. * Define BeefyAuthorityId and BeefyVerify traits * Improve BeefyVerify unit tests Co-authored-by: Robert Hambrock <roberthambrock@gmail.com> * fmt & import sp_core::blake2_256 * Renamings * remove SignerToAccountId * fix Signed-off-by: Serban Iorga <serban@parity.io> Co-authored-by: Robert Hambrock <roberthambrock@gmail.com>
This commit is contained in:
@@ -19,12 +19,13 @@
|
||||
use sp_application_crypto::RuntimeAppPublic;
|
||||
use sp_core::keccak_256;
|
||||
use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr};
|
||||
use sp_runtime::traits::Keccak256;
|
||||
|
||||
use log::warn;
|
||||
|
||||
use beefy_primitives::{
|
||||
crypto::{Public, Signature},
|
||||
KEY_TYPE,
|
||||
BeefyVerify, KEY_TYPE,
|
||||
};
|
||||
|
||||
use crate::error;
|
||||
@@ -98,11 +99,7 @@ impl BeefyKeystore {
|
||||
///
|
||||
/// Return `true` if the signature is authentic, `false` otherwise.
|
||||
pub fn verify(public: &Public, sig: &Signature, message: &[u8]) -> bool {
|
||||
let msg = keccak_256(message);
|
||||
let sig = sig.as_ref();
|
||||
let public = public.as_ref();
|
||||
|
||||
sp_core::ecdsa::Pair::verify_prehashed(sig, &msg, public)
|
||||
BeefyVerify::<Keccak256>::verify(sig, message, public)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user