Privasys
Enclave Vaults

Architecture

How the Enclave Vaults distributed vHSM is built. Typed key objects, in-enclave operations, RawShare distribution, per-key policy, and a controlled lifecycle for caller-enclave version changes.

Enclave Vaults runs as the enclave-os-vault module inside an Intel SGX enclave on top of Enclave OS Mini. It inherits the OS's attestation stack, sealed storage, RA-TLS ingress, and OIDC token verification.

A production deployment is a constellation of vault enclaves on independent machines. The vaults do not coordinate with each other; coordination is driven by the client SDK on behalf of the key owner.

               ┌──────────────────────────────────────────────────┐
               │            Vault directory                       │
               │       (the control plane, GET /api/v1/vaults)    │
               │       returns endpoints + MRENCLAVE              │
               └──────────────────────────────────────────────────┘
                                         ▲
                                         │ discover (untrusted phonebook)
                                         │
        ┌──────────────────────────┐     │
        │    Client SDK            │─────┘
        │  directory client        │
        │  Client                  │
        │  Constellation           │──── mutual RA-TLS (one channel per vault) ────┐
        └──────────────────────────┘                                               │
                                                                                   ▼
        ┌─────────────────┐   ┌─────────────────┐   ┌─────────────────┐   ┌─────────────────┐
        │   Vault #1      │   │   Vault #2      │   │   Vault #3      │   │   Vault #4      │
        │   (SGX)         │   │   (SGX)         │   │   (SGX)         │   │   (SGX)         │
        │                 │   │                 │   │                 │   │                 │
        │  KeyObjects     │   │  KeyObjects     │   │  KeyObjects     │   │  KeyObjects     │
        │  + KeyPolicy    │   │  + KeyPolicy    │   │  + KeyPolicy    │   │  + KeyPolicy    │
        │  + audit log    │   │  + audit log    │   │  + audit log    │   │  + audit log    │
        │  + sealed KV    │   │  + sealed KV    │   │  + sealed KV    │   │  + sealed KV    │
        └─────────────────┘   └─────────────────┘   └─────────────────┘   └─────────────────┘

      Each vault is independently authoritative for the key objects it holds.
      The client SDK fans out across the constellation; vaults never talk to each other.

Trust boundary

The trust boundary is the enclave. The host operating system, the cloud provider, the on-call operator, and other tenants of the same machine sit outside the boundary. They can take a vault down but they cannot read its sealed state, see its plaintext key material, or perform an operation against the policy.

Each vault publishes its identity through an RA-TLS certificate whose X.509 extensions carry the SGX quote, the MRENCLAVE measurement, and a Merkle root committing to the vault's runtime configuration (OIDC issuer, audience, attestation servers, registered modules). Clients verify all of this before sending any request.

Typed key objects

A vault holds typed key objects. Each KeyObject has a stable handle, a KeyType, an exportable flag fixed at creation, a KeyPolicy, and sealed key material whose representation depends on the type.

TypeMaterialDefault operationsExportable by default
RawShareOne Shamir share of a secretExportKey (an authorised client fetches a quorum of shares and reconstructs the secret)yes
Aes256GcmKeySymmetric key, sealed inside the enclaveWrap, Unwrap (the vault chooses the IV)no
P256SigningKeyAsymmetric key pair, sealed inside the enclaveSign (a message the vault hashes, or a pre-computed SHA-256 digest it signs raw); the public key is readableno
HmacSha256KeyMAC key, sealed inside the enclaveMacno
FrostEd25519One share of an Ed25519 key that the vaults generated together; no vault holds the keySign by any t of the vaults together; the public key is readablenever

Export is off for every type except RawShare. A signing key cannot be exfiltrated, even by its owner: every signature happens inside the enclave, and anyone verifies it with the public key.

Every key object carries a KeyPolicy. The policy is part of the sealed state, and any change to it is recorded in the audit log.

How the constellation distributes trust

There are two complementary patterns, chosen per key.

Pattern A: distributed shares (RawShare)

