Depth-tracked regulatory audit primitives for future FHE-CKKS execution.
Project description
regaudit-fhe
Encrypted regulatory audit primitives for AI systems.
A small Python library of six audit operations that can be evaluated on encrypted inputs under fully-homomorphic encryption (CKKS, multiplicative depth six) without bootstrapping. Designed so a regulated AI vendor can run mandatory audits — fairness, drift, calibration, provenance, disagreement, survival concordance — without ever exposing raw labels, predictions, protected attributes, or training data.
Maintained by VaultBytes Innovations Ltd. Licensed under AGPL-3.0-or-later — see LICENSE.
What it is for
┌──────────────┐ encrypted inputs ┌────────────────┐
│ Regulated │ ──────────────────────────► │ regaudit-fhe │
│ AI vendor │ (labels, preds, PHI, │ d=6 CKKS audit │
│ (the client) │ protected attrs) │ primitives │
└──────────────┘ └──────┬─────────┘
▲ │
│ │ encrypted
│ sealed envelope │ aggregate
│ (JSON + receipt) │ scalars only
│ ▼
│ ┌────────────────┐
└───────────────────────────────────► │ Regulator / │
│ external │
decrypt + verify receipt │ auditor │
└────────────────┘
Two audiences are served by the same surface area:
| Audience | Role | What they run |
|---|---|---|
| Client | Audited entity (vendor / operator). | audit_* primitives, regaudit-fhe audit .... |
| Regulator | External or in-house auditor. | verify_receipt(...), regaudit-fhe verify .... |
A run produces an audit envelope (JSON) with a SHA-256 receipt. The client archives it, ships it to the regulator, or both. The regulator recomputes the receipt to detect tampering between issuance and review.
The six primitives
| Module | API | Depth | Use case (technical evidence supporting…) |
|---|---|---|---|
egf_imss |
audit_fairness |
4 | NYC LL144, EU AI Act §10/§15, Colorado AI Act, CFPB workflows. |
etk_fpa_hbc |
audit_provenance |
3 | EU AI Act §10, 21 CFR Part 11, GDPR §22, HIPAA workflows. |
esc_cia |
audit_concordance |
4 | FDA SaMD oncology PCCP, EU AI Act §15, EMA workflows. |
ecp_qssp |
audit_calibration |
3 | FDA SaMD UQ, EU AI Act §15, ISO/IEC 23053, UNECE WP.29 workflows. |
ew1_cdsf |
audit_drift |
3 | EU AI Act §15, FDA SaMD PCCP, Basel III workflows. |
ecmd_jps |
audit_disagreement |
5 | OCC SR 11-7, EU AI Act §15, FDA SaMD PCCP workflows. |
Compliance scope and disclaimer.
regaudit-fheproduces technical evidence — encrypted scalars, signed envelopes, parameter-set hashes, depth-budget attestations — that may support compliance workflows in the jurisdictions above. It does not constitute legal compliance, conformity assessment, regulatory acceptance, or a recognised audit. Read COMPLIANCE.md for the binding scope statement and the "what-it-does-NOT-prove" mapping per regulation.
Each primitive's depth budget — the number of multiplicative levels it consumes inside the d=6 CKKS circuit — is shown above. All six fit comfortably under six, leaving headroom for downstream commit-and-verify chaining.
Depth budget visualisation (each ▮ = 1 level)
primitive 0 1 2 3 4 5 6
─────────────────────────────────────
audit_calibration ▮ ▮ ▮ . . . . 3 of 6
audit_provenance ▮ ▮ ▮ . . . . 3 of 6
audit_drift ▮ ▮ ▮ . . . . 3 of 6
audit_fairness ▮ ▮ ▮ ▮ . . . 4 of 6
audit_concordance ▮ ▮ ▮ ▮ . . . 4 of 6
audit_disagreement ▮ ▮ ▮ ▮ ▮ . . 5 of 6
Each primitive's full specification, including its algorithm, depth
breakdown, and security analysis, is in
docs/specs/.
Install
pip install regaudit-fhe
The plaintext model that runs the depth-budgeted slot-vector circuits
(used for testing, oracles, and CI) requires only numpy>=1.26. The
encrypted execution path lives behind the optional [fhe] extra:
pip install regaudit-fhe[fhe] # adds OpenFHE
Quick start
import numpy as np
import regaudit_fhe as rf
y_true = np.array([1, 0, 1, 1, 0, 1, 0, 0], dtype=float)
y_pred = np.array([1, 0, 1, 0, 0, 1, 1, 0], dtype=float)
group_a = np.array([1, 1, 1, 1, 0, 0, 0, 0], dtype=float)
group_b = 1.0 - group_a
report = rf.audit_fairness(y_true, y_pred, group_a, group_b, threshold=0.1)
print(report.demographic_parity_diff, report.threshold_breached)
envelope = rf.envelope("fairness", report)
print(envelope.to_json()) # ship this to the regulator
assert rf.verify_receipt(envelope) is True # regulator-side check
The HTTP server is NOT a privacy boundary by itself. The default execution path is plaintext; the server runs in-process. Encrypted execution requires the
[fhe]extra AND key custody held off-host. Read docs/DEPLOYMENT.md and docs/THREAT_MODEL.md before exposing publicly. Without the closed-source companion product, the server cannot mint regulator-trusted envelopes.
Same flow, command line
echo '{"y_true":[1,0,1,1],"y_pred":[1,0,0,0],"group_a":[1,1,0,0],"group_b":[0,0,1,1]}' \
> input.json
regaudit-fhe audit fairness -i input.json -o envelope.json
regaudit-fhe verify -i envelope.json
regaudit-fhe audit <primitive> --schema prints the JSON shape that
each primitive expects.
Audit envelope
Every audit_* call can be wrapped into a regulator-facing JSON
envelope by regaudit_fhe.envelope(...):
{
"schema": "regaudit-fhe.report.v1",
"primitive": "fairness",
"regulations": ["NYC_LL144", "EU_AI_ACT_ART10",
"EU_AI_ACT_ART15", "COLORADO_AI_ACT",
"CFPB_ALG_DISCRIM"],
"result": {
"demographic_parity_diff": 0.083,
"equal_opportunity_diff": 0.041,
"predictive_parity_diff": 0.022,
"threshold_breached": false
},
"depth_budget": {"declared": 6, "consumed": 4},
"issued_at": "2026-04-26T20:30:11.482910+00:00",
"receipt": {
"sha256": "9f3c…b4a7",
"version": "0.0.1"
}
}
schema and regulations give a regulator the exact citation they
need. receipt.sha256 is computed over the canonical JSON of every
other field; verify_receipt(env) returns False if anything changed.
Examples
The examples/ folder ships four end-to-end flows:
| File | Flow |
|---|---|
01_client_local_audit.py |
Internal audit on synthetic data; archive JSON locally. |
02_client_to_regulator.py |
Build a regulator submission bundle. |
03_regulator_verify.py |
Verify every envelope inside a submission bundle. |
04_cli_roundtrip.sh |
Pure CLI: input → audit → verify, no Python knowledge required. |
Run any of them after pip install -e .[dev].
Layout
src/regaudit_fhe/ depth-tracked plaintext model + 6 primitives + reports + CLI
docs/specs/ per-primitive technical specifications
docs/THREAT_MODEL.md roles, key custody, public surface per primitive
schemas/ JSON Schemas (Draft 2020-12) for every input, output, and the envelope
tests/ pytest unit, integration, edge-case, property-based, schema, security tests
examples/ client + regulator end-to-end flows
benchmarks/ d=6 CKKS wall-clock + memory benchmarks
JSON schemas
Every primitive input, primitive output, and the audit envelope itself
ships with a Draft-2020-12 JSON Schema under schemas/.
Auditors and integrators can pin specific schema versions and reject
payloads that do not conform.
regaudit-fhe schema --list
regaudit-fhe schema fairness.input
regaudit-fhe schema envelope
The CLI and HTTP server validate every request body against the matching schema before invoking the audit primitive; failures return HTTP 422 / CLI exit-code 2 with a structured pointer to the offending field. Programmatic access:
import regaudit_fhe as rf
rf.list_schemas() # all 13 names
rf.load_schema("fairness.input") # raw schema dict
rf.validate_input("fairness", payload) # raises rf.SchemaError on bad input
rf.validate_envelope(env_dict) # check a regulator-side envelope
Real CKKS benchmarks
The [fhe] extra ships a real TenSEAL CKKS backend; its measurements
are reproduced from benchmarks/results/SUMMARY.md (machine-readable
JSON in benchmarks/results/bench_fhe_<N>.json).
| Primitive | N | Slots | Depth obs/decl | Rotations | ct×ct | ct×pt | Runtime | RAM | Max abs err | Threshold flip |
|---|---|---|---|---|---|---|---|---|---|---|
| fairness | 2^14 | 8 192 | 1/4 | 108 | 0 | 18 | 0.28 s | 878 MB | 4.8 × 10⁻⁷ | 0.00% |
| provenance | 2^14 | 8 192 | 1/3 | 288 | 0 | 48 | 0.71 s | 885 MB | 7.9 × 10⁻⁶ | 0.00% |
| concordance | 2^14 | 8 192 | 4/4 | 0 | 0 | 0 | 0.00 s | 887 MB | 0 | 0.00% |
| calibration | 2^14 | 8 192 | 0/3 | 0 | 0 | 0 | 0.01 s | 890 MB | 0 | 0.00% |
| drift | 2^14 | 8 192 | 2/2 | 36 | 3 | 6 | 0.18 s | 968 MB | 2.3 × 10⁻⁶ | 0.00% |
| disagreement | 2^14 | 8 192 | 3/5 | 0 | 36 | 0 | 0.16 s | 977 MB | 1.1 × 10⁻⁸ | 0.00% |
| fairness | 2^15 | 16 384 | 1/4 | 108 | 0 | 18 | 0.58 s | 2.7 GB | 7.2 × 10⁻⁷ | 0.00% |
| provenance | 2^15 | 16 384 | 1/3 | 288 | 0 | 48 | 1.52 s | 2.7 GB | 1.9 × 10⁻⁵ | 0.00% |
| drift | 2^15 | 16 384 | 2/2 | 36 | 3 | 6 | 0.39 s | 2.8 GB | 1.1 × 10⁻⁵ | 0.00% |
| disagreement | 2^15 | 16 384 | 3/5 | 0 | 36 | 0 | 0.35 s | 2.7 GB | 1.4 × 10⁻⁸ | 0.00% |
Run yourself:
pip install regaudit-fhe[fhe]
python benchmarks/bench_fhe.py --rings 14 15 --reps 3
Add --rings 16 for N = 2^16 (slower; uses several GB of RAM).
The "Threshold flip" column is the rate at which CKKS noise causes the encrypted circuit to disagree with the plaintext circuit on a boolean breach decision over 10–20 trials with inputs sampled near the breach boundary. Zero flips across both rings means CKKS noise does not change a regulatory threshold decision at the audit precision targets.
Maturity and status
Description today: Depth-tracked regulatory audit primitives for future FHE-CKKS execution. Description after the OpenFHE backend lands: FHE-CKKS regulatory audit primitives for privacy-preserving AI system audits.
regaudit-fhe v0.0.1 ships:
- the plaintext SlotVec model with strict depth-budget enforcement,
- a TenSEAL CKKS backend that mirrors the SlotVec algebra and passes end-to-end ciphertext / plaintext equivalence tests,
- the Ed25519-signed audit envelope with canonical-JSON rules, parameter-set hashing, and input commitments,
- JSON Schemas for every input, output, and the envelope itself,
- the hardened HTTP audit server with bearer-token auth, scopes, body- size limit, rate limiting, structured logs, and CORS controls,
- supply-chain controls: Trusted-Publisher PyPI release, Sigstore
attestation, CycloneDX SBOM,
pip-audit, weekly Dependabot.
The OpenFHE production backend at N = 2^15, calibrated polynomial
packs per vertical, KMS-backed signing key chains, and regulator-
portal connectors live in the closed-source companion product. Contact
b@vaultbytes.com for commercial licensing.
Contributions are not accepted — see CONTRIBUTING.md.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file regaudit_fhe-0.0.2.tar.gz.
File metadata
- Download URL: regaudit_fhe-0.0.2.tar.gz
- Upload date:
- Size: 101.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d485b0d4f2ae75c9aad51109802ba08d70de38ff8bb5f4892b7d9ac646ffba2f
|
|
| MD5 |
00f644dbd13f107b5b7fb51f0bbf70f1
|
|
| BLAKE2b-256 |
5252ce6a49c55a7517ee8d6d572003e217afea5ca87a31185008d9a587ca89f2
|
Provenance
The following attestation bundles were made for regaudit_fhe-0.0.2.tar.gz:
Publisher:
publish.yml on BAder82t/regaudit-fhe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
regaudit_fhe-0.0.2.tar.gz -
Subject digest:
d485b0d4f2ae75c9aad51109802ba08d70de38ff8bb5f4892b7d9ac646ffba2f - Sigstore transparency entry: 1391827250
- Sigstore integration time:
-
Permalink:
BAder82t/regaudit-fhe@0ea4fb135b7faf7a0a6d1045d05ec4e6f8efe09a -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/BAder82t
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0ea4fb135b7faf7a0a6d1045d05ec4e6f8efe09a -
Trigger Event:
push
-
Statement type:
File details
Details for the file regaudit_fhe-0.0.2-py3-none-any.whl.
File metadata
- Download URL: regaudit_fhe-0.0.2-py3-none-any.whl
- Upload date:
- Size: 62.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f8b455e1028b6bbaf58a35dbdd45d6e027fbda29481018fe60b2c7e2e785da8
|
|
| MD5 |
5b4200a3ba475d7804ff5b3a70164907
|
|
| BLAKE2b-256 |
a6f05e17a7061775363ec31300128ce0344566e1518c02190fefbaebf2c6190c
|
Provenance
The following attestation bundles were made for regaudit_fhe-0.0.2-py3-none-any.whl:
Publisher:
publish.yml on BAder82t/regaudit-fhe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
regaudit_fhe-0.0.2-py3-none-any.whl -
Subject digest:
1f8b455e1028b6bbaf58a35dbdd45d6e027fbda29481018fe60b2c7e2e785da8 - Sigstore transparency entry: 1391827262
- Sigstore integration time:
-
Permalink:
BAder82t/regaudit-fhe@0ea4fb135b7faf7a0a6d1045d05ec4e6f8efe09a -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/BAder82t
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0ea4fb135b7faf7a0a6d1045d05ec4e6f8efe09a -
Trigger Event:
push
-
Statement type: