Skip to main content

Implicant SDK

Python client for the Implicant FHE inference platform. Encrypts one row locally under BGV, sends the ciphertext to the platform for homomorphic evaluation, and decrypts the result. The server never sees plaintext; the secret key never leaves the process.

The classifier head runs server-side under FHE (Variant B): the platform returns one ciphertext with the class scores packed contiguously, which the client decrypts (unsigned) and decodes with decode_class_scores before threshold/argmax. W / b never reach the client.

Pure Python — all crypto comes from implicant-fhe (helut.client). Architecture and byte contracts: docs/architecture.md.

Install

pip install implicant

Pulls implicant-fhe (the helut crypto wheel) from PyPI automatically. Wheels ship for CPython 3.10–3.14 on macOS-arm64 and manylinux x86_64 only. On any other target — Windows, Linux aarch64, macOS x86_64 — there is no wheel and no source fallback, so pip stops with No matching distribution found for implicant-fhe.

Developers

python3.13 -m venv .venv313
.venv313/bin/pip install -e ".[dev]"
.venv313/bin/pytest tests/ -v      # ~550 tests (real BGV keygen; slow)

To pin an unreleased implicant-fhe build, stage its wheel in ./wheels/ and add --find-links wheels/; the published versions resolve from PyPI without it.

Running an inference (CLI)

The implicant CLI is the client-side workflow: configure once, then run encrypted predictions. Everything stays local except the ciphertext and the public keys — the secret key never leaves your machine.

This release is demo-only: every predict needs --demo (or IMPLICANT_DEMO=1 in the environment) and runs on the bundled demo keypair — see Demo mode for what that implies. Without the flag, predict exits with an explanatory message.

1. Point the client at the platform

implicant init --api-url https://api.implicant.example

Writes ~/.implicant/config.toml. Run implicant status to confirm the configured api_url and list any locally cached keys.

2. Set your API token

The bearer token is read from the environment, never stored on disk:

export IMPLICANT_API_KEY="imp_..."

3. Discover the available models

The SDK ships a hand-maintained registry of the models servable on the platform (there is no server-side listing endpoint yet):

$ implicant models list
credit        Predicts whether a borrower will default on a loan
bankfraud     Predicts whether a bank account application is fraudulent
heartdisease  Predicts whether a patient has heart disease
cancer        Predicts whether a breast tumor is malignant or benign
diabetes      Predicts whether a patient will be readmitted within 30 days

Try one:           implicant predict --model <slug> --sample --demo
Editable example:  implicant models sample <slug> --out row.json
Then:              implicant predict --model <slug> --input row.json --demo

The listed slug is the --model value for predict.

4. Prepare the input row

One row of raw feature values, as a JSON object (or a single-row CSV). The keys are the feature names the model expects. Each known model ships a bundled example row — the fastest way to get a correct starting point:

implicant models sample diabetes --out row.json   # or no --out to print to stdout
{
  "age": "[80-90)",
  "medical_specialty": "InternalMedicine",
  "discharge_disposition_id": 6.0,
  "time_in_hospital": 4.0,
  "num_lab_procedures": 56.0,
  "num_medications": 16.0,
  "number_emergency": 1.0986122886681098,
  "number_inpatient": 2.3978952727983707,
  "number_diagnoses": 9.0
}

Edit the values by hand to test different inputs, then feed the file to predict. Keep categorical values as quoted strings ("[80-90)" above) — they are matched textually against the model's fitted levels. (--out refuses to overwrite an existing file unless you pass --force.)

5. Predict

implicant predict --model diabetes --input row.json --demo

Or skip the file entirely and run on the bundled example row:

implicant predict --model diabetes --sample --demo

This fetches the model manifest, generates (or reloads) your keys, uploads the public keys on first use, encrypts the row locally, sends the ciphertext, then decrypts and decodes the returned class scores. Progress streams to stderr (with a spinner on the current step in a terminal) and the decision lands on stdout:

✓ Fetching model configuration
✓ Preparing encryption keys
✓ Encrypting input data
✓ Evaluating on the server (encrypted)
✓ Decrypting server response
Final decision: readmitted

Add --json for the machine-readable result instead of the decision line (progress stays on stderr, so piping stdout to jq is safe):

{
  "key_id": "bgv-n16384-L8-5f657f27f77c",
  "label_index": 1,
  "label": "readmitted",
  "scores": [2028]
}

Add --no-persist-key to use an ephemeral secret key for a single run (nothing written to disk; keys are regenerated and re-uploaded next time).

Managing keys

The first prediction for a key_id persists your secret key to ~/.implicant/keys/<key_id>/secret_key.bin (mode 0600) so later runs skip keygen. Inspect and clean up the local store:

