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

Method from_entry

core/src/peer.rs:129–139  ·  view source on GitHub ↗

Construct a signed key from a [`PeerEntry`].

(entry: &PeerEntry, node_key: &NodeKey)

Source from the content-addressed store, hash-verified

127 }
128 /// Construct a signed key from a [`PeerEntry`].
129 pub fn from_entry(entry: &PeerEntry, node_key: &NodeKey) -> anyhow::Result<Self> {
130 if entry.id() != node_key.id() {
131 bail!("peer key must be signed by its own ID")
132 }
133 Ok(Self(format!(
134 // 11 digits of a timestamp gets us 1000+ years of padding for a consistent sort order.
135 "{:0>11}.{}",
136 entry.expiration,
137 entry.to_jws(node_key)?
138 )))
139 }
140 /// Decode and verify key as a [`PeerEntry`].
141 pub fn to_entry(&self) -> anyhow::Result<PeerEntry> {
142 let (expiration, jws) = self.split_expiration()?;

Callers

nothing calls this directly

Calls 1

idMethod · 0.45

Tested by

no test coverage detected