Skip to main content
The palyra-identity crate is the foundational security layer for the Palyra ecosystem. It manages the cryptographic lifecycle of devices, including Ed25519 signing keys, X25519 exchange keys, and X.509 certificates used for mutual TLS (mTLS) in QUIC and gRPC communications. It also orchestrates the multi-step pairing handshake required to onboard new nodes and clients into a trusted mesh.

Secret Storage and Persistence

Palyra uses a tiered storage model for sensitive identity material. The SecretStore trait provides an abstraction for reading, writing, and deleting secrets.

FilesystemSecretStore

The FilesystemSecretStore is the primary implementation for persistent storage on disk. It enforces strict OS-level permissions and uses authenticated encryption for all stored values.

Vault Backends

While palyra-identity handles the core device keys, the palyra-vault crate provides higher-level blob storage for application secrets using BackendKind crates/palyra-vault/src/backend.rs#41: Sources: crates/palyra-identity/src/store.rs#87-133, crates/palyra-vault/src/backend.rs#39-80

Device Identity and Keys

Every participant in the Palyra network is identified by a DeviceIdentity. This identity consists of a canonical ULID device_id and a set of cryptographic key pairs.

Key Types

  1. Ed25519: Used for signing pairing requests and authenticating control plane messages.
  2. X25519: Used for Diffie-Hellman key exchange during the pairing handshake to establish a shared secret without exposing it to the transport layer.

Identity Management

The IdentityManager acts as the orchestrator for the local device’s identity and the registry of known PairedDevice entities crates/palyra-identity/src/pairing/handshake.rs#58. It manages: Sources: crates/palyra-identity/src/pairing/handshake.rs#1-25, crates/palyra-identity/src/pairing/models.rs#1-20

Pairing Handshake

The pairing process is a cryptographic handshake that upgrades an out-of-band “proof” (like a QR code or numeric PIN) into a permanent mTLS trust relationship.

Handshake Flow

The IdentityManager implements the start_pairing, verify_pairing, and finalize_verified_pairing sequence.

1. Initiation

The gateway generates a PairingSession containing an ephemeral X25519 public key and a random challenge crates/palyra-identity/src/pairing/handshake.rs#41-49.

2. Device Hello

The joining device responds with a DevicePairingHello. This structure includes its own ephemeral X25519 key, its permanent Ed25519 public key, and a signature over the transcript crates/palyra-identity/src/pairing/handshake.rs#111-118.

3. Verification

The IdentityManager verifies:

Pairing Handshake Logic

Title: Pairing Handshake Sequence Sources: crates/palyra-identity/src/pairing/handshake.rs#27-109, crates/palyra-identity/src/pairing/handshake.rs#150-195

mTLS and Transport Security

Once paired, nodes communicate using mTLS. The palyra-identity crate facilitates this by managing the X.509 certificates used by the QUIC and gRPC transport layers.

Certificate Management

Code Entity Mapping

Title: Identity Code Entities and Roles Sources: crates/palyra-identity/src/store.rs#25-31, crates/palyra-identity/src/store.rs#87-92, crates/palyra-identity/src/pairing/handshake.rs#27-52

Revocation and Safety

The system includes mechanisms to protect against brute-force attacks and compromised devices. Sources: crates/palyra-identity/src/pairing/handshake.rs#59-109, crates/palyra-identity/src/pairing/handshake.rs#155-183