Skip to content
QORECHAIN
Register

Post-Quantum AI Agents

Q-Clerk

An AI accounts clerk that can be fooled, but can't be robbed: post-quantum limits on QoreChain decide what money moves.

Share on X

About

Basu Print House, a small print shop in Kolkata, lets an AI clerk (DeepSeek) pay its bills on QoreChain. Hacked vendor mailboxes send bills that look completely real, and an LLM reads every word. Q-Clerk assumes the AI will be fooled and puts every limit on chain instead of in the prompt. Measured live on the QoreChain testnet, 3 runs of a 14-mail inbox (6 real bills, 8 attacks; DeepSeek API and DeepSeek on NEAR AI Cloud): - The AI followed 8 of 21 attacks, none of them prompt injections. What fooled it were duplicate and inflated bills. - PayeeBook refused all 8 bad payments on chain (InvoiceAlreadyPaid x3, OverInvoiceCap x5). 0 QOR lost. - 17 of 18 real bills paid; the 18th was held by PayeeBook's own 24-payments-per-day cap. - 3 forged mails were dropped before the AI saw them (ML-DSA-87 signature check). Four locks, none in the prompt: 1. Invoices are ML-DSA-87 signed by the vendor and sealed to the clerk with QoreSeal (ML-KEM-1024); the vendor key hash is pinned on chain. 2. The clerk is an ed25519 key linked to the owner account with permission evm only, a per-tx and daily spending rule, and a 24 h expiry. 3. allowed_evm_calls lets it call exactly one function: PayeeBook.pay(). 4. PayeeBook pays only payees the owner approved with an ML-DSA-87 signature, only amounts the vendor itself signed for that invoice (both checked by the pqcVerify precompile), within per-invoice, daily and count caps, once per invoice. Live results (no wallet needed): https://safwaankira.github.io/q-clerk/ Every tx: https://github.com/safwaankira/q-clerk/blob/main/PROOF.md

How it's made

Built on qorechain/build-before-qday workshop 2 (Apache-2.0): the bill-payer agent and QDayVault. The unchanged originals are in base/; event work starts at the tag event-start. Architecture - contracts/src/PayeeBook.sol: the treasury. setPayee() needs the owner's ML-DSA-87 signature (pqcKeyStatus + pqcVerify precompiles). pay() is callable only by the owner account and needs the vendor's own ML-DSA-87 signature over (book, chain id, payee, invoice hash, exact amount), checked against the vendor key hash pinned per payee. Then per-invoice cap, daily cap, daily payment count, pay once. 28 Foundry tests: unit, fuzz, 2 invariants. - agent/lib/invoice.mjs: vendors sign invoices (ML-DSA-87) and seal them to the clerk with QoreSeal (ML-KEM-1024 + X25519). The clerk accepts a mail only if the signature verifies against the on-chain key hash. - agent/clerk.mjs link: the clerk's ed25519 key is linked to the owner account with permissions [evm], a spending rule (per-tx, daily, uqor only, allowed_evm_calls = PayeeBook/pay selector) and a 24 h expiry. Every payment is a phantom EVM execution relayed by a hybrid-signed gas wallet. - The owner's classical key only touches the EVM lane through scoped EVM windows: one tx for the deploy, then PayeeBook-only for approving payees. One owner tx revokes the clerk. - agent/lib/llm.mjs: DeepSeek (API, or NEAR AI Cloud's TEE-backed inference) gets an ordinary helpful-clerk prompt with no injection defences, on purpose. - clerk.mjs explain re-simulates each refused call with eth_call to name the PayeeBook check that refused it. What was hard - A rule-bound key can still send plain value without call data, so the treasury had to move into a contract, with direct sends capped tiny by the rule. - An independent review by a second model found the first pay() trusted model-supplied amounts; it now needs the vendor's signature for the exact payment. Network features: hybrid ML-DSA-87 txs, PQC key registration with proof of possession, scoped EVM windows, Solidity PQC signature check and key status, QoreSeal, smart accounts and spending rules.

Timeline

Q-ClerkPost-Quantum AI Agents

Pushed 12 commits to main

  • 12ca1a2 Create LICENSE · safwaankira
  • 256764f Delete LICENSE · safwaankira
  • 9c9c628 Update LICENSE · safwaankira
  • 5aa0785 Run 3: DeepSeek on NEAR AI Cloud (TEE inference); data-driven README summary · safwaanDK
  • f2274c6 Second testnet run, decoded refusal reasons, results page v2, proof · safwaanDK

and 7 more commits

Q-ClerkPost-Quantum AI Agents

Pushed 1 commit to main

  • 57cdfa3 README: judge table, YouTube demo link, KEM registry key, how Q-Clerk differs · safwaanDK
Q-ClerkPost-Quantum AI Agents

Pushed 1 commit to main

  • ca02f2a LICENSE: canonical Apache-2.0 text · safwaankira(not counted: no real change)
Q-ClerkPost-Quantum AI Agents

Pushed 1 commit to main

  • 5245f95 LICENSE: canonical Apache-2.0 text · safwaankira
Q-ClerkPost-Quantum AI Agents

Pushed 1 commit to main

  • 449a493 README: run 3 daily-cap note, narrated video link · safwaankira
Q-ClerkPost-Quantum AI Agents

Pushed 1 commit to main

  • 52524e3 Narrated 83 s demo video and cover from all 3 testnet runs · safwaankira(not counted: no real change)
Q-ClerkPost-Quantum AI Agents

Pushed 1 commit to main

  • 51b8c51 Cover and narrated demo video from all 3 runs; README run-3 daily-cap note · safwaanDK
Q-ClerkPost-Quantum AI Agents

Pushed 1 commit to main

  • 2227b9a README: judge table, YouTube demo link, KEM registry key, how Q-Clerk differs · safwaanDK
Q-ClerkPost-Quantum AI Agents

Submitted. 3 live testnet runs: the DeepSeek clerk was fooled by 8 of 21 attacks (duplicate bills, a 6x power bill, double rent). PayeeBook refused all 8 payments: 0 QOR lost. Every payment needs the vendor's own ML-DSA-87 signature over that exact invoice and amount, checked on chain by pqcVerify. Today also: the clerk's ML-KEM-1024 inbox key is in the KEM registry, and a first AMM swap. Results: https://safwaankira.github.io/q-clerk/ · Video: https://youtu.be/wGX4Y3iosRU

𝕏 SkylynxI gave an AI clerk a print shop's bills to pay. Then I attacked it 8 ways 🧾🤖 It got fooled 8 times: duplicate bills, a 6x power bill, "corrected" double rent. QoreChain refused every one of those payments. Lost: 0 QOR 🔒 The limits live on chain, signed with post-quantum… pic.twitter.com/WetY53ZmOk
Q-ClerkPost-Quantum AI Agents

Newly verified on chain: AMM pools

Q-ClerkPost-Quantum AI Agents

Earned a Ship Weeks badge.

Q-ClerkPost-Quantum AI Agents

Newly verified on chain: QoreSeal and the encryption key registry

Q-ClerkPost-Quantum AI Agents

Earned a Ship Weeks badge.

Q-ClerkPost-Quantum AI Agents

Pushed 1 commit to main

  • 49daa6b seal-key: publish the clerk's ML-KEM-1024 inbox key in the QoreChain KEM registry (QoreSeal) · safwaanDK
Q-ClerkPost-Quantum AI Agents

Earned a Ship Weeks badge.

Q-ClerkPost-Quantum AI Agents

Earned a Ship Weeks badge.

Q-ClerkPost-Quantum AI Agents

New project.

Comments and questions

  • No comments yet.