pub struct AgentKeyManager { /* private fields */ }Expand description
Agent Key Manager implements the KeyManager trait using the agent key abstraction
Implementations§
Source§impl AgentKeyManager
impl AgentKeyManager
Sourcepub fn get_generated_key(&self, did: &str) -> Result<GeneratedKey>
pub fn get_generated_key(&self, did: &str) -> Result<GeneratedKey>
Get a generated key (with DID document) by DID
Sourcepub async fn get_signing_key_type(&self, did: &str) -> Result<String>
pub async fn get_signing_key_type(&self, did: &str) -> Result<String>
Get the key type for a signing key (for debugging)
Sourcepub fn agent_key_from_generated(
&self,
key: &GeneratedKey,
) -> Result<LocalAgentKey>
pub fn agent_key_from_generated( &self, key: &GeneratedKey, ) -> Result<LocalAgentKey>
Create a LocalAgentKey from a GeneratedKey
Sourcepub fn get_private_key(&self, did: &str) -> Result<(Vec<u8>, KeyType)>
pub fn get_private_key(&self, did: &str) -> Result<(Vec<u8>, KeyType)>
Get the raw private key bytes and key type for a DID
Checks generated_keys first (raw bytes), falls back to extracting from the secrets JWK “d” parameter.
Sourcepub fn save_to_storage(&self) -> Result<()>
pub fn save_to_storage(&self) -> Result<()>
Save keys to storage if a storage path is configured
Sourcepub fn load_from_default_storage(self) -> Result<Self>
pub fn load_from_default_storage(self) -> Result<Self>
Load from default storage location
Sourcepub fn load_from_path(self, path: PathBuf) -> Result<Self>
pub fn load_from_path(self, path: PathBuf) -> Result<Self>
Load from a specific storage path
Sourcepub fn add_key_without_save(&self, key: &GeneratedKey) -> Result<()>
pub fn add_key_without_save(&self, key: &GeneratedKey) -> Result<()>
Add a key to the key manager without saving to storage This is useful when you plan to save to storage manually later
Sourcepub fn generate_key_without_save(
&self,
options: DIDGenerationOptions,
) -> Result<GeneratedKey>
pub fn generate_key_without_save( &self, options: DIDGenerationOptions, ) -> Result<GeneratedKey>
Generate a new key with the specified options without saving to storage This is useful when you plan to save to storage manually later
Sourcepub fn generate_web_did_without_save(
&self,
domain: &str,
options: DIDGenerationOptions,
) -> Result<GeneratedKey>
pub fn generate_web_did_without_save( &self, domain: &str, options: DIDGenerationOptions, ) -> Result<GeneratedKey>
Generate a new web DID with the specified domain and options without saving to storage This is useful when you plan to save to storage manually later
Trait Implementations§
Source§impl Clone for AgentKeyManager
impl Clone for AgentKeyManager
Source§fn clone(&self) -> AgentKeyManager
fn clone(&self) -> AgentKeyManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AgentKeyManager
impl Debug for AgentKeyManager
Source§impl Default for AgentKeyManager
impl Default for AgentKeyManager
Source§impl KeyManager for AgentKeyManager
impl KeyManager for AgentKeyManager
Source§fn get_private_key(&self, did: &str) -> Result<(Vec<u8>, KeyType)>
fn get_private_key(&self, did: &str) -> Result<(Vec<u8>, KeyType)>
Get the raw private key bytes and key type for a DID
Source§fn generate_key(&self, options: DIDGenerationOptions) -> Result<GeneratedKey>
fn generate_key(&self, options: DIDGenerationOptions) -> Result<GeneratedKey>
Generate a new key with the specified options
Source§fn generate_web_did(
&self,
domain: &str,
options: DIDGenerationOptions,
) -> Result<GeneratedKey>
fn generate_web_did( &self, domain: &str, options: DIDGenerationOptions, ) -> Result<GeneratedKey>
Generate a new web DID with the specified domain and options
Source§fn has_key(&self, did: &str) -> Result<bool>
fn has_key(&self, did: &str) -> Result<bool>
Check if the key manager has a key for the given DID
Source§fn add_signing_key<'life0, 'async_trait>(
&'life0 self,
key: Arc<dyn SigningKey + Send + Sync>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_signing_key<'life0, 'async_trait>(
&'life0 self,
key: Arc<dyn SigningKey + Send + Sync>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Add a signing key to the key manager
Source§fn add_encryption_key<'life0, 'async_trait>(
&'life0 self,
key: Arc<dyn EncryptionKey + Send + Sync>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_encryption_key<'life0, 'async_trait>(
&'life0 self,
key: Arc<dyn EncryptionKey + Send + Sync>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Add an encryption key to the key manager
Source§fn add_decryption_key<'life0, 'async_trait>(
&'life0 self,
key: Arc<dyn DecryptionKey + Send + Sync>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_decryption_key<'life0, 'async_trait>(
&'life0 self,
key: Arc<dyn DecryptionKey + Send + Sync>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Add a decryption key to the key manager
Source§fn get_signing_key<'life0, 'life1, 'async_trait>(
&'life0 self,
kid: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn SigningKey + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_signing_key<'life0, 'life1, 'async_trait>(
&'life0 self,
kid: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn SigningKey + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a signing key by ID
Source§fn get_encryption_key<'life0, 'life1, 'async_trait>(
&'life0 self,
kid: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn EncryptionKey + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_encryption_key<'life0, 'life1, 'async_trait>(
&'life0 self,
kid: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn EncryptionKey + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get an encryption key by ID
Source§fn get_decryption_key<'life0, 'life1, 'async_trait>(
&'life0 self,
kid: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn DecryptionKey + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_decryption_key<'life0, 'life1, 'async_trait>(
&'life0 self,
kid: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn DecryptionKey + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a decryption key by ID
Source§fn resolve_verification_key<'life0, 'life1, 'async_trait>(
&'life0 self,
kid: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn VerificationKey + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn resolve_verification_key<'life0, 'life1, 'async_trait>(
&'life0 self,
kid: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn VerificationKey + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Resolve a verification key by ID
Source§fn sign_jws<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
kid: &'life1 str,
payload: &'life2 [u8],
protected_header: Option<JwsProtected>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn sign_jws<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
kid: &'life1 str,
payload: &'life2 [u8],
protected_header: Option<JwsProtected>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Sign data with a key
Source§fn verify_jws<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
jws: &'life1 str,
expected_kid: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn verify_jws<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
jws: &'life1 str,
expected_kid: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Verify a JWS
Source§fn encrypt_jwe<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
sender_kid: &'life1 str,
recipient_kid: &'life2 str,
plaintext: &'life3 [u8],
protected_header: Option<JweProtected>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn encrypt_jwe<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
sender_kid: &'life1 str,
recipient_kid: &'life2 str,
plaintext: &'life3 [u8],
protected_header: Option<JweProtected>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Encrypt data for a recipient
Source§fn decrypt_jwe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
jwe: &'life1 str,
expected_kid: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn decrypt_jwe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
jwe: &'life1 str,
expected_kid: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Decrypt a JWE