feat(examples): confidential dark-pool batch-auction example#421
Open
clawdbot-glitch003 wants to merge 1 commit into
Open
feat(examples): confidential dark-pool batch-auction example#421clawdbot-glitch003 wants to merge 1 commit into
clawdbot-glitch003 wants to merge 1 commit into
Conversation
A sealed-bid batch auction: orders are submitted encrypted, stored as ciphertext in Postgres (Neon, queried over HTTP from the action), matched blind inside the TEE at a single uniform clearing price, and settled on-chain. The first example to use Lit encryption + confidential state, not just compute + signing. - contracts: DarkPoolSettlement (escrow, signed-fill settlement, per-epoch replay guard, conservation invariant, cross-pool/chain digest binding) + TestToken. 6 hardhat tests. - actions: encryptOrder (decrypt DB url, seal order, insert ciphertext) and matchEpoch (decrypt the batch in-enclave, uniform-price auction with conservation-safe rationing, sign the fills). 6 auction unit tests. - scripts: setup / submitOrder / runEpoch over the Chipotle REST API; the DB connection string is itself encrypted to the vault PKP. Validated live end-to-end (Lit API + Neon + Base Sepolia): epoch settled at the uniform clearing price, internal balances moved correctly, and the DB holds only ciphertext (no plaintext order fields). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A new flagship example:
examples/dark-pool/— a confidential exchange where orders are submitted encrypted, matched blind inside the TEE at a single uniform clearing price, and settled on-chain. Order side/price/quantity never exist in plaintext anywhere outside the enclave, including in the database that stores them.This is the first example to use Lit's encryption primitive and to hold confidential state — the existing four are all compute + signing. It wires together encrypt + confidential-compute + sign in one flow.
Honest trust framing
Not "more private than an MPC dark pool" — a different trade: hardware privacy (the TEE sees the book but doesn't leak it) for radically less complexity, async batching, and confidential state on a hobby-tier Postgres. Pre-trade privacy (no front-running of resting orders); post-trade fills are public on-chain, like real dark pools. This is stated plainly in the README.
Design
fetch). The DB connection string is itself encrypted to the vault PKP and decrypted only inside the enclave.DarkPoolSettlementpins the matchEpoch action's CID-derived address asmatcher; edit the action by a byte and the contract stops trusting it.Contents
contracts/DarkPoolSettlement.sol+TestToken.sol— escrow, signed-fill settlement, per-epoch replay guard, conservation invariant, cross-pool/chain digest bindingaction/encryptOrder.js,action/matchEpoch.js— seal+store; decrypt-batch + uniform-price auction (conservation-safe rationing) + signscripts/setup.js,submitOrder.js,runEpoch.js,deploy.js,lit.jsREADME.md,schema.sql, and anexamples/README.mdrowTests & live validation
npx hardhat test→ 12 passing (6 contract: happy path, wrong-signer, replay, under-collateralised, conservation, cross-pool replay; 6 auction: cross, rounding-dust conservation, no-cross, volume-max + tie-break, fuzz conservation, determinism)buy/sell/limitPricereturns 0.Full build log:
plans/dark-pool-example.md.Notes for review
examples/dark-pool/node_modules,.env, and key files are gitignored.🤖 Generated with Claude Code