implicant keys list            # list key_ids; flags which have a persisted SK
implicant keys rm <key_id>     # delete one stored key (secret + public)
implicant keys purge --yes     # delete all stored keys

Use (Python)

The same flow is available programmatically:

from implicant import ImplicantClient, list_known_models, sample_row
from implicant.transport import HttpxTransport

for m in list_known_models():          # discover: (slug, description) pairs
    print(m.slug, "—", m.name)

row = sample_row("diabetes")           # fresh mutable copy of the bundled example
row["time_in_hospital"] = 2.0          # hand-tweak values for testing

model = next(m for m in list_known_models() if m.slug == "diabetes")
client = ImplicantClient(
    HttpxTransport(base_url="https://api.implicant.example", api_key="imp_..."),
    key_cache_dir="~/.implicant/keys",
)
result = client.predict("diabetes", row, class_names=model.class_names)
print(result.prediction.label)

Demo mode

Demo mode skips FHE key generation by loading a pre-generated keypair shipped inside the package, and skips the public-key upload (the platform already holds the matching public bundle). It exists so a prediction can run immediately in a live demo, without first-use key generation and without uploading the multi-hundred-megabyte public key set. In this release it is required: predict refuses to run outside demo mode.

Activate with an environment variable (applies to the whole session):

export IMPLICANT_DEMO=1
implicant predict -m cancer -i row.json

Or per-command — combined with --sample, this is a zero-setup end-to-end run:

implicant predict -m cancer --sample --demo

All five registry models (credit, bankfraud, heartdisease, cancer, diabetes) are provisioned with bundled demo keys; a model ID without a bundled key raises an error in demo mode.

Security warning — demo mode is not private. The demo secret key is shipped inside the package and is therefore public: anyone with the wheel can decrypt anything encrypted in demo mode. Never use demo mode for real or sensitive data. Normal mode (the default) generates a secret key that never leaves your machine.

Web UI (demo)

A local web interface for live demonstrations — the four-step flow (choose a model, generate keys on your machine, watch your row get encrypted, see the blind result) with every visual driven by the real pipeline: a live execution-path strip, genuine per-phase timings, the exact encrypted payload and response sizes, a plain-words inventory of what the request contains, and an in-memory history of the session's inferences:

pip install "implicant[ui]"   # the ui extra ships from 0.7.0
export IMPLICANT_API_KEY="imp_..."
implicant ui        # starts a localhost server and opens your browser

All cryptography runs in the local Python process; the browser only renders. The UI is demo-only in this release and runs on the shared demonstration key (see the demo-mode warning above). On Windows, run the same UI via Docker:

docker build -t implicant-ui -f docker/Dockerfile .   # from the repo root
docker run --rm -p 8642:8642 \
  -e IMPLICANT_API_KEY=imp_... \
  -e IMPLICANT_API_URL=https://your-platform \
  implicant-ui
# then open the printed URL — including the #token — in your browser

By default the page is protected by a per-launch URL token — the printed #fragment is the credential, so keep the full URL. For a deliberately public deployment behind a reverse proxy (e.g. a demo site), start with implicant ui --public-demo (or -e IMPLICANT_UI_PUBLIC_DEMO=1 in Docker): no token is required, visitors cannot change the server-side API key, and IMPLICANT_API_KEY must be set in the environment. Anyone who can reach the address can then drive the demo — never expose a private instance this way.

License

Apache-2.0.

Metadata

Release files for implicant 0.7.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for implicant 0.7.3
File Size Uploaded Provenance
implicant-0.7.3.tar.gz 10.0 MB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for implicant 0.7.3
File Interpreter ABI Platform
implicant-0.7.3-py3-none-any.whl Python 3 none any Details

Total release size: 20.0 MB

Release files / implicant-0.7.3.tar.gz

Download URL implicant-0.7.3.tar.gz
Size 10.0 MB
Tags Source
SHA-256 checksum
How to use checksums
24c42f24611686ed92a350a9dce80c936225e9dd0226207ab2e6f8e285b1b6e4
BLAKE2b-256 checksum
How to use checksums
36195d2409f18636d021efcb563ea98290ed2d0a160139aaf4c47e9a5696e7f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

Release files / implicant-0.7.3-py3-none-any.whl

Download URL implicant-0.7.3-py3-none-any.whl
Size 10.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
9d75c5337d5beacb49e8ac4b910f886aecce60a98ee825e84bbd5efe1dab1b97
BLAKE2b-256 checksum
How to use checksums
b364f4f20be8debf24cf4828e31185e60b5b1f896565629a8312934743a5e7b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

Security for implicant 0.7.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for implicant-0.7.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page