Skip to main content

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 formation.

Contains all cryptographic material needed to bootstrap a mesh from zero. The genesis artifact is the root of trust — the authority keypair signs all certificates and the formation_secret authenticates transport.

§Security

The mesh_seed is the root secret. Protect it carefully:

  • Store encrypted at rest
  • Never transmit over the network
  • Only the genesis creator needs it (for recovery)

Shareable credentials (via MeshCredentials) exclude the seed and authority private key.

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, policy: MembershipPolicy) -> Self

Create a new mesh formation with a random seed.

The authority keypair is deterministically derived from the seed.

Source

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

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

§Safety

Only use with cryptographically random seeds in production.

Source

pub fn with_authority( mesh_name: &str, mesh_seed: [u8; 32], authority: DeviceKeypair, policy: MembershipPolicy, ) -> Self

Create a genesis with a specific seed and an externally-provided authority keypair.

Use when the authority keypair is generated independently (e.g., from a hardware security module) rather than derived from the seed.

Source

pub fn mesh_id(&self) -> String

Derive the mesh_id from name and seed.

The mesh_id is 8 hex characters derived from HKDF-SHA256. Format: uppercase hex, e.g., “A1B2C3D4”.

Source

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

Derive the formation secret.

The formation secret is shared with all mesh members and used for HKDF-based Iroh EndpointId derivation:

HKDF(formation_secret, "iroh:" + node_id) → EndpointId
Source

pub fn authority(&self) -> &DeviceKeypair

Get the authority keypair.

Source

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

Get the authority’s public key bytes.

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 root_certificate(&self, node_id: &str) -> MeshCertificate

Generate a self-signed root certificate for the authority node.

The root cert identifies the genesis authority in the mesh:

  • subject_public_key = issuer_public_key (self-signed)
  • tier = Enterprise (highest trust)
  • permissions = AUTHORITY (all permissions)
  • expires_at_ms = 0 (no expiration, root cert is permanent)
Source

pub fn issue_certificate( &self, subject_public_key: [u8; 32], node_id: &str, tier: MeshTier, permissions: u8, validity_ms: u64, ) -> MeshCertificate

Issue a signed certificate for a new member.

This is a convenience method for the genesis authority to enroll a node.

Source

pub fn credentials(&self) -> MeshCredentials

Build shareable credentials (no seed, no authority private key).

Source

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

Encode genesis data for secure persistence.

Format:

  • mesh_name length (2 bytes, LE)
  • mesh_name (variable)
  • mesh_seed (32 bytes)
  • authority secret key (32 bytes) — SENSITIVE!
  • created_at_ms (8 bytes, LE)
  • policy (1 byte)

Total: 75 + mesh_name.len() bytes

Source

pub fn decode(data: &[u8]) -> Result<Self, SecurityError>

Decode genesis data from bytes.

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more