api.wavis.xyz), see
Authentication.
The three FHE keys
Every FHE session has three keys generated together as a triple:| Key | Size | Where it lives | What it does |
|---|---|---|---|
| Secret key | ~5 KB | Client only — never sent | Decrypts ciphertexts |
| Public key | ~2 MB | Anywhere | Encrypts plaintexts |
| Evaluation key | ~40 MB | Server | Bootstraps gates on ciphertext |
Generating keys (Python)
seed=... for
reproducibility in tests.
Generating keys (REST — server-side, deprecated)
POST /api/v1/keys/generate will generate keys server-side. This is not
recommended because it requires the server to briefly hold the secret key
to derive the evaluation key. Prefer client-side keygen + /tfhe/eval-session
upload (FHE-blind mode).
secret_key only if WAVIS_ALLOW_SK_IN_RESPONSE=true
on the server (off by default). Otherwise, the secret key is held in encrypted
session storage and you can use it via session ID — but the cleanest pattern
is to generate locally.
Parameter selection
For TFHE (Boolean gates), use a named preset — see Performance. For CKKS (arithmetic), the four parameters interact:| Parameter | What it controls | Trade-off |
|---|---|---|
poly_degree | RLWE ring size (slot count) | Higher = more parallelism + more security, but slower |
scale_bits | Precision of fixed-point encoding | Higher = more decimal places, but consumes noise budget faster |
max_depth | RNS modulus chain length | Higher = deeper circuits without bootstrap, but bigger ciphertexts |
security_level | Bits of security | ”128-bit” is required for production |
| Use case | poly_degree | scale_bits | max_depth |
|---|---|---|---|
| Demo / prototype | 4096 | 30 | 5 |
| ML inference (MLP, ≤5 layers) | 8192 | 40 | 8 |
| Small CNN | 16384 | 40 | 12 |
| Deep transformer | 32768 | 50 | 14 |
poly_degree values are NIST PQC-validated: 64, 256, 4096, 8192,
16384, 32768. The smaller two (64, 256) are for testing only and don’t
provide 128-bit security — the API returns
X-Security-Warning if you use them with a non-testing security level.
Encryption
Once you have keys, encryption is local and instant:Uploading the evaluation key (FHE-Blind)
Session lifecycle
| Phase | Duration | What happens |
|---|---|---|
| Created | Instant | Session ID returned, eval key indexed |
| Active | Up to 1 h (default TTL) | Gates evaluated, ciphertexts cached |
| Idle | Last 5 min of TTL | No new ciphertexts cached |
| Expired | After TTL | Eval key zeroed, ciphertexts evicted |
Deleting a session (immediate)
204 No Content. The eval key is zeroed and all cached ciphertexts
are deleted within 5 seconds. Always delete sessions when done — it frees
server memory and ends billing for that key’s footprint.
Deleting an FHE key (CKKS workflow)
For the/keys/* endpoints (CKKS):
- The public key
- The evaluation key
- All ciphertexts associated with the key (~unlimited)
Key rotation strategy
For long-running products:- Generate a fresh key per session — the simplest and safest pattern. Each user’s session has its own keypair.
- Or rotate at fixed intervals — generate new keys daily, transition users gradually.
- Avoid long-lived global keys — if a single secret key encrypts a year of data and is later compromised, that’s a year of plaintext exposure.
Storing the secret key client-side
The secret key is bytes — store it however your platform stores secrets:- Server-side service: environment variable, AWS KMS, GCP Secret Manager, HashiCorp Vault.
- Browser app: the secret key shouldn’t live in browser storage. Either derive it from a passphrase + PBKDF2 each session, or use the WebAuthn credentials API to bind to a hardware-backed key.
- Mobile app: iOS Keychain (
kSecAttrAccessibleWhenUnlockedThisDeviceOnly) / Android Keystore.
Common mistakes
❌ Uploading the secret key to the server. This defeats the entire model. WAVIS’s/keys/upload endpoint accepts only public_key and eval_key;
it rejects requests containing a secret key.
❌ Reusing a key across users. If user A’s key is used to encrypt user
B’s data, A can decrypt B’s data. Use one key per security boundary.
❌ Forgetting to delete sessions. Active sessions count against your
session quota and consume server memory. Delete when done.
❌ Choosing weak parameters. poly_degree=64 produces fast but
insecure-by-modern-standards keys. The API warns; production code should
treat the warning as an error.
Next Steps
Server Mode Example
End-to-end FHE-blind workflow
Keys API Reference
All key endpoints with schemas