pub struct MembershipToken {
pub public_key: [u8; 32],
pub mesh_id: [u8; 4],
pub callsign: [u8; 12],
pub issued_at_ms: u64,
pub expires_at_ms: u64,
pub authority_signature: [u8; 64],
}Expand description
A membership token binding a device to a callsign within a mesh
Issued by the mesh authority and verifiable by any node.
Fields§
§public_key: [u8; 32]Member’s Ed25519 public key
mesh_id: [u8; 4]Mesh ID this token is valid for (4 bytes from MeshGenesis)
callsign: [u8; 12]Assigned callsign (up to 12 chars, null-padded)
issued_at_ms: u64When this token was issued (milliseconds since Unix epoch)
expires_at_ms: u64When this token expires (milliseconds since Unix epoch) 0 means no expiration
Authority’s Ed25519 signature over the above fields
Implementations§
Source§impl MembershipToken
impl MembershipToken
Sourcepub fn issue(
authority: &DeviceIdentity,
genesis: &MeshGenesis,
member_public_key: [u8; 32],
callsign: &str,
validity_ms: u64,
) -> Self
pub fn issue( authority: &DeviceIdentity, genesis: &MeshGenesis, member_public_key: [u8; 32], callsign: &str, validity_ms: u64, ) -> Self
Issue a new membership token
§Arguments
authority- The mesh authority’s identity (must be mesh creator)genesis- The mesh genesis containing mesh_idmember_public_key- The new member’s public keycallsign- Human-readable callsign (max 12 chars)validity_ms- How long the token is valid (0 = forever)
§Panics
Panics if callsign is longer than 12 characters.
Sourcepub fn issue_at(
authority: &DeviceIdentity,
mesh_id: [u8; 4],
member_public_key: [u8; 32],
callsign: &str,
issued_at_ms: u64,
expires_at_ms: u64,
) -> Self
pub fn issue_at( authority: &DeviceIdentity, mesh_id: [u8; 4], member_public_key: [u8; 32], callsign: &str, issued_at_ms: u64, expires_at_ms: u64, ) -> Self
Issue a token with explicit timestamps (for testing)
Sourcepub fn is_expired(&self, now_ms: u64) -> bool
pub fn is_expired(&self, now_ms: u64) -> bool
Sourcepub fn is_valid(&self, authority_public_key: &[u8; 32], now_ms: u64) -> bool
pub fn is_valid(&self, authority_public_key: &[u8; 32], now_ms: u64) -> bool
Check if the token is valid (signature OK and not expired)
§Arguments
authority_public_key- The mesh authority’s public keynow_ms- Current time in milliseconds since epoch
Sourcepub fn callsign_str(&self) -> &str
pub fn callsign_str(&self) -> &str
Get the callsign as a string (trimmed of null padding)
Sourcepub fn mesh_id_hex(&self) -> String
pub fn mesh_id_hex(&self) -> String
Get the mesh_id as a hex string (e.g., “A1B2C3D4”)
Trait Implementations§
Source§impl Clone for MembershipToken
impl Clone for MembershipToken
Source§fn clone(&self) -> MembershipToken
fn clone(&self) -> MembershipToken
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 Debug for MembershipToken
impl Debug for MembershipToken
Source§impl PartialEq for MembershipToken
impl PartialEq for MembershipToken
impl Eq for MembershipToken
impl StructuralPartialEq for MembershipToken
Auto Trait Implementations§
impl Freeze for MembershipToken
impl RefUnwindSafe for MembershipToken
impl Send for MembershipToken
impl Sync for MembershipToken
impl Unpin for MembershipToken
impl UnsafeUnpin for MembershipToken
impl UnwindSafe for MembershipToken
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.