12. Keystore & Enclave (fleetmesh_node.keystore)
The fleetmesh_node.keystore package manages cryptographic private keys, seed phrases,
key derivation paths, and hardware security enclave integration.
12.1. Keystore Core
The node’s keys on disk.
One JSON file, mode 0600, holding the three secrets constants.json names: the secp256k1 node key (the nostr identity and did:nostr subject), the X25519 agreement key, and the Ed25519 transport key. Generated once, read every start. Nothing else is stored here: grants, receipts and the event store have their own files, and an operator who rotates the node key has a new node.
- class fleetmesh_node.keystore.core.Keystore[source]
Bases:
object- agreement_priv: X25519PrivateKey
- agreement_pub: X25519PublicKey
- transport_priv: Ed25519PrivateKey
- transport_pub: Ed25519PublicKey
12.2. Hardware Enclave Integration
Enclave-shaped DID keystore: WebAuthn/COSE wire formats over a software key.
What this module does: 1. Generates a P-256 (or secp256k1) key with cryptography, holds it in process
memory and writes it to disk as priv_hex under the node directory.
Produces WebAuthn-shaped structures - authenticatorData, clientDataJSON, COSE EC2 keys - and a self-signed attestation statement, with no external dependency beyond cryptography.
EnclaveKeystore: a drop-in for Keystore that tags the events it signs [‘enclave’, hardware_tier, pubkey_multibase, attestation_sig_hex] and adds the key to the DID document’s verification methods.
What it does not do, stated plainly so nobody relies on it: - No Secure Enclave, TPM or FIDO authenticator API is driven. The key never
leaves software. detect_hardware_enclave() only reports the platform (apple-secure-enclave on Darwin/arm64 means “this host has one”, not “the key is in it”); on every other host the tier reads emulated-enclave.
The attestation is self-asserted: the statement is signed by the same software key it attests, and user_presence / user_verified are fixed True with no biometric or presence check behind them. A peer verifying it learns only that the ECDSA signature is valid.
Verifiers must treat the enclave tag as a key-format hint, not as hardware provenance. A real hardware backend (and honest tier names) is tracked in docs/architecture-review-2026-10-06.md R8.
- fleetmesh_node.keystore.enclave.detect_hardware_enclave()[source]
Detect available hardware security enclave capabilities on the host.
- class fleetmesh_node.keystore.enclave.EnclaveSignature[source]
Bases:
objectHardware enclave signature with attestation metadata.
- class fleetmesh_node.keystore.enclave.EnclaveKey[source]
Bases:
objectHardware Enclave-protected asymmetric keypair.
- sign(message, challenge=None)[source]
Sign message inside enclave isolation, returning signature + hardware attestation.
- Parameters:
- Return type:
- verify(message, signature_bytes)[source]
Verify signature (either 64-byte raw or DER format) against this key.
- class fleetmesh_node.keystore.enclave.WebAuthnCredential[source]
Bases:
objectW3C WebAuthn Level 3 Passkey Credential.
- __init__(credential_id, rp_id, user_name, enclave_key, sign_count=0)[source]
- Parameters:
credential_id (bytes)
rp_id (str)
user_name (str)
enclave_key (EnclaveKey)
sign_count (int)
- Return type:
None
- make_attestation_object()[source]
Produce WebAuthn attestationObject (CBOR map: fmt, authData, attStmt).
- Return type:
- create_assertion(challenge, origin='https://meshnode.example.org', user_verification=True)[source]
Produce WebAuthn authentication assertion (response to navigator.credentials.get).
- class fleetmesh_node.keystore.enclave.EnclaveKeystore[source]
Bases:
objectHardware-Enclave augmented Keystore implementing KeyStoreProtocol.
- __init__(node_sk, agreement_seed, transport_seed, enclave_key=None, hardware_tier=None)[source]
- Parameters:
node_sk (str)
agreement_seed (bytes)
transport_seed (bytes)
enclave_key (EnclaveKey | None)
hardware_tier (str | None)
- Return type:
None
- multikeys()[source]
Multikeys for node descriptor and DID document, including hardware enclave key.
- sign_event_with_attestation(created_at, kind, tags, content)[source]
Create signed Nostr event with attached in-band hardware enclave attestation tag.
- attest_event(event)[source]
Produce detached hardware attestation receipt over an already-formed event ID.
- fleetmesh_node.keystore.enclave.verify_enclave_attestation(event)[source]
Verify the hardware enclave attestation tag of a Nostr event.
- fleetmesh_node.keystore.enclave.verify_signature(message, multikey_str, signature_bytes)[source]
Verify an arbitrary message signature against an enclave multikey.