PrivaC is a bare-metal, ultra-fast C reverse proxy designed for privacy-preserving, zero-knowledge LLM workflows. It intercepts inbound prompts, strips sensitive PII and raw figures into type-preserving surrogates and symbolic algebraic variables (VAR_1, VAR_2), and compiles mathematical expressions returned by remote LLMs (<<calc: ... >>) locally using an embedded micro-math VM (tinyexpr) over streaming Server-Sent Events (SSE) with sub-millisecond latency.
| Capability | Standard Gateway / Python Proxy | PrivaC (Bare-Metal C) |
|---|---|---|
| End-to-End Latency | +150 ms to +400 ms | < 1.0 µs (Bare-metal C11) |
| Agent / JSON Schema Safe | ❌ Fails on typed integer fields | ✅ Yes (Type-preserving surrogates) |
| Math Accuracy | ❌ LLM hallucinates calculations | ✅ 100% Deterministic (Local C math VM) |
| Numeric Privacy | ❌ Sends clear numbers to LLM | ✅ Zero-Knowledge (Symbolic derivation) |
| Memory Footprint | ~200–500 MB (Python/Node runtime) | < 15 MB static binary |
| Harness Compatibility | ✅ Drop-in (OpenAI base_url) |
[Agent / SDK] ───> [PrivaC Proxy: Schema & Masking] ──(Blind Prompt)──> [Remote LLM Cloud]
│ │
(Local Vault) │ (Formula AST)
[mlock + Arena] │
│ ▼
[Agent / SDK] <─── [PrivaC Proxy: TinyExpr Math + SSE Stream FSM] <─────────────┘
-
Schema-Aware Type-Preserving Masking: Replaces names, emails, and entities with
Entity_A,Entity_B, while converting monetary and numerical figures into symbolic variables (VAR_1,VAR_2). -
Blind Symbolic Prompt Injection: Injects system-level directives forcing the remote LLM to reason abstractly and emit formula ASTs:
[Original]: "Alice made $1,250,000 in revenue with $820,000 in costs. Net profit after 22% tax?" [Masked]: "Entity_A has Revenue = VAR_1 and Costs = VAR_2. Derive profit with Tax = VAR_3. Return <<calc: expression>>." -
Remote LLM Logic Compilation: The model generates:
<<calc: (VAR_1 - VAR_2) * (1 - VAR_3)>> - Streaming SSE Delimiter FSM: Buffers split tokens across arbitrary chunk boundaries without breaking SSE framing or delaying Time-To-First-Token (TTFT).
-
Embedded Micro-Math VM: Evaluates the formula locally in
$< 2\ \mu\text{s}$ using real session vault values, formatting$335,400.00before forwarding the unmasked stream to the client.
Measured on Apple Silicon / Modern Linux x86_64:
==================================================================
PRIVAC: BLIND C PROXY & SYMBOLIC ENGINE - BENCHMARK SUITE
==================================================================
[1] Micro-Math VM Performance:
Total Iterations: 100,000
Average Latency: 0.777 µs / evaluation
Throughput: 1,287,365.79 ops / second
[2] JSON Masking & Prompt Extraction Performance:
Total Iterations: 20,000
Average Latency: 0.900 µs / request
Throughput: 1,111,419.84 reqs / second
==================================================================
SUMMARY: Total proxy overhead is < 0.002 ms (< 2 microseconds)
==================================================================
- Page-Locked Vaults (
mlock): Guarantees sensitive session keys and cleartext values reside strictly in RAM and are never swapped to unencrypted disk swap space. - Defensive Zeroization (
privac_secure_zero): Wipes memory regions immediately upon session termination to prevent compiler dead-store optimization. - Region-Based Arena Allocation: Zero runtime
malloc/freecalls during request handling, preventing heap fragmentation and memory leaks. - Strict Sanitizer Verification: Fully verified under
-fsanitize=address,undefinedwith 0 leaks and 0 warnings.
- C11 compliant compiler (
clangorgcc) make
# Compile standard release binary
make
# Run all unit and integration tests
make test
# Run with AddressSanitizer and UndefinedBehaviorSanitizer
make sanitize
# Run latency and throughput benchmarks
make bench# Run in standalone mock mode (offline demo with zero API keys required)
./bin/privac --port 8080 --mock
# Run as upstream forwarder to a local Ollama or vLLM instance
./bin/privac --port 8080 --upstream 127.0.0.1:11434
# Run with verbose token and masking logs
./bin/privac --port 8080 --mock -vcurl -N -X POST http://127.0.0.1:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-H "x-session-id: sess_1001" \
-d '{
"model": "gpt-4",
"messages": [
{
"role": "user",
"content": "Alice made $1,250,000 in revenue with $820,000 in expenses. What is her net profit after a 22% tax?"
}
],
"stream": true
}'from openai import OpenAI
# Point client to local PrivaC Proxy
client = OpenAI(
base_url="http://127.0.0.1:8080/v1",
api_key="none"
)
response = client.chat.completions.create(
model="gpt-4",
messages=[
{"role": "user", "content": "Alice made $1,250,000 in revenue with $820,000 in expenses. What is her net profit after a 22% tax?"}
],
stream=True,
extra_headers={"x-session-id": "user_session_42"}
)
for chunk in response:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
print()privacy_c/
├── include/
│ ├── arena.h # Fixed-block / region bump memory allocator
│ ├── vault.h # Page-locked session state & bidirectional map
│ ├── symbolic_vm.h # TinyExpr compilation, evaluation, and formatting
│ ├── mask_engine.h # SIMD PII regex + type-preserving surrogacy
│ ├── stream_fsm.h # Chunk-split delimiter FSM with fallback flush
│ ├── sse_parser.h # Zero-copy SSE framing and delta re-assembler
│ └── server.h # Non-blocking HTTP reverse proxy & mock engine
├── src/
│ ├── main.c # CLI entrypoint (--port, --upstream, --mock)
│ ├── arena.c
│ ├── vault.c
│ ├── symbolic_vm.c
│ ├── mask_engine.c
│ ├── stream_fsm.c
│ ├── sse_parser.c
│ └── server.c
├── deps/
│ ├── yyjson/ # Embedded SIMD JSON parser (yyjson.h, yyjson.c)
│ └── tinyexpr/ # Embedded Micro-Math VM (tinyexpr.h, tinyexpr.c)
├── tests/
│ ├── test_arena.c # Arena bump allocator & bounds tests
│ ├── test_vault.c # Session mappings, zeroization, and LRU eviction
│ ├── test_mask.c # PII/number extraction and prompt rewriting
│ ├── test_math_vm.c # Symbolic math evaluation and currency formatting
│ ├── test_stream_fsm.c# Split-token SSE streaming tests across chunk boundaries
│ ├── test_e2e_mock.c # End-to-end proxy integration test
│ └── benchmark.c # Microsecond latency benchmark suite
├── .github/workflows/
│ └── ci.yml # Automated CI for Linux & macOS (Clang + GCC)
├── Makefile
├── .gitignore
└── README.md
MIT License.