Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
core: introduce NodeId
Fintan Halpenny committed 4 months ago
commit e09cdb8f6703cda044c50b45d35c9df29f82216f
parent ff3a801858cafd8f678888d97d4ce9ff2ab4ed19
4 files changed +29 -0
modified Cargo.lock
@@ -2944,6 +2944,7 @@ dependencies = [
 "multibase",
 "proptest",
 "qcheck",
+
 "radicle-crypto",
 "radicle-git-ref-format",
 "radicle-oid",
 "schemars",
modified crates/radicle-core/Cargo.toml
@@ -20,6 +20,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, features = ["sha1", "std"] }
schemars = { workspace = true, optional = true, default-features = false, features = ["derive"] }
modified crates/radicle-core/src/lib.rs
@@ -56,5 +56,8 @@
#[cfg(doc)]
extern crate std as doc_std;

+
pub mod node;
+
pub use node::NodeId;
+

pub mod repo;
pub use repo::RepoId;
added 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 multi-base encoded format of the underlying Ed25519 public key, i.e.
+
//! ```
+
//! MULTIBASE(base58-btc, MULTICODEC(public-key-type, raw-public-key-bytes))
+
//! ```
+
//! which result 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;