About
PQ Guardian Agent pays a team's bills autonomously inside on-chain limits (send only, 1 QOR per payment, 3 QOR per day, 24-hour expiry), while the treasury sits in a vault that only releases with an ML-DSA-87 guardian signature. A leaked agent key costs at most the daily limit.
Giving an AI agent a normal private key makes its spending limits only as strong as its own code. One bug, one prompt injection, or one stolen server removes them. PQ Guardian Agent moves the limits on chain.
Three keys, three roles. The owner holds the funds and signs hybrid (secp256k1 plus ML-DSA-87). The agent holds only an ed25519 key linked to the owner account under a SpendingRule the chain checks on every payment: send permission only, 1 QOR per payment, 3 QOR per day, uqor only, and a 24-hour expiry. A separate gas wallet submits the agent's signed requests and pays fees; it never holds owner funds. The agent code deliberately has no value-limit check, so every over-limit refusal in the demo comes from the chain itself.
Target control is layered and stated honestly. The documented SpendingRule has no recipient-allowlist field, so the vendor allowlist and an invoice memo hash (sha256 of recipient, amount, and memo) are checked by the agent before signing, the recipient and amount are bound inside the authenticator sign-bytes so a relayer cannot redirect a payment, and the on-chain per-payment, daily, denomination, permission, and expiry rules are the backstop. Each payment is authenticated by the agent key's signature over a domain-separated, replay-bound digest with a per-authenticator nonce, submitted by the relayer under its own hybrid signature.
Larger funds stay in QDayVault, a Solidity vault on the EVM lane. Withdrawals require an ML-DSA-87 guardian signature verified on chain through the pqcVerify precompile (0xa01) against the guardian key read from pqcKeyStatus (0xa02) on every withdrawal, so on-chain key rotation is followed automatically with no redeploy. A stolen classical key alone cannot move anything: the demo attack is blocked by the vault itself. The owner can revoke the agent in one transaction, after which the chain refuses its payments. Worst case, a compromised agent server costs at most the daily limit, and only until expiry or revoke.
Built during Build Before Q-Day on QoreChain Diana testnet. The vault and agent flows are based on the official Workshop 2 examples (Apache-2.0, credited in the repository) with original extensions: vendor allowlist and invoice-hash binding with honest agent-side versus chain refusal labels, zero-address and zero-amount vault guards, guardian-rotation and failed-transfer tests (12 Foundry tests passing), a read-only demo verifier, and a threat model that names the maximum loss per threat.
How it's made
How it works (for judges):
1. Owner registers the ML-DSA-87 key once, then links the agent key with `link 1 3`: send only, 1 QOR per payment, 3 QOR per day, 24-hour expiry. Rules are read back from chain with `rules`.
2. `run` pays the bill list. Allowlisted bills inside the limits are PAID. A 5 QOR invoice is REFUSED BY THE CHAIN (per-payment limit). A bill that crosses 3 QOR total is REFUSED BY THE CHAIN (daily limit). A bill to a non-allowlisted vendor, or with a tampered invoice hash, is REFUSED BY AGENT before signing and is never signed.
3. Vault: a forged-signature withdrawal is blocked (BadPqcSignature); the guardian's ML-DSA-87 withdrawal succeeds. `forge test` runs the full suite locally against mocked precompiles.
4. `revoke` disables the agent in one owner transaction; the next payment is refused by the chain.
5. `scripts/verify-demo.mjs` checks any demo transaction hash against the public testnet REST endpoint: success code, PQCHybridSignature extension, and pqc_hybrid_verify status.
Tech stack:
- Solidity 0.8.28, Foundry (vault contract, tests, deploy script)
- Node.js, QoreChain SDK 0.14.0, CosmJS, noble-curves (agent CLI)
- QoreChain Diana testnet (qorechain-diana, EVM chain ID 9800): hybrid secp256k1 + ML-DSA-87 signing, abstract-account authenticators and SpendingRules, pqcVerify and pqcKeyStatus precompiles, scoped EVM window
QoreChain features used:
- Hybrid-signed transactions (secp256k1 + ML-DSA-87, FIPS 204)
- ML-DSA-87 key registration with proof of possession
- Linked authenticator keys with possession proof (chain v3.2.8 flow)
- SpendingRule enforcement: per-transaction, daily, denomination, expiry
- Authenticator sign-bytes with per-authenticator nonce, relayer model
- pqcVerify (0xa01) and pqcKeyStatus (0xa02) precompiles in the vault
- Scoped EVM authorisation window for contract deployment
- Public REST verification of pqc_hybrid_verify events
Run it (judge instructions):
Local, no funds needed:
pnpm install
node agent/agent.mjs selftest
node agent/agent.mjs check agent/bills.example.json agent/vendors.allowlist.json
forge test
node scripts/verify-demo.mjs --selftest
node scripts/demo-dryrun.mjs
Funded Diana testnet flow (throwaway accounts only, keys in ~/.config/qday/*.env, never in the repo):
node agent/agent.mjs init
node agent/agent.mjs owner-init
# fund owner and gas wallet at https://dashboard.qorechain.io/faucet
node agent/agent.mjs register owner
node agent/agent.mjs register gas
node agent/agent.mjs link 1 3
node agent/agent.mjs rules
node agent/agent.mjs run agent/bills.example.json agent/vendors.allowlist.json
node agent/agent.mjs revoke
Testnet addresses:
- Owner testnet address (qor1): qor1hvk58md7uj4au252xzye5peyxgm74x6px5j742
- Owner EVM address (0x): 0xbB2D43edBee4Abde2A8A30899A07243237ea9B41
- Gas wallet (qor1): qor1pq4ex4ngurgm647uv9zv78meukf52rvuk2cypm
- Agent key identifier (public only): ed25519 af3b8753c12d5577... (revoked after the demo run)
- QDayVault (0x): 0x2566FCCD411847100C667D85D5AeBa195F722027
- Key transactions: link 63E757E9193BE4C7315D4C317A462A4AA49EC834D61D6F6AC2283B126D131FE5, paid A09C96EC9DD9B8E530A7BB96D2C9762140688AD802577D7B2F49F112B519D5FC, refused per-payment E63C126EF2A5EFA0890BFF2493EB5D312CB58FE0DC508A1FFBC1FCE248E6B372, refused daily 4AFCD799B2EC0CCC3CDCFD1D4D7FF0F6C46937554C5246B6C90F4A6C9249E8B4, vault withdraw 0x7655fecc3fad349705473de0835ab78c9eda139279d4a58951e05b5d4607955a, revoke 1AE7B1AE6C72F4D559AF23699C411C24E99127C42559B4F0672FA77FE7397D43
Full evidence table: docs/addresses.md in the repository.
AI-native declaration: AI tools were used for research, blueprinting, scaffolding, code drafting, tests, and documentation, as recorded in AI_USAGE.md. Human decisions: track and concept selection, limit values, vendor list, security trade-offs, and every signing, funding, recording, and submission step. All generated code was verified with Foundry tests, agent selftests, and live testnet checks before any claim was written down.
Credits and license: Built during Build Before Q-Day. Based on the official QoreChain Workshop 2 examples `01-qday-vault` and `02-pq-agent` (Apache-2.0) from https://github.com/qorechain/build-before-qday, credited in the files they inform, with original extensions marked. Original work is MIT licensed; adapted files keep their Apache-2.0 headers. `lib/forge-std` is the Foundry test library under its own licenses.