Trait sp_keystore::CryptoStore
source · pub trait CryptoStore: Send + Sync {
Show 15 methods
// Required methods
fn sr25519_public_keys<'life0, 'async_trait>(
&'life0 self,
id: KeyTypeId
) -> Pin<Box<dyn Future<Output = Vec<Public>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn sr25519_generate_new<'life0, 'life1, 'async_trait>(
&'life0 self,
id: KeyTypeId,
seed: Option<&'life1 str>
) -> Pin<Box<dyn Future<Output = Result<Public, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn ed25519_public_keys<'life0, 'async_trait>(
&'life0 self,
id: KeyTypeId
) -> Pin<Box<dyn Future<Output = Vec<Public>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn ed25519_generate_new<'life0, 'life1, 'async_trait>(
&'life0 self,
id: KeyTypeId,
seed: Option<&'life1 str>
) -> Pin<Box<dyn Future<Output = Result<Public, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn ecdsa_public_keys<'life0, 'async_trait>(
&'life0 self,
id: KeyTypeId
) -> Pin<Box<dyn Future<Output = Vec<Public>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn ecdsa_generate_new<'life0, 'life1, 'async_trait>(
&'life0 self,
id: KeyTypeId,
seed: Option<&'life1 str>
) -> Pin<Box<dyn Future<Output = Result<Public, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn insert_unknown<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: KeyTypeId,
suri: &'life1 str,
public: &'life2 [u8]
) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn supported_keys<'life0, 'async_trait>(
&'life0 self,
id: KeyTypeId,
keys: Vec<CryptoTypePublicPair>
) -> Pin<Box<dyn Future<Output = Result<Vec<CryptoTypePublicPair>, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn keys<'life0, 'async_trait>(
&'life0 self,
id: KeyTypeId
) -> Pin<Box<dyn Future<Output = Result<Vec<CryptoTypePublicPair>, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn has_keys<'life0, 'life1, 'async_trait>(
&'life0 self,
public_keys: &'life1 [(Vec<u8>, KeyTypeId)]
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn sign_with<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: KeyTypeId,
key: &'life1 CryptoTypePublicPair,
msg: &'life2 [u8]
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn sr25519_vrf_sign<'life0, 'life1, 'async_trait>(
&'life0 self,
key_type: KeyTypeId,
public: &'life1 Public,
transcript_data: VRFTranscriptData
) -> Pin<Box<dyn Future<Output = Result<Option<VRFSignature>, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn ecdsa_sign_prehashed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: KeyTypeId,
public: &'life1 Public,
msg: &'life2 [u8; 32]
) -> Pin<Box<dyn Future<Output = Result<Option<Signature>, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
// Provided methods
fn sign_with_any<'life0, 'life1, 'async_trait>(
&'life0 self,
id: KeyTypeId,
keys: Vec<CryptoTypePublicPair>,
msg: &'life1 [u8]
) -> Pin<Box<dyn Future<Output = Result<Option<(CryptoTypePublicPair, Vec<u8>)>, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn sign_with_all<'life0, 'life1, 'async_trait>(
&'life0 self,
id: KeyTypeId,
keys: Vec<CryptoTypePublicPair>,
msg: &'life1 [u8]
) -> Pin<Box<dyn Future<Output = Result<Vec<Result<Option<Vec<u8>>, Error>>, ()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}
Expand description
Something that generates, stores and provides access to keys.
Required Methods§
sourcefn sr25519_public_keys<'life0, 'async_trait>(
&'life0 self,
id: KeyTypeId
) -> Pin<Box<dyn Future<Output = Vec<Public>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn sr25519_public_keys<'life0, 'async_trait>( &'life0 self, id: KeyTypeId ) -> Pin<Box<dyn Future<Output = Vec<Public>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Returns all sr25519 public keys for the given key type.
sourcefn sr25519_generate_new<'life0, 'life1, 'async_trait>(
&'life0 self,
id: KeyTypeId,
seed: Option<&'life1 str>
) -> Pin<Box<dyn Future<Output = Result<Public, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn sr25519_generate_new<'life0, 'life1, 'async_trait>( &'life0 self, id: KeyTypeId, seed: Option<&'life1 str> ) -> Pin<Box<dyn Future<Output = Result<Public, Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Generate a new sr25519 key pair for the given key type and an optional seed.
If the given seed is Some(_)
, the key pair will only be stored in memory.
Returns the public key of the generated key pair.
sourcefn ed25519_public_keys<'life0, 'async_trait>(
&'life0 self,
id: KeyTypeId
) -> Pin<Box<dyn Future<Output = Vec<Public>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn ed25519_public_keys<'life0, 'async_trait>( &'life0 self, id: KeyTypeId ) -> Pin<Box<dyn Future<Output = Vec<Public>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Returns all ed25519 public keys for the given key type.
sourcefn ed25519_generate_new<'life0, 'life1, 'async_trait>(
&'life0 self,
id: KeyTypeId,
seed: Option<&'life1 str>
) -> Pin<Box<dyn Future<Output = Result<Public, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn ed25519_generate_new<'life0, 'life1, 'async_trait>( &'life0 self, id: KeyTypeId, seed: Option<&'life1 str> ) -> Pin<Box<dyn Future<Output = Result<Public, Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Generate a new ed25519 key pair for the given key type and an optional seed.
If the given seed is Some(_)
, the key pair will only be stored in memory.
Returns the public key of the generated key pair.
sourcefn ecdsa_public_keys<'life0, 'async_trait>(
&'life0 self,
id: KeyTypeId
) -> Pin<Box<dyn Future<Output = Vec<Public>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn ecdsa_public_keys<'life0, 'async_trait>( &'life0 self, id: KeyTypeId ) -> Pin<Box<dyn Future<Output = Vec<Public>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Returns all ecdsa public keys for the given key type.
sourcefn ecdsa_generate_new<'life0, 'life1, 'async_trait>(
&'life0 self,
id: KeyTypeId,
seed: Option<&'life1 str>
) -> Pin<Box<dyn Future<Output = Result<Public, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn ecdsa_generate_new<'life0, 'life1, 'async_trait>( &'life0 self, id: KeyTypeId, seed: Option<&'life1 str> ) -> Pin<Box<dyn Future<Output = Result<Public, Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Generate a new ecdsa key pair for the given key type and an optional seed.
If the given seed is Some(_)
, the key pair will only be stored in memory.
Returns the public key of the generated key pair.
sourcefn insert_unknown<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: KeyTypeId,
suri: &'life1 str,
public: &'life2 [u8]
) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn insert_unknown<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, id: KeyTypeId, suri: &'life1 str, public: &'life2 [u8] ) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,
Insert a new key. This doesn’t require any known of the crypto; but a public key must be manually provided.
Places it into the file system store.
Err
if there’s some sort of weird filesystem error, but should generally be Ok
.
sourcefn supported_keys<'life0, 'async_trait>(
&'life0 self,
id: KeyTypeId,
keys: Vec<CryptoTypePublicPair>
) -> Pin<Box<dyn Future<Output = Result<Vec<CryptoTypePublicPair>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn supported_keys<'life0, 'async_trait>( &'life0 self, id: KeyTypeId, keys: Vec<CryptoTypePublicPair> ) -> Pin<Box<dyn Future<Output = Result<Vec<CryptoTypePublicPair>, Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Find intersection between provided keys and supported keys
Provided a list of (CryptoTypeId,u8) pairs, this would return a filtered set of public keys which are supported by the keystore.
sourcefn keys<'life0, 'async_trait>(
&'life0 self,
id: KeyTypeId
) -> Pin<Box<dyn Future<Output = Result<Vec<CryptoTypePublicPair>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn keys<'life0, 'async_trait>( &'life0 self, id: KeyTypeId ) -> Pin<Box<dyn Future<Output = Result<Vec<CryptoTypePublicPair>, Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
List all supported keys
Returns a set of public keys the signer supports.
sourcefn has_keys<'life0, 'life1, 'async_trait>(
&'life0 self,
public_keys: &'life1 [(Vec<u8>, KeyTypeId)]
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn has_keys<'life0, 'life1, 'async_trait>( &'life0 self, public_keys: &'life1 [(Vec<u8>, KeyTypeId)] ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Checks if the private keys for the given public key and key type combinations exist.
Returns true
iff all private keys could be found.
sourcefn sign_with<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: KeyTypeId,
key: &'life1 CryptoTypePublicPair,
msg: &'life2 [u8]
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn sign_with<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, id: KeyTypeId, key: &'life1 CryptoTypePublicPair, msg: &'life2 [u8] ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,
Sign with key
Signs a message with the private key that matches the public key passed.
Returns the SCALE encoded signature if key is found and supported, None
if the key doesn’t
exist or an error when something failed.
sourcefn sr25519_vrf_sign<'life0, 'life1, 'async_trait>(
&'life0 self,
key_type: KeyTypeId,
public: &'life1 Public,
transcript_data: VRFTranscriptData
) -> Pin<Box<dyn Future<Output = Result<Option<VRFSignature>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn sr25519_vrf_sign<'life0, 'life1, 'async_trait>( &'life0 self, key_type: KeyTypeId, public: &'life1 Public, transcript_data: VRFTranscriptData ) -> Pin<Box<dyn Future<Output = Result<Option<VRFSignature>, Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Generate VRF signature for given transcript data.
Receives KeyTypeId and Public key to be able to map them to a private key that exists in the keystore which is, in turn, used for signing the provided transcript.
Returns a result containing the signature data.
Namely, VRFOutput and VRFProof which are returned
inside the VRFSignature
container struct.
This function will return None
if the given key_type
and public
combination
doesn’t exist in the keystore or an Err
when something failed.
sourcefn ecdsa_sign_prehashed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: KeyTypeId,
public: &'life1 Public,
msg: &'life2 [u8; 32]
) -> Pin<Box<dyn Future<Output = Result<Option<Signature>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn ecdsa_sign_prehashed<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, id: KeyTypeId, public: &'life1 Public, msg: &'life2 [u8; 32] ) -> Pin<Box<dyn Future<Output = Result<Option<Signature>, Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,
Generate an ECDSA signature for a given pre-hashed message.
Receives KeyTypeId
and an ecdsa::Public
key to be able to map
them to a private key that exists in the keystore. This private key is,
in turn, used for signing the provided pre-hashed message.
The msg
argument provided should be a hashed message for which an
ECDSA signature should be generated.
Returns an ecdsa::Signature
or None
in case the given id
and
public
combination doesn’t exist in the keystore. An Err
will be
returned if generating the signature itself failed.
Provided Methods§
sourcefn sign_with_any<'life0, 'life1, 'async_trait>(
&'life0 self,
id: KeyTypeId,
keys: Vec<CryptoTypePublicPair>,
msg: &'life1 [u8]
) -> Pin<Box<dyn Future<Output = Result<Option<(CryptoTypePublicPair, Vec<u8>)>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn sign_with_any<'life0, 'life1, 'async_trait>( &'life0 self, id: KeyTypeId, keys: Vec<CryptoTypePublicPair>, msg: &'life1 [u8] ) -> Pin<Box<dyn Future<Output = Result<Option<(CryptoTypePublicPair, Vec<u8>)>, Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Sign with any key
Given a list of public keys, find the first supported key and sign the provided message with that key.
Returns a tuple of the used key and the SCALE encoded signature or None
if no key could
be found to sign.
sourcefn sign_with_all<'life0, 'life1, 'async_trait>(
&'life0 self,
id: KeyTypeId,
keys: Vec<CryptoTypePublicPair>,
msg: &'life1 [u8]
) -> Pin<Box<dyn Future<Output = Result<Vec<Result<Option<Vec<u8>>, Error>>, ()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn sign_with_all<'life0, 'life1, 'async_trait>( &'life0 self, id: KeyTypeId, keys: Vec<CryptoTypePublicPair>, msg: &'life1 [u8] ) -> Pin<Box<dyn Future<Output = Result<Vec<Result<Option<Vec<u8>>, Error>>, ()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Sign with all keys
Provided a list of public keys, sign a message with each key given that the key is supported.
Returns a list of Result
s each representing the SCALE encoded
signature of each key, None
if the key doesn’t exist or a error when something failed.