Skip to main content
This page documents the palyra-identity crate, which serves as the security foundation for the Palyra ecosystem. It manages the internal Certificate Authority (CA), Ed25519 device keypairs, X.509 certificate issuance, and the multi-stage pairing protocol used to establish trust between the daemon and various clients (CLI, Desktop, Browser Extension, and Nodes).

Identity Architecture

Palyra uses a decentralized identity model where every component (daemon, node, or client) possesses a unique DeviceIdentity. Trust is established via a Root CA managed by the daemon’s IdentityManager.

Device Identity

A DeviceIdentity consists of an Ed25519 keypair used for signing and a unique ULID-based device ID.

Certificate Authority (CA)

The CertificateAuthority struct handles the lifecycle of the internal PKI.

Secret Storage

Identity materials (private keys, CA state) are persisted using a SecretStore. Sources: crates/palyra-identity/src/ca.rs, crates/palyra-identity/src/device.rs, crates/palyra-identity/src/store.rs

The Pairing Flow

The pairing flow is a Trust-On-First-Use (TOFU) mechanism that upgrades a shared secret (Pairing Code) into a pinned mTLS identity.

Pairing Sequence Diagram

The following diagram illustrates the interaction between the IdentityManager and a new DeviceIdentity.

Key Functions

Sources: crates/palyra-identity/src/pairing/handshake.rs, crates/palyra-cli/src/commands/pairing.rs

mTLS and Transport Security

Once paired, all node-to-daemon and client-to-daemon gRPC/QUIC communication is secured via mutual TLS (mTLS).

QUIC Runtime

The QuicRuntime in the daemon enforces certificate verification for all incoming connections.

Node RPC mTLS

The node_rpc_mtls subsystem handles gRPC-over-HTTP/2 security.

Security Entity Mapping

System NameCode EntityFile
CA ManagerCertificateAuthoritycrates/palyra-identity/src/ca.rs#34
Identity StoreFilesystemSecretStorecrates/palyra-identity/src/store.rs#87
Pairing LogicIdentityManagercrates/palyra-identity/src/pairing/manager.rs#1
QUIC ServerQuicRuntimecrates/palyra-daemon/src/quic_runtime.rs#19
mTLS ConfigQuicServerTlsConfigcrates/palyra-transport-quic/src/lib.rs#1
Sources: crates/palyra-daemon/src/quic_runtime.rs, crates/palyra-daemon/tests/node_rpc_mtls.rs, crates/palyra-transport-quic/src/lib.rs

Implementation Details

Revocation and Pinning

Pairing is not permanent. The IdentityManager maintains a list of revoked_devices.

Rate Limiting

To prevent brute-force attacks on pairing codes:

Data Flow: Pairing Request

The following diagram maps the CLI pairing command to the underlying identity logic. Sources: crates/palyra-cli/src/commands/pairing.rs, crates/palyra-identity/src/pairing/handshake.rs, crates/palyra-identity/src/store.rs