For secrets the owner wants to keep recoverable across the constellation, and wants to keep distributed even at rest, the secret is split with Shamir Secret Sharing on the client side. Each vault stores one share as a RawShare key object. To use the secret, an authorised client fetches a quorum of shares over mutual RA-TLS and reconstructs the secret inside its own trusted environment.

    ┌─────────────────────┐
    │  Owner / authorised │
    │  client (in a TEE)  │
    └──────────┬──────────┘
               │   1. mutual RA-TLS to N-of-M vaults
               │   2. fetch one share from each
               │   3. reconstruct secret locally
               ▼
      ┌───────────────────┐
      │  Reconstructed    │
      │  secret in client │
      │  enclave memory   │
      └───────────────────┘

    Vaults do not coordinate. Each independently checks the caller's
    attestation against the share's KeyPolicy before releasing it.

The secret is split into one share per vault, n in all, and any k of them (the threshold, at least 2) reconstruct it. A single compromised vault leaks one share. By the information-theoretic guarantee of Shamir's scheme, fewer than k shares reveal nothing about the original secret, and the secret survives the loss of up to n - k vaults. There is no threshold cryptography or multi-party computation involved; reconstruction is a polynomial interpolation done by the client.

RawShare is the right pattern for things like LUKS volume keys for confidential VMs, master KEKs that are reconstructed on a controlled schedule, and any secret whose value the owner ultimately needs in cleartext somewhere.

Pattern B: in-enclave operations on a typed key

For signing keys, AES data keys and HMAC keys, the value the owner needs is not the key itself but the result of an operation on it. A typed key is held whole by one vault of the constellation, sealed to that vault's MRENCLAVE, and never exported. Clients dial that vault, present their authentication and any required approvals, and receive the operation's result.

The key is not split or copied: Shamir sharing needs the secret reassembled to use it, which a key that must never leave the enclave cannot allow. So a typed key is as available as the one vault that holds it. For a signing key that must survive the loss of a vault, use a threshold Ed25519 key (Pattern C). Treat it as a working key with a bounded life, as the Key lifecycle describes: keep what you need to carry on without it (the public key of a signing key; data re-wrapped under a newer version), and rotate before it expires.

    ┌──────────────────────┐
    │  Authorised caller   │
    │  (TEE, OIDC subject) │
    └──────────┬───────────┘
               │   mutual RA-TLS to one (or several) vaults
               │   Sign(handle, msg)
               ▼
    ┌──────────────────────┐
    │  Vault enclave       │
    │  - verify policy     │
    │  - run op on key     │  -- raw key never leaves --
    │  - return signature  │
    └──────────────────────┘

This pattern matches classical HSM semantics: the key never leaves the hardware, and the policy is what governs whether an operation is allowed.

Pattern C: threshold Ed25519 keys (FrostEd25519)

A threshold Ed25519 key is one signing key that no single vault holds, and neither does the client. The vaults of the constellation generate it together with a distributed key generation, and each keeps one share. Any t of the n vaults sign together, and the result is one ordinary 64-byte Ed25519 signature (JOSE alg EdDSA) that any Ed25519 verifier accepts. The scheme is FROST(Ed25519, SHA-512), RFC 9591.

    ┌──────────────────────┐
    │  Authorised caller   │   calls each vault directly, with its
    │  (owner, TEE, ...)   │   own credentials, and relays the
    └──────────┬───────────┘   vaults' messages between them
       ┌───────┼───────┐
       ▼       ▼       ▼
    ┌──────┐┌──────┐┌──────┐
    │share1││share2││share3│  each vault checks the key's policy,
    │      ││      ││      │  audits the Sign, returns its part
    └──────┘└──────┘└──────┘
               │
               ▼
     one Ed25519 signature, verified under the key's public key

Creation. The client drives the rounds: it calls every vault in turn and passes each vault's messages to the others. The vaults never call each other.

  • The secret messages of the key generation are sealed from one vault to another, under keys each vault binds into its SGX quote. The client carries ciphertext it cannot open.
  • Every vault verifies the other vaults' quotes through the attestation servers. It accepts a vault only if it runs the same MRENCLAVE as itself and is not an SGX debug enclave, whose memory its host could read.
  • A vault stores its share only after every other vault has confirmed the same transcript and the same public key. If any check fails, no share is kept.

