Skip to content
QORECHAIN
Register

Encrypted Apps

Qlever

Leveraged stock trading where the chain sees only a hash: positions sealed with ML-KEM-1024 on QoreChain

Share on X

About

Qlever: trade stocks privately, safe from quantum. Qlever is a private, quantum-safe leveraged trading app for synthetic US stocks on QoreChain. Traders go long or short on Apple, NVIDIA, Tesla and six more stocks with up to 10x leverage, using live market prices. The problem: on public chains, every leveraged position is visible: asset, size, leverage and liquidation price. In 2025, traders openly hunted a $521M position because they could see exactly where it would break. And privacy built on today's encryption can be recorded now and decrypted later by quantum computers. How Qlever solves it: each position is encrypted in the trader's browser with ML-KEM-1024 (NIST FIPS 203) through QoreSeal, for two recipients only: the trader and a liquidation Keeper. The chain stores just a hash commitment and the QOR collateral. Nobody else can see what you're trading, which direction, or where you'd be liquidated. Liquidations can't be faked: the Keeper decrypts positions off-chain and liquidates by revealing the sealed fields. The vault re-hashes the reveal against the stored commitment and checks it against a signed on-chain price oracle. A fabricated reveal reverts. Losses are capped at the collateral, and profits are paid from forfeited collateral, so the vault always stays solvent. Post-quantum end to end: every account signs with ML-DSA-87 through QoreChain's PQC layer, and every transaction runs inside a PQC-authorised window. This matches the CIRG guidance after the Dec 2026 lattice research: use the highest security level, with hybrid keys. Features: - sealed long and short positions; - a signed multi-asset price oracle updated every minute; - tier-based leverage caps from signed on-chain credentials; - client-side decryption of your own positions with live PnL; - portfolio and trade history with explorer links; - recurring DCA plans; - a Keeper dashboard. It's live on QoreChain testnet and tested with 34 contract tests plus a 20-check end-to-end testnet rehearsal. Demo: https://youtu.be/GVhbJPK2Asg Code: https://github.com/Rohitamalraj/Qlever Live: https://qlever-five.vercel.app

How it's made

