From 5cf268962ccf7bb9227584cec11bbe6ebb27de1f Mon Sep 17 00:00:00 2001 From: DeFiDude <59237470+DeFiDude@users.noreply.github.com> Date: Thu, 14 May 2026 16:42:13 -0600 Subject: [PATCH] lxmf: define propagation transient id type --- crates/lxmf-core/src/lib.rs | 1 + crates/lxmf-core/src/types.rs | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 crates/lxmf-core/src/types.rs diff --git a/crates/lxmf-core/src/lib.rs b/crates/lxmf-core/src/lib.rs index 5fe26be..7d1d65d 100644 --- a/crates/lxmf-core/src/lib.rs +++ b/crates/lxmf-core/src/lib.rs @@ -47,6 +47,7 @@ pub mod router; pub mod stamper; pub mod sync; pub mod ticket; +pub mod types; /// Encode an `rmpv::Value` into a byte buffer. /// diff --git a/crates/lxmf-core/src/types.rs b/crates/lxmf-core/src/types.rs new file mode 100644 index 0000000..dbd3a13 --- /dev/null +++ b/crates/lxmf-core/src/types.rs @@ -0,0 +1,42 @@ +//! Shared LXMF identifier aliases. +//! +//! Reticulum addressable hashes are 16-byte truncated hashes. LXMF propagation +//! transient IDs are different: upstream Python uses the full SHA-256 hash of +//! the propagation blob (`RNS.Identity.full_hash(lxmf_data)`), so they are +//! 32-byte identifiers. + +use crate::constants::DESTINATION_LENGTH; + +/// Reticulum destination hash, as carried in LXMF wire messages. +pub type DestinationHash = [u8; DESTINATION_LENGTH]; + +/// Reticulum identity hash, used for peer and ticket identity binding. +pub type IdentityHash = [u8; DESTINATION_LENGTH]; + +/// Canonical LXMF message id / SHA-256 digest. +pub type MessageId = [u8; 32]; + +/// Canonical LXMF propagation transient id. +/// +/// Python reference: `LXMessage.pack()` computes this as +/// `RNS.Identity.full_hash(lxmf_data)` before appending the propagation stamp. +pub type PropagationTransientId = [u8; 32]; + +pub const PROPAGATION_TRANSIENT_ID_LENGTH: usize = 32; + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn propagation_transient_ids_are_full_hash_width() { + assert_eq!(std::mem::size_of::(), 32); + assert_eq!(PROPAGATION_TRANSIENT_ID_LENGTH, 32); + } + + #[test] + fn destination_and_identity_hashes_remain_reticulum_width() { + assert_eq!(std::mem::size_of::(), 16); + assert_eq!(std::mem::size_of::(), 16); + } +}