MeshGenesis

Struct MeshGenesis 

Source
pub struct MeshGenesis {
    pub mesh_name: String,
    pub created_at_ms: u64,
    pub policy: MembershipPolicy,
    /* private fields */
}
Expand description

Genesis event for creating a new mesh

Contains all the cryptographic material needed to bootstrap a mesh. The creator should securely store this for recovery purposes.

Fields§

§mesh_name: String

Human-readable mesh name

§created_at_ms: u64

Timestamp of creation (milliseconds since Unix epoch)

§policy: MembershipPolicy

Membership policy for this mesh

Implementations§

Source§

impl MeshGenesis

Source

pub fn create( mesh_name: &str, creator: &DeviceIdentity, policy: MembershipPolicy, ) -> Self

Create a new mesh as the founding controller

§Arguments
  • mesh_name - Human-readable name for the mesh
  • creator - Device identity of the mesh creator
  • policy - Membership policy for the mesh
§Returns

A new MeshGenesis with cryptographically secure seed

Source

pub fn with_seed( mesh_name: &str, seed: [u8; 32], creator: &DeviceIdentity, policy: MembershipPolicy, ) -> Self

Create genesis with a specific seed (for testing or deterministic creation)

§Safety

Only use with cryptographically random seeds in production.

Source

pub fn mesh_id(&self) -> String

Derive the mesh_id from name and seed

The mesh_id is 8 hex characters derived from BLAKE3 keyed hash. Format: uppercase hex, e.g., “A1B2C3D4”

Source

pub fn encryption_secret(&self) -> [u8; 32]

Derive the mesh-wide encryption secret

Uses BLAKE3 key derivation with a specific context.

Source

pub fn beacon_key_base(&self) -> [u8; 32]

Derive the base key for encrypted beacons

Beacon keys are rotated, but this is the base from which they’re derived.

Source

pub fn mesh_seed(&self) -> &[u8; 32]

Get the mesh seed for secure storage

Security: This is the root secret. Protect it carefully.

Source

pub fn creator(&self) -> &DeviceIdentity

Get the creator’s identity

Source

pub fn creator_public_key(&self) -> [u8; 32]

Get the creator’s public key

Source

pub fn is_creator(&self, identity: &DeviceIdentity) -> bool

Check if a given identity is the mesh creator

Source

pub fn encode(&self) -> Vec<u8>

Encode genesis data for persistence

Format:

  • mesh_name length (2 bytes, LE)
  • mesh_name (variable)
  • mesh_seed (32 bytes)
  • creator public key (32 bytes)
  • creator private key (32 bytes) - SENSITIVE!
  • created_at_ms (8 bytes, LE)
  • policy (1 byte)

Total: 107 + mesh_name.len() bytes

Source

pub fn decode(data: &[u8]) -> Option<Self>

Decode genesis data from bytes

Returns None if data is invalid or too short.

Trait Implementations§

Source§

impl Clone for MeshGenesis

Source§

fn clone(&self) -> MeshGenesis

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MeshGenesis

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.