mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 12:48:00 +00:00
Added RuntimePublic for ecdsa public key. (#6029)
* add generate ecdsa, etc to keystore * impl ecdsa needed traits * add ecdsa to sr_io * add ecdsa to application-crypto * add ecdsa to test-utils * add ecdsa debug derive * fix ecdsa public
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
|
||||
//! Batch/parallel verification.
|
||||
|
||||
use sp_core::{ed25519, sr25519, crypto::Pair, traits::CloneableSpawn};
|
||||
use sp_core::{ed25519, sr25519, ecdsa, crypto::Pair, traits::CloneableSpawn};
|
||||
use std::sync::{Arc, atomic::{AtomicBool, Ordering as AtomicOrdering}};
|
||||
use futures::{future::FutureExt, task::FutureObj, channel::oneshot};
|
||||
|
||||
@@ -124,6 +124,29 @@ impl BatchVerifier {
|
||||
true
|
||||
}
|
||||
|
||||
/// Push ecdsa signature to verify.
|
||||
///
|
||||
/// Returns false if some of the pushed signatures before already failed the check
|
||||
/// (in this case it won't verify anything else)
|
||||
pub fn push_ecdsa(
|
||||
&mut self,
|
||||
signature: ecdsa::Signature,
|
||||
pub_key: ecdsa::Public,
|
||||
message: Vec<u8>,
|
||||
) -> bool {
|
||||
if self.invalid.load(AtomicOrdering::Relaxed) { return false; }
|
||||
|
||||
if self.spawn_verification_task(move || ecdsa::Pair::verify(&signature, &message, &pub_key)).is_err() {
|
||||
log::debug!(
|
||||
target: "runtime",
|
||||
"Batch-verification returns false because failed to spawn background task.",
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
fn verify_sr25519_batch(items: Vec<Sr25519BatchItem>) -> bool {
|
||||
let messages = items.iter().map(|item| &item.message[..]).collect();
|
||||
let signatures = items.iter().map(|item| &item.signature).collect();
|
||||
|
||||
Reference in New Issue
Block a user