openagent-server · did_key
Declared module signatures, types, configuration, and source documentation.
Source: openagents/openagent.id/crates/openagent-server/src/did_key.rs. SHA-256: af3d85cbe793c1528189111ecc157ee9f82bc378c3f446f9246a3baac5de7e62.
This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.
did_key::did_key_from_ed25519
Derives a did:key string from a raw 32-byte Ed25519 public key.
Per the did:key method specification:
- Prepend the Ed25519 multicodec prefix (0xed01)
- Encode with base58btc (multibase prefix 'z')
- Result:
did:key:z<base58btc>
Arguments
pubkey- 32-byte Ed25519 public key
Returns
The did:key:z... string.
pub fn did_key_from_ed25519(pubkey: &[u8; 32]) -> String;Source line: 28.
did_key::ed25519_from_did_key
Extracts the raw 32-byte Ed25519 public key from a did:key string.
Errors
Returns an error if the DID is not a valid did:key with Ed25519 multicodec prefix.
pub fn ed25519_from_did_key(did: &str) -> Result<[u8; 32], DidKeyError>;Source line: 41.
did_key::parse_pubkey_base64url
Parses a public key from the base64url-encoded segment of an Authorization header.
pub fn parse_pubkey_base64url(encoded: &str) -> Result<[u8; 32], DidKeyError>;Source line: 69.
did_key::DidKeyError
Errors from did:key operations.
#[derive(Debug, thiserror::Error)]
pub enum DidKeyError {
#[error("did:key must start with 'did:key:z'")]
InvalidPrefix,
#[error("invalid base58 encoding in did:key")]
InvalidBase58,
#[error("invalid base64url encoding")]
InvalidBase64,
#[error("decoded key length {actual} does not match expected {expected}")]
InvalidLength { expected: usize, actual: usize },
#[error("unsupported multicodec prefix {found}; expected 0xed01 (Ed25519)")]
UnsupportedCodec { found: String },
}Source line: 88.