Inspiration
Modern AI Agents powered by hosted LLM APIs (such as Google Gemini, OpenAI, and AWS Bedrock) are increasingly used for autonomous DevSecOps, database debugging, and financial analytics. However, passing raw prompts containing production API keys, database credentials, and confidential numbers directly to third-party inference servers creates severe vulnerability windows—exposing master keys to server logs, data retention leaks, and RAM memory-dump side-channel attacks.
We built ZeroVault AI to solve this real-world security bottleneck: allowing an AI agent to reason, generate audit scripts, and compute financial totals without ever observing the underlying master keys or plaintext numbers ($0\%$ exposure).
What it does
ZeroVault AI is a Cryptographic Blind-Proxy & Secret-Sharded AI Execution Pipeline featuring both a Cyber-Security Dashboard and a retro Terminal User Interface (TUI) mode:
- Local Entropic Interception & Secret Sharding: Before any prompt leaves
localhost, high-entropy credentials (such as Stripe keys and PostgreSQL URLs) are intercepted and split into $n=5$ cryptographic shards ($k=3$ threshold) over a prime Galois Field, replacing them with opaque blind tokens (<<ZV_SHARD_TOKEN_0x01>>). - Host API Wiretap Proof: Demonstrates in real time that the hosted Google Gemini API (
gemini-3.5-flash-lite) receives only blinded tokens and encrypted ciphertexts—never the raw secrets. - Ephemeral Vandermonde Reconstruction & Side-Channel Mitigation: When the LLM returns its execution plan, the local enclave reconstructs the secret in RAM for microseconds using Gaussian elimination over a Vandermonde matrix and immediately overwrites the memory buffers with zeros (
memset(0)). - Homomorphic Blind Financial Math: Sensitive numerical values (e.g.,
[HOMO:45000]and[HOMO:82500]) are encrypted using the Paillier cryptosystem so the pipeline computes their sum directly on ciphertexts without decrypting them.
Mathematical Architecture & Cryptographic Proofs
1. Shamir's Secret Sharing over Finite Field \(\mathbb{GF}(p)\) (Number Theory)
Each intercepted secret is partitioned into 48-bit integers \(S \in \mathbb{GF}(p)\), where \(p\) is the 61-bit Mersenne Prime: $$p = 2^{61} - 1 = 2305843009213693951$$
To eliminate single-point memory compromise, we construct a random polynomial of degree \(k-1\) over \(\mathbb{GF}(p)\) with constant term \(a_0 = S\):
$$f(x) = \left( S + \sum_{j=1}^{k-1} a_j x^j \right) \pmod p$$
where \(a_1, \dots, a_{k-1} \in \mathbb{GF}(p)\) are cryptographically random coefficients generated via crypto.getRandomValues. Evaluating \(f(x)\) at \(n=5\) distinct points \(x_i \in {1, 2, 3, 4, 5}\) yields \(n=5\) shards \({(x_i, y_i)}_{i=1}^n\). Any subset of fewer than \(k=3\) shards reveals 0 bits of information about \(S\).
2. Linear Algebra Reconstruction via Vandermonde Matrix Inversion
Given any \(k=3\) distinct shards \((x_1, y_1), (x_2, y_2), (x_3, y_3)\), recovering \(S = a_0\) is formulated as solving the linear system \(\mathbf{V}\mathbf{a} \equiv \mathbf{y} \pmod p\), where \(\mathbf{V}\) is the \(k \times k\) Vandermonde Matrix:
$$\begin{bmatrix} 1 & x_1 & x_1^2 \ 1 & x_2 & x_2^2 \ 1 & x_3 & x_3^2 \end{bmatrix} \begin{bmatrix} a_0 \ a_1 \ a_2 \end{bmatrix} \equiv \begin{bmatrix} y_1 \ y_2 \ y_3 \end{bmatrix} \pmod p$$
Because the determinant of the Vandermonde matrix over \(\mathbb{GF}(p)\) is: $$\det(\mathbf{V}) \equiv \prod_{1 \le i < j \le k} (x_j - x_i) \not\equiv 0 \pmod p$$ for distinct \(x_i\), \(\mathbf{V}\) is strictly invertible. Our engine performs row-reduced Gaussian elimination in \(\mathbb{GF}(p)\), computing modular multiplicative inverses \(z^{-1} \pmod p\) via the Extended Euclidean Algorithm: $$z \cdot z^{-1} \equiv 1 \pmod p$$
3. Additive Homomorphic Encryption (Paillier Cryptosystem)
For numerical secrets, we implement Paillier Additive Homomorphic Encryption over \(\mathbb{Z}_{n^2}^*\) where \(n = p \cdot q\) and generator \(g = n + 1\): $$E(m, r) = g^m \cdot r^n \pmod{n^2} = (1 + m \cdot n) \cdot r^n \pmod{n^2}$$
The AI pipeline multiplies two ciphertexts homomorphically without decrypting either operand: $$E(m_1, r_1) \cdot E(m_2, r_2) \pmod{n^2} \equiv \big(1 + (m_1 + m_2)n\big)(r_1 r_2)^n \pmod{n^2} = E(m_1 + m_2)$$
How we built it
- Zero-Dependency Cryptographic Engine (
cryptoEngine.ts): Built from scratch in TypeScript using native arbitrary-precisionBigIntarithmetic to prevent floating-point rounding vulnerabilities in modular field operations. - Hosted LLM Pipeline Integration: Integrated the Google Gemini REST API (
gemini-3.5-flash-lite) with automatic model fallback and strict system-level blind-token guardrails. - Dual-Mode Interface (
App.tsx): Engineered a three-column real-time Wiretap & Enclave dashboard in React and Tailwind CSS with an instant toggle for a retro Terminal User Interface (TUI) mode.
Challenges we ran into
- Precision Overflow in Modular Arithmetic: Standard 64-bit JavaScript numbers lose precision above \(2^{53}-1\). We solved this by implementing 6-byte chunk packing over the 61-bit Mersenne Prime \(2^{61}-1\) using
BigInt, ensuring exact modular inverses and zero overflow during Vandermonde Gaussian elimination. - Minimizing RAM Exposure Window: Keeping reconstructed secrets in memory creates side-channel risks. We structured our matrix solver to extract \(a_0\), inject the credential, and explicitly overwrite every matrix cell and chunk array with
BigInt(0)within microseconds.
Accomplishments that we're proud of
- Implementing pure Number Theory (\(\mathbb{GF}(2^{61}-1)\) Shamir's Secret Sharing & Paillier FHE) and Linear Algebra (Vandermonde Gaussian Elimination) from scratch without external crypto libraries.
- Proving live end-to-end 0% Master Key Exposure against a hosted Gemini LLM API while successfully executing DevSecOps commands and homomorphic financial aggregations.
What's next for ZeroVault AI
- Porting the core
cryptoEnginemodule into WebAssembly (WASM) via Rust for hardware-level constant-time execution. - Adding threshold multi-party approval workflows where human security officers hold individual Shamir shards on mobile hardware keys.
Built With
- cryptography
- gemini-api
- homomorphic-encryption
- linear-algebra
- number-theory
- react
- shamirs-secret-sharing
- tailwindcss
- typescript