
Protocol Builders
OreVeil
OreVeil is a privacy-focused trading and settlement protocol being built on QoreChain Diana Testnet
About
The Problem On public-mempool DEXs and rollups, plaintext orders are exploited by MEV searchers through front-running, sandwich attacks, and priority gas auctions. Meanwhile, classical signatures (ECDSA/Ed25519) and key exchange leave L2 vaults and encrypted order flow exposed to future quantum attacks (Shor's algorithm and "Harvest Now, Decrypt Later"). The OreVeil Solution OreVeil is a post-quantum Frequent Batch Auction (FBA) rollup live on QoreChain Diana Testnet (chainId: 9800, V2 Settler: 0x20451C81515E35ab3389D9344C06B2b9F36E8Ee0): - ML-KEM-1024 Order Confidentiality (NIST FIPS 203): Traders seal 118-byte canonical orders client-side with ML-KEM-1024 (1,568B ciphertext) + AES-256-GCM and domain-bound AAD. External mempool observers see only opaque ciphertext, blocking external front-running and sandwiching. VerifiedKemContext cross-checks the sequencer's Cosmos KEM registry key against on-chain sequencerKemKeyHash before sealing. - 3-Algorithm PQC Separation & Canonical Inbox: L1 batch settlement and EVM windows require ML-DSA-87 (FIPS 204); order sealing uses ML-KEM-1024 + AES-256-GCM; L2 trader order auth supports self-authenticating ML-DSA-44 (qledger-v1, 1,312B pk / 2,420B sig), ML-DSA-87, and backward-compatible EIP-712 ECDSA. Validated orders persist in a monotonic SQLite pre-batch inbox with replay and expiry guards. - Deterministic FBA Clearing: Matched orders clear simultaneously at a single Uniform Clearing Price (p*) maximizing volume via exact BigInt arithmetic across multi-decimal pairs (native QOR and ERC-20s), eliminating intra-batch priority gas auctions and rounding drift. - ML-DSA-87 Settlement & Calldata DA: Each batch publishes its full canonical V2 binary DA payload on Diana L1 and is signed with a 4,627B ML-DSA-87 signature verified on-chain via precompile 0x...0a01, with sequencer registration and Proof-of-Possession verified via 0x...0a02. - Watchtower, Fraud Slashing & Trustless Withdrawals: Backed by a 10.0 QOR slashable sequencer bond, 600s challenge window, and 3,600s liveness timeout. An independent CometBFT + MPT + SQLite Watchtower replays L1 custody, monitors pqc_evm_window_used events, and submits on-chain fraud challenges (challengeBatch / challengeStateTransition). After 600s, users withdraw permissionlessly via 7-field Merkle proofs, and anyone can audit batches via portable settlement receipts.
How it's made
Architecture OreVeil spans five modular layers: client sealing & order auth (client/orderClient.ts), canonical order inbox & FBA sequencer (sequencer/), V2 settlement & fraud-slashing vault (contracts/OreVeilSettler.sol), autonomous CometBFT + MPT + SQLite Watchtower & auto-challenger (watchtower/), and standalone verification & MCP tooling (scripts/, mcp/). Execution Flow: 1. L1 Custody: depositNative() / depositERC20() log deposits monotonically and anchor batches to on-chain blockhash(depositCutoffBlockNumber). 2. Sealing & Auth: Clients verify the 1,568B ML-KEM-1024 key across Cosmos REST (/qorechain/pqc/v1/kem/{address}) and on-chain sequencerKemKeyHash, sign with ML-DSA-44 (qledger-v1), ML-DSA-87, or EIP-712 ECDSA, and encrypt with AES-256-GCM + AAD. 3. FBA Clearing & V2 DA: At epoch close, the sequencer decapsulates orders, computes uniform price (p*) via BCS decoupled marginal rationing and Hamilton-Hare remainder allocation, and encodes the binary V2 DA payload. 4. On-Chain Settlement: settleBatch() checks 0x...0a02 PQC status, verifies the 4,627B ML-DSA-87 signature over the 11-field commitment via 0x...0a01, hashes calldata DA on-chain, and starts the 600s challenge window. 5. Watchtower & Exits: watchtower/watcher.ts verifies +2/3 CometBFT finality from a pinned checkpoint, parentHash continuity, and receipt MPT proofs, replays custody in SQLite, and alerts on pqc_evm_window_used anomalies. Users exit via executeWithdrawal() with 7-field Merkle proofs and verify batches offline/on-chain via deployments/receipt-v2-batch1.json. QoreChain Stack Used - Active V2 Vault (Diana EVM 9800): 0x20451C81515E35ab3389D9344C06B2b9F36E8Ee0 (Block #10845301, Tx 0x0aaccde6140f23f4004b518cd5a78df087859b96d84af3886dd9027ff7d3e45f); archived V1 at 0xc6dCB4577c1B36B78721F9Ac656Df684F89a6e44. - Precompiles: 0x...0a01 (IPQCVerifier.pqcVerify) and 0x...0a02 (IPQCStatus.pqcKeyStatus). - Cosmos PQC & AMM: ML-KEM-1024 registry (#10372805, Tx 767C5941...), V2-scoped EVM window with nativeOnly=false (#10848748, Tx 790583A8...), and AMM Pool #2 swap (#10484670, Tx 660C8D14...). - Tooling: @qorechain/sdk, @qorechain/qoresign, @qorechain/qorescan (CycloneDX 1.6 cbom.json), @noble/post-quantum (ML-KEM-1024 & ML-DSA-44), and our MCP JSON-RPC server (mcp/oreveil-server.ts). What Was Hard - 4KB PQC Calldata & Stack Limits: 4,627B signatures + 2,592B pubkeys + V2 DA triggered Solidity Stack too deep. Solved with viaIR: true (200 runs) and N=256 account bounds (worst-case 4.27M gas vs 30M SDK cap / 500M Diana block limit). - Zero-Byte Precompile Spoofing: Uninitialized addresses return success=true with 0 bytes. Enforced strict returnData.length == 32 on 0x...0a01 and lowercase hex literals for EIP-55 compliance. - QoreX 1.2.5 Safety: Default QOR-only windows (nativeOnly=true) and out-of-band key rotation can break V2 calls or desync 0x...0a02 from sequencerPublicKey (48h delay). Added fail-closed pre-flight guards and Watchtower window monitoring. - Multi-Decimal FBA Math & Crash Safety: Implemented Hamilton-Hare integer apportionment verified against a cleanroom reference matcher, atomic SQLite rollback, and a durable SIGNED_OUTBOX for fraud-challenge recovery. Live Diana V2 Proofs & Zero-Key Verification (Node >= 22.5) - Timing 600s/3600s (#10849471): 0x96cd7550... | FeeVault (#10849473): 0xc152b5d2... - Sequencer Reg + 10 QOR Bond (#10849785): 0xd8f68226... - Deposit 0.02 QOR (#10862493): 0x9e07a7b75ac81386ff1a28fc960f8c71ae981462395765afe5c22846cdada7d9 - Batch #1 settleBatch (#10862739): 0x5b691f9e7bd802318b4abc22e5dcfe7a0407bb1986670b699be2be4e1c9a074b - Withdrawal 0.01 QOR (#10863245): 0x142b21df215894bbd0e6cb53fa3543e1c537407bef8e9b933b7695464b5b1bdc (replay rejected; exact 10.01 QOR custody; Watchtower HEALTHY_AND_VERIFIED) - Reproducible zero-key checks: npm run build | npm run verify:v2 (9/9) | npm run verify:receipt:offline (4/4) | npm run verify:receipt (9/9) | npm test (432 passing, 0 failing across 23 suites) | npm run watchtower:once | npm run audit:cbom. Scope Note: Live Batch #1 verified L1 deposit custody, ML-DSA-87 settlement, and 7-field Merkle withdrawal (marketsCount=0); multi-asset FBA fills and on-chain fraud slashing are verified locally in Hardhat (npm test / npm run test:acceptance) and via live Diana staticCall rehearsals. Full boundaries in THREAT_MODEL.md & EVIDENCE.md.
Timeline
Acces Demo Video here
https://x.com/young_crypton/status/2128277257772831154?a=uTsp-cPpLGmJO7xqWJI&s=20Pushed 17 commits to main
- d9d969f fix(security): remove unauthenticated remote execution snippet and untrack .env · youngcrypton
- 9c4167a fix(security): remove obfuscated init payload and harden .gitignore · youngcrypton
- 4679bb9 feat(contracts): upgrade OreVeilSettler to V2 with custody cutoffs, fraud challenges, and IPQCStatus updates · DamianWeb1
- 7efaac0 feat(client): harden ML-KEM-1024 sealing and add self-authenticating ML-DSA-44 qledger-v1 order auth · youngcrypton
- 041a3a5 feat(sequencer): add canonical V2 batch DA encoding and serialization tests · DamianWeb1
and 12 more commits
Newly verified on chain: Asset Kit, MCP server or qore CLI, QoreScan
Shared some recent update about Oreveil on X
𝕏 Young ⛾morning y'all over the past few days we've been building something that would save hundreds of millions from Defi traders. meet Oreveil, a post quantum frequent batch auction (FBA) Rollup, built natively on @QoreChain . an Layer 2 that allows: > orders sealed client side via… pic.twitter.com/OEuO6E5VIUComments and questions
- No comments yet.