Skip to content
QORECHAIN
Register

Post-Quantum AI Agents

Qill-switch

Quantum-signed mandates for AI agents: a stolen classical key can't loosen anything, and one ML-DSA-87 signature stops e

Share on X

About

Qill Switch gives an AI agent a mandate: plain-English instructions compiled into on-chain rules and signed with the owner's ML-DSA-87 key. The agent can only act inside the mandate. Anything that loosens control (a new mandate, resume, withdraw, a new executor or owner key) needs the owner's post-quantum signature, verified on chain by QoreChain's pqcVerify precompile. A stolen ECDSA key alone can never loosen anything. How it maps to the track: - Scoped EVM window: owner commands are relayed through a window allowed to reach only the vault (1 tx, exact fee budget), then closed and verified closed. - Limits on transactions, value, duration and target: per-trade cap, UTC-daily cap, mandate expiry, pool and token allowlists in the QillVault contract, plus window limits. - Smart-account spending rules: the agent's key is linked to an x/abstractaccount smart account with the evm permission only; its single rule lets it call only vault.trade and move at most 1 uqor of native QOR per day. - Authenticated messaging: every owner and guardian action is a domain-separated ML-DSA-87 message (chain id, vault, action, params, nonce, expiry) checked by pqcVerify. Also included: an independent guardian service that must co-sign large trades with its own ML-DSA-87 key and can only veto; a Q-Day button that freezes every vault, revokes every agent key and closes every EVM window, then verifies it on chain; an owner CLI and dashboard where signing happens locally, never in the browser; and "Steal This Agent", a public challenge that publishes the agent's private key and a funded account's key. Results on qorechain-diana: 94 tests passing (including fuzz and invariant tests); our attack bot made 71 attacks with the stolen keys (32 on the drill deployment, 39 on the challenge) with 0 successes and 0 value moved; Q-Day froze a test fleet in one round. Built with Hardhat, viem, @qorechain/sdk, @noble/post-quantum and Gemini. MIT licensed.

How it's made

Architecture - Contracts (Solidity 0.8.24, Hardhat 3): QillVault holds the agent's funds. It has no msg.sender owner: every owner action checks keccak256(pubkey) == ownerKeyHash, a nonce, an expiry, and an ML-DSA-87 signature through QoreChain's pqcVerify precompile (0x...0A01), always called through the typed interface so an inactive precompile fails closed. Trades come only from the executor (the agent's smart account), inside an active mandate: per-trade cap, UTC-daily cap, expiry, pool and token allowlists, and a guardian ML-DSA-87 co-signature above a soft limit. Exact approvals, output measured by balance delta, reentrancy guard, irreversible Q-Day freeze. No delegatecall, selfdestruct, proxies or generic calls. - Messages: one canonical format, abi.encode("QILLSWITCH_V1", chainid, vault, action, keccak256(params), nonce, expiry), built identically in Solidity and TypeScript with shared test vectors. - Chain layer (TypeScript, @qorechain/sdk + viem): unified eth_secp256k1 accounts whose ML-DSA-87 key comes from a separate secret, so the ECDSA key reveals nothing about it; hybrid-signed Cosmos-lane transactions; MsgRegisterPQCKeyV2 with proof of possession; EVM windows; x/abstractaccount smart accounts. - Agent: its secp256k1 key is linked to a smart account with the evm permission only. The account's single spending rule allows only <vault>/<trade selector> and 1 uqor of native value per day. A relayer submits the agent-signed MsgExecuteEVM. Trade sizes are set by a deterministic strategy inside the mandate; the LLM only writes the explanation. - Mandates: plain English → template parser or Gemini structured output → a deterministic validator (no missing or zero limits, at most 30 days, known pools and tokens only, global ceilings) → vault params, the smart-account rule and textHash/rulesHash, all signed together by the owner. - Guardian: a separate service. It reads facts from chain itself, applies a deterministic veto policy (caps, slippage, price impact, rate limits), lets an optional LLM review add a veto (never remove one), and simulates the exact trade before signing. - Owner tools: the qill CLI and a React dashboard. Signing happens in a localhost API behind a session token, never in the browser. - Q-Day button: freezes every vault, revokes every linked key, closes every window, then re-queries and retries until everything is confirmed. Network features used pqcVerify and pqcKeyStatus precompiles, ML-DSA-87 key registration with proof of possession, hybrid-signed transactions, EVM authorisation windows with allowedTargets, x/abstractaccount spending rules and linked keys, MsgExecuteEVM. Kits @qorechain/sdk and @qorechain/evm, viem, Hardhat 3 with forge-std Solidity tests (fuzz and invariant), @noble/post-quantum, @google/genai (Gemini), React and Vite, Vitest, Gitleaks. What was hard - Verifying before building: a spike showed that FIPS 204 ML-DSA-87 with an empty context, signed by @noble/post-quantum, verifies on chain, and that invalid signatures return false instead of reverting, so the vault must check the result itself. - An account doesn't exist until it is funded, so "register before funding" became: send only the registration fee, register, verify proof of possession, then top up. - Windows scoped with allowedTargets refuse contract creation, so deployment needed one exactly-sized unscoped window, closed right away. - A failed MsgExecuteEVM comes back as a code-0 transaction with an abstractaccount_execution_failed event, so every relay checks the events. - Events emitted inside MsgExecuteEVM can't be read through eth_getLogs, so trades are verified from state instead (vault balance, spentToday). - We found that a rule-bound linked key can still send plain value up to its limits. We cut the limit to 1 uqor and keep the smart account at 0 before publishing the agent's key in Steal This Agent. Results: 94 tests passing; 71 attacks with the stolen keys, 0 successes.

Timeline

Qill-switchPost-Quantum AI Agents

Pushed 2 commits to main

  • 7f7fcff docs: drill registration confirmed · CapThunder19
  • 72d2842 attack-bot: try linking an attacker key to the drill account via account abstraction (classical + forged hybrid); drill run 34/0 · CapThunder19
Qill-switchPost-Quantum AI Agents

New project.

Comments and questions

  • No comments yet.