pub struct GenericIpNodeID<A: NodeIpAddress> {
pub node_id: Vec<u8>,
pub ip_addr: A,
pub public_key: Vec<u8>,
pub signature: Vec<u8>,
pub timestamp_secs: u64,
pub salt: Vec<u8>,
}Expand description
Generic IP-based node identity that binds node ID to network location
This struct provides a unified implementation for both IPv4 and IPv6 node identities, reducing code duplication while maintaining type safety.
Fields§
§node_id: Vec<u8>Derived node ID (SHA256 of ip_addr + public_key + salt + timestamp)
ip_addr: AIP address this node ID is bound to
public_key: Vec<u8>ML-DSA public key for signatures
signature: Vec<u8>Signature proving ownership of the IP address and keys
timestamp_secs: u64Timestamp when this ID was generated (seconds since epoch)
salt: Vec<u8>Salt used in node ID generation (for freshness)
Implementations§
Source§impl<A: NodeIpAddress> GenericIpNodeID<A>
impl<A: NodeIpAddress> GenericIpNodeID<A>
Sourcepub fn generate(
ip_addr: A,
secret: &MlDsaSecretKey,
public: &MlDsaPublicKey,
) -> Result<Self>
pub fn generate( ip_addr: A, secret: &MlDsaSecretKey, public: &MlDsaPublicKey, ) -> Result<Self>
Generate a new IP-based node ID
Sourcepub fn is_expired(&self, max_age: Duration) -> bool
pub fn is_expired(&self, max_age: Duration) -> bool
Check if the node ID has expired (older than max_age)
Trait Implementations§
Source§impl<A: Clone + NodeIpAddress> Clone for GenericIpNodeID<A>
impl<A: Clone + NodeIpAddress> Clone for GenericIpNodeID<A>
Source§fn clone(&self) -> GenericIpNodeID<A>
fn clone(&self) -> GenericIpNodeID<A>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<A: Debug + NodeIpAddress> Debug for GenericIpNodeID<A>
impl<A: Debug + NodeIpAddress> Debug for GenericIpNodeID<A>
Source§impl<'de, A> Deserialize<'de> for GenericIpNodeID<A>where
A: Deserialize<'de> + NodeIpAddress,
impl<'de, A> Deserialize<'de> for GenericIpNodeID<A>where
A: Deserialize<'de> + NodeIpAddress,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<A> Serialize for GenericIpNodeID<A>where
A: Serialize + NodeIpAddress,
impl<A> Serialize for GenericIpNodeID<A>where
A: Serialize + NodeIpAddress,
Auto Trait Implementations§
impl<A> Freeze for GenericIpNodeID<A>where
A: Freeze,
impl<A> RefUnwindSafe for GenericIpNodeID<A>where
A: RefUnwindSafe,
impl<A> Send for GenericIpNodeID<A>
impl<A> Sync for GenericIpNodeID<A>
impl<A> Unpin for GenericIpNodeID<A>where
A: Unpin,
impl<A> UnwindSafe for GenericIpNodeID<A>where
A: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more