MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / to_did_key

Method to_did_key

atomic-identity/src/keypair.rs:63–68  ·  view source on GitHub ↗

The standard `did:key` identifier for this Ed25519 key. Multicodec `ed25519-pub` (varint `0xed01`) + the 32 key bytes, base58btc multibase — always rendered `did:key:z6Mk...` for Ed25519. Unlike `did:atomic` (a blake3 fingerprint), the public key is *recoverable from this form, so a verifier holding only the DID can check a signature. Delegation certificates carry both.

(&self)

Source from the content-addressed store, hash-verified

61 /// from this form, so a verifier holding only the DID can check a
62 /// signature. Delegation certificates carry both.
63 pub fn to_did_key(&self) -> String {
64 let mut bytes = Vec::with_capacity(2 + Self::SIZE);
65 bytes.extend_from_slice(&MULTICODEC_ED25519_PUB);
66 bytes.extend_from_slice(self.as_bytes());
67 format!("{}z{}", DID_KEY_PREFIX, bs58::encode(bytes).into_string())
68 }
69
70 /// Recover a public key from its `did:key` form.
71 pub fn from_did_key(did: &str) -> Result<Self, IdentityError> {

Callers 3

key_idMethod · 0.80
did_key_for_public_keyFunction · 0.80
newMethod · 0.80

Calls 1

as_bytesMethod · 0.45

Tested by

no test coverage detected