sp_application_crypto/
bls381.rs1use crate::{KeyTypeId, RuntimePublic};
20
21use alloc::vec::Vec;
22
23pub use sp_core::bls::bls381::*;
24use sp_core::{crypto::CryptoType, proof_of_possession::ProofOfPossessionVerifier};
25
26mod app {
27 crate::app_crypto!(super, sp_core::testing::BLS381);
28}
29
30#[cfg(feature = "full_crypto")]
31pub use app::Pair as AppPair;
32pub use app::{Public as AppPublic, Signature as AppSignature};
33
34impl RuntimePublic for Public {
35 type Signature = Signature;
36
37 fn all(_key_type: KeyTypeId) -> Vec<Self> {
39 Vec::new()
40 }
41
42 fn generate_pair(key_type: KeyTypeId, seed: Option<Vec<u8>>) -> Self {
43 sp_io::crypto::bls381_generate(key_type, seed)
44 }
45
46 fn sign<M: AsRef<[u8]>>(&self, _key_type: KeyTypeId, _msg: &M) -> Option<Self::Signature> {
48 None
49 }
50
51 fn verify<M: AsRef<[u8]>>(&self, _msg: &M, _signature: &Self::Signature) -> bool {
53 false
54 }
55
56 fn generate_proof_of_possession(&mut self, key_type: KeyTypeId) -> Option<Self::Signature> {
57 sp_io::crypto::bls381_generate_proof_of_possession(key_type, self)
58 }
59
60 fn verify_proof_of_possession(&self, proof_of_possession: &Self::Signature) -> bool {
61 let proof_of_possession = AppSignature::from(*proof_of_possession);
62 let pub_key = AppPublic::from(*self);
63 <AppPublic as CryptoType>::Pair::verify_proof_of_possession(&proof_of_possession, &pub_key)
64 }
65
66 fn to_raw_vec(&self) -> Vec<u8> {
67 sp_core::crypto::ByteArray::to_raw_vec(self)
68 }
69}