MCPcopy Create free account
hub / github.com/ceramicnetwork/rust-ceramic / try_from_cid

Method try_from_cid

core/src/node_id.rs:103–114  ·  view source on GitHub ↗

public_ed25519_key_bytes from a Cid

(cid: Cid)

Source from the content-addressed store, hash-verified

101 }
102 /// public_ed25519_key_bytes from a Cid
103 pub fn try_from_cid(cid: Cid) -> Result<Self> {
104 let mh = cid.hash();
105 if mh.code() != 0x00 {
106 return Err(anyhow!("Cid multihash is not identity"));
107 }
108 if mh.size() != 32 {
109 return Err(anyhow!("CID multihash is not 36 bytes"));
110 }
111 Ok(Self {
112 public_ed25519_key_bytes: mh.digest().try_into()?,
113 })
114 }
115 /// public_ed25519_key_bytes from a did:key
116 pub fn try_from_did_key(did_key: &str) -> Result<Self> {
117 let public_key_multibase = did_key

Callers

nothing calls this directly

Calls 3

try_intoMethod · 0.80
hashMethod · 0.45
digestMethod · 0.45

Tested by

no test coverage detected