This project is built on the Midnight Network.
MidnightShield serves as a next-generation privacy-preserving liquidity vault, leveraging the advanced private state mechanics of the Midnight Network. By utilizing zero-knowledge proofs, MidnightShield allows institutional liquidity providers and retail users to pool assets transparently—proving the vault's solvency and total value locked (TVL) publicly—while completely obfuscating individual deposit amounts, user identities, and withdrawal triggers. This approach delivers the strict compliance and liquidity assurances required by global financial networks without compromising on the fundamental right to transactional privacy.
To satisfy strict code quality and security evaluation criteria, MidnightShield strictly bifurcates its state transitions:
total_liquidity: A publicly verifiable accumulator that proves the vault's exact solvency without leaking who owns what.- Data Disclosure Minimization: Utilizing the
disclose()mechanism, only the exactamountandpublic_recipientare revealed during withdrawal execution, allowing the underlying L1/L2 networks to process token transfers securely.
commitmentsMap: Deposits map user identities to a secure cryptographic hash. The underlying balances and metadata are never posted to the mempool.nullifiersSet: Withdrawals are validated off-chain using a privatesecret_witness. A unique nullifier is computed and registered on-chain to prevent replay attacks and double-spending.- Front-running Protection: Because the private witness is executed inside a local ZK circuit rather than on a public RPC node, bad actors cannot intercept, replicate, or front-run user withdrawals.
Ensure your local development environment meets the strict prerequisites before evaluating the project.
- Node.js: v22.0.0 or higher
- Docker: For running the isolated Midnight proof server and sandbox
Clone the repository and install the strict Node dependencies:
# Clone the repository
git clone <repository-url>
cd midnight-shield
# Install Node dependencies
npm installWe use a clean, isolated Docker configuration to ensure consistent zero-knowledge proof generation:
docker-compose up -dThis will spin up the midnight-proof-server (Port 6300) and the midnight-sandbox (Ports 9944, 9933).
Compile the vault.compact smart contract to generate the highly secure TypeScript bindings into the managed/ directory. Note: The managed/ directory is strictly tracked to allow the technical committee to verify circuit integrity.
npx @midnight-ntwrk/compactc compile contracts/vault.compact --target typescript --out-dir managed/Validate the state transitions and zero-knowledge bounds (spam prevention, replay attacks, insolvency protection):
npm run testCreate a .env file containing your DEPLOYER_SEED_PHRASE, then execute the professional deployment script:
npx ts-node scripts/deploy.tsTo fulfill the submission requirements, the following proofs of successful compilation and deployment are provided:

