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: StringHuman-readable mesh name.
created_at_ms: u64Timestamp of creation (milliseconds since Unix epoch).
policy: MembershipPolicyMembership policy for this mesh.
Implementations§
Source§impl MeshGenesis
impl MeshGenesis
Sourcepub fn create(mesh_name: &str, policy: MembershipPolicy) -> Self
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.
Sourcepub fn with_seed(
mesh_name: &str,
mesh_seed: [u8; 32],
policy: MembershipPolicy,
) -> Self
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.
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.
Sourcepub fn mesh_id(&self) -> String
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”.
Sourcepub fn formation_secret(&self) -> [u8; 32]
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) → EndpointIdGet the authority keypair.
Get the authority’s public key bytes.
Sourcepub fn mesh_seed(&self) -> &[u8; 32]
pub fn mesh_seed(&self) -> &[u8; 32]
Get the mesh seed for secure storage.
Security: This is the root secret. Protect it carefully.
Sourcepub fn root_certificate(&self, node_id: &str) -> MeshCertificate
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)
Sourcepub fn issue_certificate(
&self,
subject_public_key: [u8; 32],
node_id: &str,
tier: MeshTier,
permissions: u8,
validity_ms: u64,
) -> MeshCertificate
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.
Sourcepub fn credentials(&self) -> MeshCredentials
pub fn credentials(&self) -> MeshCredentials
Build shareable credentials (no seed, no authority private key).
Sourcepub fn encode(&self) -> Vec<u8> ⓘ
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
Sourcepub fn decode(data: &[u8]) -> Result<Self, SecurityError>
pub fn decode(data: &[u8]) -> Result<Self, SecurityError>
Decode genesis data from bytes.
Trait Implementations§
Source§impl Clone for MeshGenesis
impl Clone for MeshGenesis
Source§fn clone(&self) -> MeshGenesis
fn clone(&self) -> MeshGenesis
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more