DEV Community

Štefan Bohumel
Štefan Bohumel

Posted on

Building Aegis Protocol: A Zero-Knowledge Web3 Security Enclave, Tax-Loss Harvester & Shamir 2-of-2 Vault Across 15 Chains

Self-custody in Web3 comes with three persistent engineering and operational problems that cost investors and treasuries billions of dollars every year:

  1. Trapped Capital Losses & Dust Fragmentation: Across 15+ EVM chains and Solana, wallets accumulate rugged tokens, abandoned airdrops, and uncollected dust. Because holders never formally dispose of dead tokens on-chain, they miss out on legitimate capital loss deductions (IRS Form 8949 / EU MiCA tax reporting).
  2. Silent Unlimited Approval Risks (2^256 - 1): Legacy ERC-20 approve() calls leave wallets permanently exposed to compromised routers, unverified proxy contracts, and wallet drainers.
  3. The $100B+ Self-Custody Inheritance Gap: When crypto holders pass away or lose access, their assets are permanently locked—yet existing inheritance platforms require trusting a third-party server or custodian with seed phrases.

To solve all three without introducing a single point of failure, I built Aegis Protocol — a 100% client-side, zero-knowledge Web3 security and treasury enclave supporting 15 networks (14 EVM chains + Solana).


Architecture Overview: Zero Backend, Zero Custodial Risk

Aegis Protocol is architected as a pure browser-based enclave. No private keys, seed phrases, or wallet telemetry ever leave the client. All cryptography runs natively inside the browser's window.crypto.subtle (WebCrypto API) and isolated memory arrays.

1. DustSweeper & Cryptographic Tax-Loss Harvester

The scanner queries token balances across Ethereum, Base, Arbitrum, Optimism, Polygon, Solana, Avalanche, BNB Chain, zkSync Era, Linea, Scroll, Blast, Sonic, Mantle, and Berachain.

  • Dust Consolidation: Aggregates sub-threshold micro-balances into native gas tokens (ETH / SOL / native L1/L2 gas).
  • On-Chain Tax-Loss Realization: Disposes of dead or rugged tokens via verifiable burn/disposition transactions to crystallize capital losses before the tax year closes.
  • Compliance Exports: Automatically generates accountant-ready IRS Form 8949 & EU MiCA CSV ledgers (hardened against CSV formula injection) alongside a printable SHA-256 Tax-Loss Certificate containing an immutable hash of the transaction batch.

2. Approval Sentinel (Live Bytecode & Proxy Threat Scanner)

Most revocation dashboards only check an address against a static blocklist. Aegis Protocol performs live on-chain bytecode inspection directly via JSON-RPC:

  • Executes eth_getCode and eth_call against active token spenders.
  • Flags unlimited allowances (2^256 - 1), unverified contract bytecode, and mutable EIP-1967 proxy spenders that could be upgraded maliciously after approval.
  • Calculates a real-time Wallet Security Score (0–100) and constructs zero-allowance revocation calldata (approve(spender, 0)) directly in the client.

3. InheritSafe: Zero-Knowledge Dead Man's Switch (AES-256-GCM + GF(256) Shamir 2-of-2)

Instead of storing recovery phrases on a server, InheritSafe combines authenticated encryption with finite-field secret sharing:

  1. Key Derivation & Encryption: The recovery payload is encrypted locally using PBKDF2-HMAC-SHA256 (100,000 iterations) and AES-256-GCM with a random 96-bit IV and 128-bit salt.
  2. Galois Field GF(256) Polynomial Split: The cryptographic key material is split across the irreducible polynomial x^8 + x^4 + x^3 + x + 1 (0x11b) into two independent mathematical shares:
    • Share A (Owner / Cold Backup Key)
    • Share B (Beneficiary / Legal Executor Key)
  3. Information-Theoretic Security: Neither share reveals a single byte of the secret on its own. Reconstruction (gfAdd / gfMul / gfInv Lagrange interpolation in GF(256)) occurs strictly offline in the browser when both shares are combined after the inactivity heartbeat expires.

Rapid Prototyping & Deployment with Bolt.new

I built, iterated, and shipped Aegis Protocol for the Bolt Builders Week competition. Having an integrated AI-native full-stack environment in the browser made it possible to wire up 15-chain RPC adapters, custom SVG 3D isometric telemetry, WebCrypto GF(256) arithmetic, and strict on-chain payment verification (eth_getTransactionByHash recipient & wei validation) in record time.

If you want to build and ship full-stack Web3 or AI apps directly in your browser (and get extra free tokens when signing up), you can try Bolt here via my referral link:


Try the Live Enclave (No Wallet Connection Required)

You can test all three engines immediately using the built-in Interactive Judge Demo Mode—it pre-populates simulated multi-chain dust, high-risk proxy approvals, and a live GF(256) Shamir 2-of-2 vault so you can inspect the full workflow without connecting a live wallet:

Feedback from fellow Web3 builders, security auditors, and cryptography enthusiasts is welcome in the comments!

Top comments (0)