aboutsummaryrefslogtreecommitdiffstats
path: root/src/federation/keys.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/federation/keys.rs')
-rw-r--r--src/federation/keys.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/federation/keys.rs b/src/federation/keys.rs
index 0dbe5f7..aff7792 100644
--- a/src/federation/keys.rs
+++ b/src/federation/keys.rs
@@ -125,6 +125,14 @@ pub(crate) fn node_id(text: &str) -> bool {
identity::public_of(text).is_some_and(|key| VerifyingKey::from_bytes(&key).is_ok())
}
+/// The ID of the node whose key `key` is, where it is an Ed25519 key, as a node's are.
+pub(crate) fn node_of(key: &Key) -> Option<String> {
+ match key {
+ Key::Ed25519(PublicKey(public)) => Some(identity::node_id_of(public)),
+ Key::P256(_) => None,
+ }
+}
+
/// Whether `sig` is `key`'s signature of `message`, spelled as the federation spells one.
pub(crate) fn verifies(key: &Key, sig: &str, message: &[u8]) -> bool {
let Ok(blob) = BASE64.decode(sig) else {