diff --git a/client-keystore/src/lib.rs b/client-keystore/src/lib.rs index 7083beeae..378e72bb2 100644 --- a/client-keystore/src/lib.rs +++ b/client-keystore/src/lib.rs @@ -22,9 +22,10 @@ use parking_lot::RwLock; use sp_application_crypto::{AppCrypto, AppPair, IsWrappedBy}; use sp_core::{ - crypto::{ByteArray, ExposeSecret, KeyTypeId, Pair as CorePair, SecretString, VrfSecret}, + crypto::{ByteArray, ExposeSecret, KeyTypeId, Pair as CorePair, SecretString, VrfSigner}, ecdsa, ed25519, sr25519, }; +use sp_keystore::{Error as TraitError, Keystore, KeystorePtr}; use std::{ collections::HashMap, fs::{self, File}, @@ -37,7 +38,6 @@ use sc_keystore::{Error, Result}; mod keystore_ext; pub use keystore_ext::KeystoreExt; -pub use sp_keystore::{Error as TraitError, Keystore, KeystorePtr}; /// A local based keystore that is either memory-based or filesystem-based. pub struct LocalKeystore(RwLock); @@ -103,33 +103,19 @@ impl LocalKeystore { Ok(signature) } - fn vrf_sign( + fn vrf_sign( &self, key_type: KeyTypeId, public: &T::Public, - data: &T::VrfSignData, + transcript: &T::VrfInput, ) -> std::result::Result, TraitError> { let sig = self .0 .read() .key_pair_by_type::(public, key_type)? - .map(|pair| pair.vrf_sign(data)); + .map(|pair| pair.vrf_sign(transcript)); Ok(sig) } - - fn vrf_output( - &self, - key_type: KeyTypeId, - public: &T::Public, - input: &T::VrfInput, - ) -> std::result::Result, TraitError> { - let preout = self - .0 - .read() - .key_pair_by_type::(public, key_type)? - .map(|pair| pair.vrf_output(input)); - Ok(preout) - } } impl Keystore for LocalKeystore { @@ -139,7 +125,7 @@ impl Keystore for LocalKeystore { /// Generate a new pair compatible with the 'ed25519' signature scheme. /// - /// If `[seed]` is `Some` then the key will be ephemeral and stored in memory. + /// If the `[seed]` is `Some` then the key will be ephemeral and stored in memory. fn sr25519_generate_new( &self, key_type: KeyTypeId, @@ -161,18 +147,9 @@ impl Keystore for LocalKeystore { &self, key_type: KeyTypeId, public: &sr25519::Public, - data: &sr25519::vrf::VrfSignData, + transcript: &sr25519::vrf::VrfTranscript, ) -> std::result::Result, TraitError> { - self.vrf_sign::(key_type, public, data) - } - - fn sr25519_vrf_output( - &self, - key_type: KeyTypeId, - public: &sr25519::Public, - input: &sr25519::vrf::VrfInput, - ) -> std::result::Result, TraitError> { - self.vrf_output::(key_type, public, input) + self.vrf_sign::(key_type, public, transcript) } fn ed25519_public_keys(&self, key_type: KeyTypeId) -> Vec { @@ -181,7 +158,7 @@ impl Keystore for LocalKeystore { /// Generate a new pair compatible with the 'sr25519' signature scheme. /// - /// If `[seed]` is `Some` then the key will be ephemeral and stored in memory. + /// If the `[seed]` is `Some` then the key will be ephemeral and stored in memory. fn ed25519_generate_new( &self, key_type: KeyTypeId, @@ -205,7 +182,7 @@ impl Keystore for LocalKeystore { /// Generate a new pair compatible with the 'ecdsa' signature scheme. /// - /// If `[seed]` is `Some` then the key will be ephemeral and stored in memory. + /// If the `[seed]` is `Some` then the key will be ephemeral and stored in memory. fn ecdsa_generate_new( &self, key_type: KeyTypeId, @@ -237,60 +214,6 @@ impl Keystore for LocalKeystore { Ok(sig) } - #[cfg(feature = "bls-experimental")] - fn bls381_public_keys(&self, key_type: KeyTypeId) -> Vec { - self.public_keys::(key_type) - } - - #[cfg(feature = "bls-experimental")] - /// Generate a new pair compatible with the 'bls381' signature scheme. - /// - /// If `[seed]` is `Some` then the key will be ephemeral and stored in memory. - fn bls381_generate_new( - &self, - key_type: KeyTypeId, - seed: Option<&str>, - ) -> std::result::Result { - self.generate_new::(key_type, seed) - } - - #[cfg(feature = "bls-experimental")] - fn bls381_sign( - &self, - key_type: KeyTypeId, - public: &bls381::Public, - msg: &[u8], - ) -> std::result::Result, TraitError> { - self.sign::(key_type, public, msg) - } - - #[cfg(feature = "bls-experimental")] - fn bls377_public_keys(&self, key_type: KeyTypeId) -> Vec { - self.public_keys::(key_type) - } - - #[cfg(feature = "bls-experimental")] - /// Generate a new pair compatible with the 'bls377' signature scheme. - /// - /// If `[seed]` is `Some` then the key will be ephemeral and stored in memory. - fn bls377_generate_new( - &self, - key_type: KeyTypeId, - seed: Option<&str>, - ) -> std::result::Result { - self.generate_new::(key_type, seed) - } - - #[cfg(feature = "bls-experimental")] - fn bls377_sign( - &self, - key_type: KeyTypeId, - public: &bls377::Public, - msg: &[u8], - ) -> std::result::Result, TraitError> { - self.sign::(key_type, public, msg) - } - fn insert( &self, key_type: KeyTypeId,