core: Introduce NodeId

A type for node IDs, which are Ed25519 public keys, is added to the
`radicle-core` crate.
This commit is contained in:
Fintan Halpenny 2025-11-06 09:06:46 +00:00 committed by Lorenz Leutgeb
parent d5fea6324c
commit 7c016f9219
4 changed files with 29 additions and 0 deletions

1
Cargo.lock generated
View File

@ -2935,6 +2935,7 @@ dependencies = [
"multibase",
"proptest",
"qcheck",
"radicle-crypto",
"radicle-git-ref-format",
"radicle-oid",
"schemars",

View File

@ -22,6 +22,7 @@ gix-hash = { workspace = true, optional = true }
multibase = { workspace = true }
proptest = { workspace = true, optional = true }
qcheck = { workspace = true, optional = true }
radicle-crypto = { workspace = true }
radicle-git-ref-format = { workspace = true, optional = true }
radicle-oid = { workspace = true, default-features = false, features = ["sha1"] }
schemars = { workspace = true, optional = true, default-features = false, features = ["derive"] }

View File

@ -71,5 +71,8 @@ extern crate std as doc_std;
extern crate alloc;
pub mod node;
pub use node::NodeId;
pub mod repo;
pub use repo::RepoId;

View File

@ -0,0 +1,24 @@
//! A Radicle node on the network is identified by its [`NodeId`], which in turn
//! is a Ed25519 public key.
//!
//! The human-readable format is a multibase-encoded format of the underlying Ed25519 public key, i.e.
//! ```
//! MULTIBASE(base58-btc, MULTICODEC(public-key-type, raw-public-key-bytes))
//! ```
//! which results in strings that look like:
//! ```
//! z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
//! ```
use radicle_crypto::PublicKey;
/// Public identifier of a node device in the network.
///
/// # Legacy
///
/// This is a type alias, providing little protection around evolving a [`NodeId`]
/// and having it very tightly coupled with a [`PublicKey`].
///
/// Future iterations will change this to provide a better API for working with
/// [`NodeId`]'s and their usage in the protocol.
pub type NodeId = PublicKey;