pub trait Keystore: TransactionAuthenticator {
// Required methods
fn add_key<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 AuthSecretKey,
account_id: AccountId,
) -> Pin<Box<dyn Future<Output = Result<(), KeyStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn remove_key<'life0, 'async_trait>(
&'life0 self,
pub_key: PublicKeyCommitment,
) -> Pin<Box<dyn Future<Output = Result<(), KeyStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn get_key<'life0, 'async_trait>(
&'life0 self,
pub_key: PublicKeyCommitment,
) -> Pin<Box<dyn Future<Output = Result<Option<AuthSecretKey>, KeyStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn get_account_key_commitments<'life0, 'life1, 'async_trait>(
&'life0 self,
account_id: &'life1 AccountId,
) -> Pin<Box<dyn Future<Output = Result<BTreeSet<PublicKeyCommitment>, KeyStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn get_account_id_by_key_commitment<'life0, 'async_trait>(
&'life0 self,
pub_key_commitment: PublicKeyCommitment,
) -> Pin<Box<dyn Future<Output = Result<Option<AccountId>, KeyStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
// Provided method
fn get_keys_for_account<'life0, 'life1, 'async_trait>(
&'life0 self,
account_id: &'life1 AccountId,
) -> Pin<Box<dyn Future<Output = Result<Vec<AuthSecretKey>, KeyStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: Sync + 'async_trait { ... }
}Expand description
A trait for managing cryptographic keys and their association with accounts.
This trait extends TransactionAuthenticator to provide a unified interface
for key storage, retrieval, and account-key mapping.
Required Methods§
Sourcefn add_key<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 AuthSecretKey,
account_id: AccountId,
) -> Pin<Box<dyn Future<Output = Result<(), KeyStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn add_key<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 AuthSecretKey,
account_id: AccountId,
) -> Pin<Box<dyn Future<Output = Result<(), KeyStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Adds a secret key to the keystore and associates it with the given account.
A key can be associated with multiple accounts by calling this method multiple times.
Sourcefn remove_key<'life0, 'async_trait>(
&'life0 self,
pub_key: PublicKeyCommitment,
) -> Pin<Box<dyn Future<Output = Result<(), KeyStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn remove_key<'life0, 'async_trait>(
&'life0 self,
pub_key: PublicKeyCommitment,
) -> Pin<Box<dyn Future<Output = Result<(), KeyStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Removes a key from the keystore by its public key commitment.
This also removes all account associations for this key.
Sourcefn get_key<'life0, 'async_trait>(
&'life0 self,
pub_key: PublicKeyCommitment,
) -> Pin<Box<dyn Future<Output = Result<Option<AuthSecretKey>, KeyStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn get_key<'life0, 'async_trait>(
&'life0 self,
pub_key: PublicKeyCommitment,
) -> Pin<Box<dyn Future<Output = Result<Option<AuthSecretKey>, KeyStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Retrieves a secret key by its public key commitment.
Returns Ok(None) if the key is not found.
Sourcefn get_account_key_commitments<'life0, 'life1, 'async_trait>(
&'life0 self,
account_id: &'life1 AccountId,
) -> Pin<Box<dyn Future<Output = Result<BTreeSet<PublicKeyCommitment>, KeyStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn get_account_key_commitments<'life0, 'life1, 'async_trait>(
&'life0 self,
account_id: &'life1 AccountId,
) -> Pin<Box<dyn Future<Output = Result<BTreeSet<PublicKeyCommitment>, KeyStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Returns all public key commitments associated with the given account ID.
Returns an error if the account is not found.
Sourcefn get_account_id_by_key_commitment<'life0, 'async_trait>(
&'life0 self,
pub_key_commitment: PublicKeyCommitment,
) -> Pin<Box<dyn Future<Output = Result<Option<AccountId>, KeyStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn get_account_id_by_key_commitment<'life0, 'async_trait>(
&'life0 self,
pub_key_commitment: PublicKeyCommitment,
) -> Pin<Box<dyn Future<Output = Result<Option<AccountId>, KeyStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Returns the account ID associated with a given public key commitment.
Returns Ok(None) if no account is found for the commitment.
Provided Methods§
Sourcefn get_keys_for_account<'life0, 'life1, 'async_trait>(
&'life0 self,
account_id: &'life1 AccountId,
) -> Pin<Box<dyn Future<Output = Result<Vec<AuthSecretKey>, KeyStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: Sync + 'async_trait,
fn get_keys_for_account<'life0, 'life1, 'async_trait>(
&'life0 self,
account_id: &'life1 AccountId,
) -> Pin<Box<dyn Future<Output = Result<Vec<AuthSecretKey>, KeyStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: Sync + 'async_trait,
Returns all secret keys associated with the given account ID.
This is a convenience method that calls get_account_key_commitments
followed by get_key for each commitment.
Returns an empty vector if the account has no associated keys. Returns an error if any key lookup fails.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.