Signing. The client asks t vaults to sign.

  • Each vault checks the key's policy itself, against the caller's own credentials (the owner's token, an app's attestation, approvals), and writes the Sign to its own audit log. No vault vouches for a caller on another's behalf.
  • The one-time signing values (nonces) live only in enclave memory: they are never sealed or stored, are erased before a vault returns its part, and are lost on restart. A signing session belongs to the caller that opened it.
  • Any vault combines the parts and checks the result against the public key before it is returned.

Properties. The key is never exportable: there is no material to export. It survives the loss of up to n - t vaults, and fewer than t shares cannot sign. It expires after 90 days like every key.

Renewal keeps the public key. Renewing a threshold key gives it a fresh 90 days under the same handle and the same public key, on the active constellation: in place when the key is already there, or moved there after a vault upgrade.

  • The key's current vaults each deal a fresh share of the same key to the new vaults, sealed to keys the new vaults bind into their attestation. No vault and no client holds the key at any point.
  • Each new vault checks every piece it receives against the key's existing public data. It stores its share only after every new vault has confirmed the same result.
  • Every share changes, and old shares cannot be combined with new ones.
  • The owner approves each renewal in the wallet. The approval names the exact new vaults, the threshold and the vault build the key goes to, and a renewal cannot change the key's policy. The wallet shows that build as a published release, which it checks itself. The threshold may change at renewal.

Rotating a threshold key is different: it creates a new key with a new public key. Keys created before vault v0.39.0 cannot be renewed this way; rotate them, or let them expire.

The three patterns share the same KeyPolicy schema and the same lifecycle, so the developer experience is uniform.

Per-vault sealed storage

Each vault has its own KV store sealed with an MRENCLAVE-bound AES-256-GCM key, provided by enclave-os-kvstore. Only the same enclave binary on the same physical host can unseal it. The KV store holds:

KeyValuePurpose
key:{handle}JSON KeyRecordType, exportable flag, policy and policy version, expiry, sealed material, and the key's pending profiles (caller-enclave attestation profiles staged for future inclusion in its TEE principals, up to 16).
audit:{handle}:{seq}JSON AuditEntryAppend-only log of every operation on a key, allowed or denied.
tomb:{handle}JSON TombstoneWhat remains of a deleted key until its original expiry: never material, only enough to keep the name taken and answer its principals.
index:{owner}JSON list of handlesThe keys each owner holds, for listing.
prev:{handle}JSON KeyRecordA threshold key's previous share, kept during a renewal in place until the renewal is finalised.

The bootstrap configuration (OIDC issuer, audience, attestation servers, registered modules) is sealed by Enclave OS Mini on first boot. The host OS, hypervisor, and cloud provider see only encrypted bytes.

Vault identity

Each vault has a member identity: a signing key it generates and seals on first start, and a member id, the SHA-256 of that public key under a fixed domain. GetVaultIdentity returns the member id, the public key, the vault's MRENCLAVE, a billing id, an SGX quote whose report data binds the member id and billing id, and the capabilities the build supports (generations-v1, update-policy-from-v1 and tombstones-v1 today), so a client knows which protocol features it can use. Binding 2 approvals name the member ids of the constellation, and each vault checks that it is among them. A client trusts a member identity only when it reads it over an RA-TLS connection pinned to that attested vault.

Mutual RA-TLS ingress

The vault's RA-TLS server requires mutual TLS for every interesting operation. The client presents either:

  • A bearer OIDC token in the request envelope. The vault verifies the token via JWKS against the configured issuer and audience, and reads the sub and roles claims to evaluate the policy.
  • A peer RA-TLS certificate when the caller is itself a TEE. The vault parses the SGX or TDX quote out of the X.509 extensions, verifies it through the configured attestation server, and matches the measurement against the key's policy.
  • Both. Sensitive policies typically require a calling enclave with the right MRENCLAVE, a manager OIDC token, and a fresh wallet approval, all together.

Audit log

Every operation on a key, allowed or denied, appends an entry to that key's audit log: a sequence number, the time, the operation, the caller, the outcome, and a reason when it was refused. The log is sealed with the rest of the KV store, and any principal of the key can read it through the audit RPC (privasys vault key audit).

Caller-enclave version changes (the pending-profile flow)

