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

Function did_atomic

atomic-cli/src/commands/identity/lookup_key.rs:206–215  ·  view source on GitHub ↗

Compute the `did:atomic:` identifier for a canonical base32 public key. Matches `atomic-canonical::did_for_public_key`: the fingerprint is base32 of `blake3(pubkey_bytes)`.

(canonical: &str)

Source from the content-addressed store, hash-verified

204/// Matches `atomic-canonical::did_for_public_key`: the fingerprint is
205/// base32 of `blake3(pubkey_bytes)`.
206fn did_atomic(canonical: &str) -> String {
207 let bytes: Vec<u8> = BASE32_NOPAD
208 .decode(canonical.as_bytes())
209 .expect("validated above");
210 let hash = blake3::hash(&bytes);
211 format!(
212 "{DID_ATOMIC_PREFIX}{}",
213 BASE32_NOPAD.encode(hash.as_bytes())
214 )
215}
216
217/// Truncate a base32 key for display (matches the `identity list` style).
218fn short_key(key: &str) -> String {

Callers 2

executeMethod · 0.85

Calls 3

hashFunction · 0.50
decodeMethod · 0.45
as_bytesMethod · 0.45

Tested by 1