Configure versioned master keys
Version 1 continues to usePROVIDER_KEY_ENCRYPTION_KEY. Before each later rotation, deploy the next secret to every application and worker instance using the versioned name:
Initialize the external erasure ledger
Crypto-erasure evidence must survive a database restore. Configure a durable ledger path whose storage lifecycle is independent from application releases and database backups, plus an independent HMAC signing key:EXTERNAL=1 attestation. Every application replica and restore worker must see the same durable file with atomic create and rename semantics. Keep the signing key outside the database-backup lifecycle.
Provision and sign the empty ledger before the first application startup. This explicit command is the only path allowed to create the ledger and its separate signed .genesis identity marker. It refuses to bootstrap once any provider credential or encryption-key history exists. Repeating it against an intact empty ledger verifies the existing identity and never replaces it.
fsync support.
Inspect the current safe registry metadata before an operation. This output never includes wrapped keys, ciphertext, or fingerprints:
Rotate the active version
After the next versioned environment variable is available everywhere, rotate atomically:decrypt_only and creates exactly one new active version. Credential writes and rotations serialize on the organization, and the database rejects encryption under an inactive version. Reads of permitted historical credentials continue to work.
Re-encrypt historical credentials
Create a durable re-encryption run from adecrypt_only version to the active version:
Revoke or erase a historical version
Revocation immediately rejects application reads but preserves wrapped key material for a later, separately approved erasure:decrypt_only or revoked versions can be erased. A migrated legacy-derived version with remaining ciphertext must first be fully re-encrypted; this prevents presenting a status change as cryptographic destruction when the old key remains derivable.
The erase command first appends and fsyncs a signed, hash-chained external tombstone and only then clears database key material. If the process stops between those operations, credential access fails with PROVIDER_CREDENTIAL_ERASURE_REPLAY_REQUIRED. Replay is idempotent and clears material reintroduced by a pre-erasure database restore:
Restore procedure
Mount the original external ledger and signing key before starting any process against a restored database. Runerasure-replay explicitly as a restore gate, or let the application startup gate perform it, and require a successful result before enabling traffic. Verify that:
- every applicable tombstone has an
appliedreplay receipt; - the corresponding registry row is
erasedwith no key reference, fingerprint, or wrapped-key fields; - an unaffected organization’s credential remains readable; and
- a second replay reports zero newly applied entries.