This is one of the most important properties of the v0.19 design, and it deserves a careful framing.

The caller of a vault is typically a customer application running in its own enclave (for example, a WASM enclave or a TDX VM running on the Privasys platform). Its key policy refers to a specific MRENCLAVE (or to an attestation profile that includes that MRENCLAVE). When the developer ships a new version of the application, the new build has a new MRENCLAVE. By default, that new MRENCLAVE has no permission to use the keys the previous version was using.

This is by design. The platform team chooses when to ship a new build of the customer's application; the platform team must not therefore be in a position to silently grant a freshly-built measurement access to the customer's key material. Adding the new MRENCLAVE to a key's policy is an act that belongs to the key owner (the customer), not to the platform.

The pending-profile lifecycle implements that invariant.

   1. The platform builds v(N+1) of the customer app and records
      its MRENCLAVE in the control plane.

   2. The owner uses the SDK (or a portal that drives the SDK)
      to call StagePendingProfile(handle, profile_v_n_plus_1).

      Each vault in the constellation stores the profile in its
      pending-profile slot. The key's TEE principals are
      unchanged. v(N+1) cannot yet read the key.

   3. The owner reviews the change (commit range, build inputs,
      measurement) and approves it with a fresh wallet or passkey
      step-up bound to this promotion.

   4. The owner calls PromotePendingProfile(handle, profile_id).

      Each vault checks the step-up against the key's
      policy and atomically adds the pending profile to the key's
      TEE principals. v(N+1) is now authorised.

   5. The platform schedules v(N+1), v(N) is retired on its own
      schedule. Both versions can coexist until the owner removes
      v(N) from the policy.

The fan-out is driven by the client SDK on the owner's side. The vaults do not coordinate behind the operator's back; the directory never sees policies, profiles, or approvals. A single compromised vault still cannot promote a profile on its own, because the policy requires approvals from authentic principals.

A separate auto_migrate_to_next_attestation_profile flag exists for owners who explicitly opt in to hands-off rollout of runtime-only changes. It is off by default, and only the owner can switch it.

Vault enclave version changes

The pending-profile flow is about the caller's MRENCLAVE in a key's policy. Upgrading the vault's own enclave to a new MRENCLAVE is a separate concern and is handled by the deployment model, not by the per-key lifecycle.

The vault directory models each vault version as a constellation: a set of vault instances that share one MRENCLAVE, attestation server, and OIDC configuration. A new vault build is a new constellation, which an operator activates; at most one is active per environment. To roll a new vault enclave version forward, we stand up the new constellation alongside the old one and make it the active one. New keys and new key versions are created on the active constellation. Existing keys stay on the constellation that created them, their home, which keeps serving them until they expire: the platform addresses each key at its home, and does not retire a constellation while it still holds an unexpired key. Sealed storage stays with its vault version. A key reaches the new constellation when it is renewed, carrying its policy byte for byte: the platform renews the storage keys of running apps, and an owner renews their own keys and secrets. The old generation is then deleted with the owner's approval naming its successor, or expires. See Key lifecycle.

Bootstrap and configuration

On first boot, each vault accepts a bootstrap configuration over an authenticated channel: OIDC issuer, audience, attestation server URL(s), registered modules, intermediate CA cert and key for RA-TLS issuance. The vault seals this configuration and refuses to use a different one on subsequent boots without a recorded reconfiguration event. The configuration is committed into the Merkle root attested by the vault's RA-TLS certificate, so clients can detect any drift.

Because the audience is part of that sealed configuration, a constellation accepts tokens for one audience only. Privasys runs its production vaults on privasys-platform and its test platform's vaults on privasys-platform-test, so a token issued for one environment is refused by the other's vaults. The platform API reports each constellation's audience (oidc_audience), which tells a client which token to request.

Standard interfaces

The RA-TLS wire protocol described above is the native surface. On top of it, the same enclave operations are reachable through the interfaces existing software already speaks: a PKCS#11 3.1 module, a KMIP 2.1 gateway, and a REST API plus CLI. These are front-ends over the same policy engine and data plane, so they add no new trust boundary. The Standard Interfaces page covers how each maps onto the vault and where the standard client's reach ends.

Edit on GitHub