pub struct DidKeyProvider { /* private fields */ }Expand description
Provider for did:key identities.
Holds the agent’s own signing key (so it can sign()) and an
in-memory cache of peer Ed25519 keys decoded from did:key
strings. Cache exists only to avoid re-running base58 decode on
every verify; cache misses fall back to decoding the input
agent_id on the spot.
Implementations§
Source§impl DidKeyProvider
impl DidKeyProvider
Sourcepub fn from_signing_key(signing_key: SigningKey) -> Result<Self>
pub fn from_signing_key(signing_key: SigningKey) -> Result<Self>
Build a provider from an existing Ed25519 signing key. The agent_id is derived deterministically from the corresponding public key.
Sourcepub fn decode_pubkey(agent_id: &AgentId) -> Result<VerifyingKey>
pub fn decode_pubkey(agent_id: &AgentId) -> Result<VerifyingKey>
Decode a did:key:z... string into its Ed25519 verifying key.
Returns an error if the input is not a did:key, if the
multibase prefix is not z (base58btc), if the multicodec
prefix is not Ed25519, or if the key length is wrong.
Sourcepub async fn register_peer(&self, peer_id: AgentId, pubkey: VerifyingKey)
pub async fn register_peer(&self, peer_id: AgentId, pubkey: VerifyingKey)
Register a peer’s public key. Useful when the caller has already
decoded a peer’s did:key and wants to avoid repeated decoding.
Trait Implementations§
Source§impl IdentityProvider for DidKeyProvider
impl IdentityProvider for DidKeyProvider
Source§fn agent_id(&self) -> &AgentId
fn agent_id(&self) -> &AgentId
sign() will produce signatures for).Source§fn sign<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<Signature>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn sign<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<Signature>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn verify_peer<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
peer_id: &'life1 AgentId,
message: &'life2 [u8],
signature: &'life3 Signature,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn verify_peer<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
peer_id: &'life1 AgentId,
message: &'life2 [u8],
signature: &'life3 Signature,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§fn trust_metadata<'life0, 'life1, 'async_trait>(
&'life0 self,
_peer_id: &'life1 AgentId,
) -> Pin<Box<dyn Future<Output = Option<TrustMetadata>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn trust_metadata<'life0, 'life1, 'async_trait>(
&'life0 self,
_peer_id: &'life1 AgentId,
) -> Pin<Box<dyn Future<Output = Option<TrustMetadata>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
None if this provider does not support
trust metadata — callers must handle that gracefully. Read more