diff --git a/Cargo.lock b/Cargo.lock index bb5de26b..09e7233d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2935,6 +2935,7 @@ dependencies = [ "multibase", "proptest", "qcheck", + "radicle-crypto", "radicle-git-ref-format", "radicle-oid", "schemars", diff --git a/crates/radicle-core/Cargo.toml b/crates/radicle-core/Cargo.toml index 63d20755..3a45e1c1 100644 --- a/crates/radicle-core/Cargo.toml +++ b/crates/radicle-core/Cargo.toml @@ -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"] } diff --git a/crates/radicle-core/src/lib.rs b/crates/radicle-core/src/lib.rs index 3fe21ac8..f78fd9d7 100644 --- a/crates/radicle-core/src/lib.rs +++ b/crates/radicle-core/src/lib.rs @@ -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; diff --git a/crates/radicle-core/src/node.rs b/crates/radicle-core/src/node.rs new file mode 100644 index 00000000..1fb97777 --- /dev/null +++ b/crates/radicle-core/src/node.rs @@ -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;