Skip to main content
The palyra-identity crate provides the foundation for secure communication and device trust within the Palyra ecosystem. It manages Ed25519 keypairs for device identification, handles X.509 certificate generation via an internal Certificate Authority (CA), and implements a multi-step pairing handshake for new nodes. Security is enforced through Mutual TLS (mTLS) for all node-to-node and node-to-daemon RPC communications.

Identity Core Entities

Palyra uses a tiered identity model where the daemon acts as a Root of Trust for its connected nodes.

Identity Data Flow

The following diagram illustrates how identity materials are generated and stored. Identity Generation & Storage Flow Sources: crates/palyra-identity/src/pairing/manager.rs#20-80, crates/palyra-identity/src/store.rs#87-115, crates/palyra-identity/src/device.rs#1-20

Device Pairing Handshake (TOFU)

Pairing is a Trust-On-First-Use (TOFU) mechanism that upgrades an unauthenticated connection to a trusted, mTLS-secured session. It involves a cryptographic exchange (Device Hello) verified against a pre-shared secret (PIN or QR token).
  1. Start Pairing: The daemon creates an ActivePairingSession with a challenge and an ephemeral X25519 public key crates/palyra-identity/src/pairing/handshake.rs#27-52.
  2. Device Hello: The connecting node generates a DevicePairingHello containing its device_id, public signing key, and a signature over the transcript crates/palyra-identity/src/pairing/handshake.rs#111-118.
  3. Verification: The IdentityManager verifies the signature using the device’s public key and checks the proof (e.g., PIN) crates/palyra-identity/src/pairing/handshake.rs#150-190.
  4. Finalization: Upon success, the device is added to paired_devices and issued its first mTLS certificate crates/palyra-identity/src/pairing/handshake.rs#120-127.
Pairing Sequence Sources: crates/palyra-cli/src/commands/pairing.rs#123-178, crates/palyra-identity/src/pairing/handshake.rs#83-149

mTLS Configuration & Enforcement

Palyra enforces mTLS for all Node RPC communication. The daemon requires a valid client certificate issued by its internal CA for any request to the NodeService.

Server-Side Enforcement

The QuicRuntime and gRPC server use a ClientCertVerifier to validate incoming certificates against the daemon’s Root CA crates/palyra-daemon/src/quic_runtime.rs#19-25.
FeatureImplementationFile Reference
CA Validationrustls RootCertStorecrates/palyra-identity/src/mtls.rs#10-30
Revocation CheckFingerprint-based CRL in IdentityManagercrates/palyra-identity/src/pairing/revocation.rs#5-40
Enforcement Togglenode_rpc_mtls_required flagcrates/palyra-daemon/src/quic_runtime.rs#82-90

Node RPC Test Patterns

Integration tests in node_rpc_mtls.rs verify that: Sources: crates/palyra-daemon/src/quic_runtime.rs#1-120, crates/palyra-daemon/tests/node_rpc_mtls.rs#45-118

Secret Store & Persistence

The palyra-identity crate provides a SecretStore trait to abstract the storage of sensitive identity materials (CA keys, device keys, and state bundles).

FilesystemSecretStore

The FilesystemSecretStore implements encrypted storage using ChaCha20-Poly1305 crates/palyra-identity/src/store.rs#16-23.

State Concurrency

To prevent multiple processes (e.g., CLI and Daemon) from corrupting the identity state, a file-based lock mechanism is used. Sources: crates/palyra-identity/src/store.rs#87-167, crates/palyra-identity/src/pairing/persistence.rs#1-115

Certificate Rotation & Revocation

Certificates in Palyra are designed to be short-lived (DEFAULT_CERT_VALIDITY).

Rotation

The IdentityManager provides issue_gateway_server_certificate to rotate the daemon’s own transport certificates. Nodes are expected to re-pair or use a refresh protocol (managed via the Control Plane) when their leaf certificates approach expiry.

Revocation

Revocation is handled via the revocation.rs module. The daemon maintains:
  1. revoked_devices: A map of Device IDs that are no longer allowed to connect crates/palyra-identity/src/pairing/revocation.rs#10-25.
  2. revoked_certificate_fingerprints: A set of SHA-256 fingerprints for specific certificates that have been invalidated crates/palyra-identity/src/pairing/revocation.rs#27-45.
During the mTLS handshake, the ClientCertVerifier checks the presented certificate’s fingerprint against this list. Sources: crates/palyra-identity/src/pairing/revocation.rs#1-50, crates/palyra-identity/src/mtls.rs#5-35