Skip to main content

did_key_to_ed25519

Function did_key_to_ed25519 

pub fn did_key_to_ed25519(did: &str) -> Result<[u8; 32], Error>
Expand description

Decode a did:key (Ed25519) identifier into its raw 32-byte Ed25519 key.

For Ed25519 a did:key is exactly "did:key:" + multibase-base58btc(0xed01 ‖ pubkey) — i.e. the method-specific identifier is the same Multikey publicKeyMultibase value decode_ed25519_multikey decodes. A did:key is therefore self-contained: the key is the identity, so this is a pure decode with no network fetch.

Returns Err for a non-did:key identifier, a non-Ed25519 multicodec, a bad multibase, or a wrong-length payload. A DID URL fragment / query is stripped (did:key:z6Mk…#z6Mk… self-references the same key; we decode the base method-specific identifier).