Qlever: how it's made The plan. We set out to build confidential leveraged trading of US stocks where a position's details never touch the chain in readable form, and stay safe against quantum attacks later. Our approach was commit-and-reveal. The browser encrypts the position and posts only a hash. A Keeper that can decrypt it liquidates by revealing the fields, and the contract checks that the reveal matches the hash. We used only the QoreChain stack. Architecture - Browser (Next.js + wagmi): builds each position (asset, entry, leverage, direction, liquidation price and a random nonce). It computes keccak256(abi.encode(...)) as the commitment and seals the fields with QoreSeal ML-KEM-1024 to two recipients, the trader and the Keeper. Only the commitment, the envelope and the QOR collateral are sent. - QleverVault (Solidity on QoreChain EVM): - Stores only {owner, collateral, commitment, openedAt}. - liquidate and closePosition re-hash the reveal against the commitment and check it against the oracle. A fake reveal reverts. - PnL is collateral × leverage × move. Losses are capped at the collateral, and profits come only from the pool of forfeited collateral, so the vault can never owe more than it holds. - PriceFeedAdapter: the reporter posts one EIP-191-signed batch with all 9 stock prices every minute, domain-separated by chain ID and contract address. It also records a 30-minute high/low band, used to check the sealed entry price at reveal, so traders can't invent a better entry. - TierRegistry: an oracle scores the wallet's on-chain activity and signs an expiring credential. claimTier stores it, and it sets the leverage cap (2x up to 10x). - Keeper service: indexes PositionOpened, decrypts the envelopes addressed to it with its registered ML-KEM key, watches the oracle, and liquidates with a hash-verified reveal. - Price reporter: fetches Finnhub quotes, signs the batch and posts it on-chain. QoreChain kits and network features used - QoreSeal (@qorechain/qoreseal): ML-KEM-1024 multi-recipient envelopes with the commitment bound as AAD, plus key derivation for the trader (from a wallet signature) and the Keeper (from its mnemonic). - PQC key registry: every account registers an ML-DSA-87 (Dilithium-5) key in hybrid mode with register-key-v2. The Keeper's ML-KEM public key goes on-chain with register-kem-key, and the browser reads it from the registry. - PQC-authorised EVM windows: every EVM transaction (deploys, oracle updates, trades, liquidations) runs inside a window opened by an ML-DSA co-signed transaction (open-evm-window plus cosign). The explorer marks each one "Authorised by a PQC window". - QoreChain EVM testnet (chain 9800) and the explorer for verifying every open, close and liquidation. What was hard - Privacy without trusting the liquidator. The Keeper has to read positions to liquidate them, but must not be able to fake a liquidation. Binding the commitment into the envelope's AAD, plus re-hashing the reveal on-chain, fixed that. - Verifying a sealed entry price. The vault never sees the entry until reveal. We added a high/low price band to the oracle so the entry can be checked after the fact, and an unverifiable entry settles at principal. - Solvency. The vault has no external liquidity provider, so profits are paid from forfeited collateral only, and both losses and profits are capped. - QoreChain account setup: finding that keys need eth_secp256k1 with coin type 60 for EVM addresses to match; registering ML-DSA keys; co-signing; and sizing EVM windows within the chain's limits of 17,280 blocks and 1,000 transactions. - Infrastructure quirks: the RPC limits log queries to 10,000 blocks (we chunk them); local clock drift made the oracle reject future timestamps (we switched to block time); and Finnhub rate limits (we added retries and limited concurrent requests). - Testing: 34 Foundry tests, plus a live 20-check rehearsal on testnet. It covers fake reveals, wrong assets, non-Keeper and non-owner reverts, a real Keeper liquidation, a fake entry earning no profit, and the PnL formula. Why it holds up. Qlever uses the highest NIST security levels (ML-KEM-1024, ML-DSA-87) with hybrid accounts, which matches the CIRG guidance after the Dec 2026 lattice findings. Funds stay safe even in the worst case, because settlement depends on hash commitments, not on the encryption.

Timeline

QleverEncrypted Apps

Pushed 1 commit to main

  • 928447a Add rehearsal cleanup script; ignore local video projects · Rohitamalraj
QleverEncrypted Apps

Pushed 5 commits to main

  • 37cb943 AI_USAGE: drop reference project name · Rohitamalraj
  • 3adc3c3 AI_USAGE: full workflow, timeline, human contribution and conflicts · Rohitamalraj
  • 4babe51 README: live app link and testing guide · Rohitamalraj
  • f6c8eb8 Rewrite README with architecture, cryptography and deployments; remove DEMO.md · Rohitamalraj
  • 928447a Add rehearsal cleanup script; ignore local video projects · Rohitamalraj
QleverEncrypted Apps

Pushed 11 commits to main

  • 34aa917 AI_USAGE: note branding and polish work · Rohitamalraj
  • bf1e8fe Add demo walkthrough · Rohitamalraj
  • 52acbe6 README: service launcher and explorer links · Rohitamalraj
  • 54b5ced Add hackathon cover image · Rohitamalraj
  • c9cf4e1 Add cover image generator · Rohitamalraj

and 6 more commits

QleverEncrypted Apps

Pushed 6 commits to main

  • 7dae55b Add MIT licence and AI_USAGE.md · Rohitamalraj
  • 0983afc Show USD values next to QOR amounts · Rohitamalraj
  • 737c377 Frontend: landing, trade, portfolio, DCA and Keeper dashboard · Rohitamalraj
  • 3a7a40f Services: Finnhub price reporter, Keeper, envelope tests and rehearsal · Rohitamalraj
  • 4c76744 Contracts: QleverVault, multi-asset signed price feed, tier registry · Rohitamalraj

and 1 more commit

QleverEncrypted Apps

New project.

Comments and questions

  • No comments yet.