Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
core: Introduce NodeId
Fintan Halpenny committed 3 months ago
commit 7c016f9219d5d5d32b9b3dfe213372e0d62d4d14
parent d5fea6324c8df3e25da7063827deb75a5828be12
4 files changed +29 -0
modified Cargo.lock
@@ -2935,6 +2935,7 @@ dependencies = [
 "multibase",
 "proptest",
 "qcheck",
+
 "radicle-crypto",
 "radicle-git-ref-format",
 "radicle-oid",
 "schemars",
modified 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"] }
modified 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;
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 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;