public_ed25519_key_bytes from a Cid
(cid: Cid)
| 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 |