- Client
keygen()locally POST /tfhe/eval-sessionwith the eval key (FHE-blind mode)POST /tfhe/gateorPOST /tfhe/batchfor each operationDELETE /tfhe/session/{id}to release server resources
POST /api/v1/tfhe/session
Create a server-managed session. For demos and quick tests only — the
server holds the secret key. For production, use /eval-session.
Auth: TRIAL+
Request
| Field | Type | Required | Allowed |
|---|---|---|---|
preset | string | Yes | "fast_128", "standard_128", "conservative_128" |
Response — 201 Created
POST /api/v1/tfhe/eval-session
Create an FHE-blind session by uploading a client-generated evaluation key.
Recommended for production.
Auth: TRIAL+
Request
| Field | Type | Required | Notes |
|---|---|---|---|
eval_key_b64 | string | Yes | base64-encoded eval key, ≤40 MB |
Response — 201 Created
preset is auto-detected from the eval-key parameters.
Response — 413 Payload Too Large
POST /api/v1/tfhe/gate
Evaluate a single Boolean gate.
Auth: TRIAL+
Request
| Field | Type | Required | Notes |
|---|---|---|---|
session_id | string | Yes | From /session or /eval-session |
op | string | Yes | "NAND", "AND", "OR", "XOR", "NOR", "XNOR", "NOT", "MUX" |
a | string (base64) | Yes | First operand ciphertext |
b | string (base64) | No | Second operand. Required for binary gates; omit for NOT |
sel | string (base64) | No | Selector input. Required only for MUX |
MUX: a is d1 (input when sel=1), b is d0 (input when sel=0),
sel is the selector.
Response — 200 OK
Bootstrap costs
| Gate | Bootstrap ops | Cost (JPY) |
|---|---|---|
| NAND, AND, OR, NOR | 1 | ¥0.10 |
| XOR, XNOR | 4 | ¥0.40 |
| NOT | 0 | ¥0.00 (free, no bootstrap) |
| MUX | 3 | ¥0.30 |
POST /api/v1/tfhe/batch
Evaluate multiple gates in one request. Sequential execution (not parallel),
but 30% discount for ≥32 ops.
Auth: TRIAL+
Request
| Field | Type | Required | Notes |
|---|---|---|---|
gates | array | Yes | 1–1024 gate objects, each like /gate request |
Response — 200 OK
gates.length >= 32:
POST /api/v1/tfhe/session/{session_id}/encrypt
Server-side encryption. Only available for v1 (non-blind) sessions.
Auth: TRIAL+
Request
Response — 200 OK
/tfhe/gate or /tfhe/batch.
POST /api/v1/tfhe/session/{session_id}/decrypt
Server-side decryption. Only available for v1 (non-blind) sessions.
Auth: TRIAL+
Request
Response — 200 OK
GET /api/v1/tfhe/session/{session_id}
Get session usage stats.
Auth: TRIAL+
Response — 200 OK
DELETE /api/v1/tfhe/session/{session_id}
Release session resources (eval key, cached ciphertexts).
Auth: TRIAL+
Response — 204 No Content
No body. Cleanup completes within 5 seconds.GET /api/v1/tfhe/sessions
Admin endpoint — list all sessions for the account.
Auth: BILLING+ (account_admin)
Response — 200 OK
Common errors
| Code | Status | Meaning |
|---|---|---|
SESSION_NOT_FOUND | 404 | session_id invalid or expired |
SESSION_EXPIRED | 410 | Session TTL elapsed (1 h default) |
INVALID_CIPHERTEXT | 400 | Ciphertext bytes don’t match session params |
INVALID_GATE_OP | 400 | op not in supported set |
MISSING_OPERAND | 400 | b missing for binary gate, or sel missing for MUX |
BATCH_TOO_LARGE | 400 | More than 1024 gates in one batch |
PAYLOAD_TOO_LARGE | 413 | Single ciphertext >2 MB or eval key >40 MB |
Performance tips
- Batch ≥32 ops for the 30% discount and to amortize HTTP overhead.
- Reuse sessions — a session is valid for 1 hour; one session per logical workflow, not one per gate.
- Don’t ping-pong ciphertexts. Computing locally with the SDK is faster than round-tripping to the server when network latency dominates.
- Use NOT freely — it’s a unary trivial operation, costs ¥0, and runs in microseconds.
Next Steps
Server Mode Example
Full FHE-blind walkthrough
Compute API
CKKS arithmetic operations