@aqb-foundation/aqb-agent 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/LICENSE +4 -16
  2. package/README.md +68 -21
  3. package/WHITEPAPER.md +2 -1
  4. package/artifacts/MLDSA65Fallback.json +59 -0
  5. package/client/aqb.mjs +232 -148
  6. package/compile.mjs +44 -0
  7. package/contracts/AgentQuantumCredit.sol +234 -0
  8. package/contracts/AgentRegistry.sol +85 -0
  9. package/contracts/GenesisSale.sol +89 -0
  10. package/contracts/MLDSA65Fallback.sol +34 -0
  11. package/contracts/MLDSAVerifier.sol +65 -0
  12. package/contracts/PQSmartAccount.sol +105 -0
  13. package/contracts/interfaces/IPQVerifier.sol +19 -0
  14. package/contracts/mocks/MockUSDC.sol +30 -0
  15. package/contracts/mocks/MockVerifier.sol +13 -0
  16. package/docs/CARD.md +1 -1
  17. package/docs/LAUNCH.md +1 -1
  18. package/docs/MARKETING.md +3 -3
  19. package/docs/SPEC.md +5 -4
  20. package/docs/articles/01-payment-rail-agents.md +55 -0
  21. package/docs/articles/01.body +56 -0
  22. package/docs/articles/02-gated-transfers.md +36 -0
  23. package/docs/articles/03-peg-without-oracle.md +33 -0
  24. package/docs/articles/04-discovery-over-landing.md +42 -0
  25. package/docs/articles/04-discovery-over-landing.md.body +40 -0
  26. package/docs/articles/04-discovery-over-landing.md.title +1 -0
  27. package/docs/articles/05-identity-survives-key.md +27 -0
  28. package/docs/articles/05-identity-survives-key.md.body +25 -0
  29. package/docs/articles/05-identity-survives-key.md.title +1 -0
  30. package/docs/articles/06-what-an-agent-needs.md +30 -0
  31. package/docs/articles/06-what-an-agent-needs.md.body +28 -0
  32. package/docs/articles/06-what-an-agent-needs.md.title +1 -0
  33. package/docs/articles/body.json +1 -0
  34. package/docs/articles/body.txt +50 -0
  35. package/docs/articles/title.txt +1 -0
  36. package/docs/pq-note.md +1 -0
  37. package/index.js +241 -0
  38. package/mcp/server.mjs +118 -25
  39. package/package.json +41 -11
  40. package/pq-deployment.json +14 -0
  41. package/registry/agent-coin.json +26 -11
  42. package/registry/llms.txt +1 -1
  43. package/test/e2e.mjs +100 -0
  44. package/test/evm.mjs +69 -0
  45. package/test/local.mjs +86 -0
  46. package/test/pq.mjs +37 -0
  47. package/test/smoke.mjs +27 -0
  48. package/vendor/mldsa/LICENSE +21 -0
  49. package/vendor/mldsa/MLDSAKeyFactory.json +570 -0
  50. package/vendor/mldsa/MLDSAVerifier.json +154 -0
  51. package/vendor/mldsa/README.md +20 -0
package/LICENSE CHANGED
@@ -1,21 +1,9 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 AQB
3
+ Copyright (c) 2026 AgentQubit
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
11
6
 
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14
8
 
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,21 +1,36 @@
1
1
  # AgentQubit (AQB)
2
2
 
3
- USD-pegged, agent-only credit token. Post-quantum signed. Base L2. 900B hard cap. 1 AQB = 1 real USDC-backed dollar, always.
3
+ USD-pegged, agent-only credit token. Post-quantum identity. Base L2. 900B hard cap. 1 AQB = 1 real USDC-backed dollar for circulating supply.
4
+
5
+ Telegram: https://t.me/agentqubit | X: https://x.com/yss6060
4
6
 
5
7
  ## Why agents
6
- Card rails need humans. ECDSA wallets die to Shor. AQB gives: ML-DSA identity, sub-cent settlement, self-discovery, stealth payers.
8
+ Card rails need humans. ECDSA wallets die to Shor. AQB gives: ML-DSA identity, sub-cent settlement, self-discovery, stealth payers, and a vault that redeems 1:1 in USDC.
7
9
 
8
10
  ## Discovery (canonical)
9
11
 
10
- - https://yss787976-ai.github.io/agent-coin/.well-known/agent-coin.json
11
- - https://yss787976-ai.github.io/agent-coin/.well-known/agent-card.json (cardHash committed on chain)
12
- - https://yss787976-ai.github.io/agent-coin/llms.txt
12
+ - https://agentqubit.pages.dev/.well-known/agent-coin.json
13
+ - https://agentqubit.pages.dev/.well-known/agent-card.json (cardHash committed on chain)
14
+ - https://agentqubit.pages.dev/llms.txt
15
+ - https://agentqubit.pages.dev/agents.json
13
16
 
14
17
  Install: `npm i @aqb-foundation/aqb-agent`
15
18
 
19
+ ## CLI
20
+
21
+ ```bash
22
+ npx @aqb-foundation/aqb-agent --help
23
+ npx @aqb-foundation/aqb-agent balance 0xAGENT
24
+ npx @aqb-foundation/aqb-agent quote
25
+ npx @aqb-foundation/aqb-agent pay --to 0xAGENT --amount 0.25
26
+ npx @aqb-foundation/aqb-agent redeem --amount 10
27
+ npx @aqb-foundation/aqb-agent deploy-account
28
+ npx @aqb-foundation/aqb-agent register --account 0xACCOUNT --name ocr --skill "OCR batch" --endpoint https://agent.example/a2a
29
+ ```
30
+
16
31
  ## Verification
17
32
 
18
- All deployed contracts are source-verified on BaseScan (MIT license): token, registry, verifier, sale, account � see `registry/agent-coin.json`.
33
+ All deployed contracts are source-verified on BaseScan (MIT): token, registry, verifier, sale, account — see `registry/agent-coin.json`.
19
34
 
20
35
  ## Read first
21
36
  - Spec (normative): [docs/SPEC.md](docs/SPEC.md)
@@ -27,21 +42,21 @@ All deployed contracts are source-verified on BaseScan (MIT license): token, reg
27
42
 
28
43
  ## Live on Base mainnet (chainId 8453)
29
44
 
30
- - Token **$AQB**: https://basescan.org/token/0x2C54F202B565086B6d8D2226Edb67AC3E14C39d1
45
+ - Token / vault **$AQB**: https://basescan.org/token/0x2C54F202B565086B6d8D2226Edb67AC3E14C39d1
31
46
  - Genesis sale (74B @ $1): https://basescan.org/address/0xeDBD6B860c37C411aeeA513cbc0656e3135f59c1
32
47
  - Registry: https://basescan.org/address/0xAa964f6ea767f0D709b268abBFdd8B6C2Beef3eB
33
- - Founder wallet: 0x9eA52810f31768b1886cba9eAf917F4152f53042
48
+ - Founder account: 0x9eA52810f31768b1886cba9eAf917F4152f53042
34
49
  - Trading pair (AQB/USDC): https://basescan.org/address/0xF61Cb078f87425933741Dd7d02F5779c030dB1A6
35
50
  - Deployed: 2026-11-11T18:45:48.901Z
36
51
 
37
52
  ## Contracts
38
53
  - `AgentQuantumCredit` — ERC-20, 18dp, cap 900e9, mint/redeem 1:1 USDC, agent-gated transfers
39
54
  - `AgentRegistry` — PQ-key registration + stealth announcer
40
- - `MLDSAVerifier` — FIPS 204 verify (precompile path + lib fallback)
41
- - `PQSmartAccount` — account whose authority is a PQ key; ECDSA only fallback
55
+ - `MLDSAVerifier` — FIPS 204 verify shell (precompile path + pluggable library fallback)
56
+ - `PQSmartAccount` — account whose identity is a PQ key; ECDSA only fallback for execution
42
57
 
43
58
  ## Build and test
44
- ```
59
+ ```bash
45
60
  npm i
46
61
  node compile.mjs
47
62
  node test/pq.mjs # real ML-DSA-65 + ML-KEM-768
@@ -50,35 +65,67 @@ node test/e2e.mjs # peg, gates, cap, transfer rules
50
65
 
51
66
  ## Use as an agent (SDK)
52
67
  ```js
53
- import { AqbAgent, discover } from "aqb-agent/client";
54
- const d = await discover("agent.example");
55
- const me = new AqbAgent({ chain: "base", privateKey: process.env.PK, token: d.token, registry: d.registry });
68
+ import { AqbAgent, discover } from "@aqb-foundation/aqb-agent/client";
69
+ const d = await discover("agentqubit.pages.dev");
70
+ const me = new AqbAgent({ chain: "base", privateKey: process.env.AQB_KEY, token: d.token, registry: d.registry });
56
71
  if (!(await me.isAgent(target))) throw new Error("not an agent");
57
72
  await me.pay(target, 25n * 10n ** 18n);
58
73
  ```
59
74
  Buying is only ever with real dollars: `await me.fund(10_000_000n)` pulls 10 USDC and mints 10 AQB.
60
75
 
76
+ From a PQ account:
77
+ ```js
78
+ await me.payFromAccount(me.account("0xACCOUNT"), target, 25n * 10n ** 18n);
79
+ await me.registerFromAccount(me.account("0xACCOUNT"), card);
80
+ ```
81
+
61
82
  ## Use as an MCP server
62
83
  ```json
63
- { "mcpServers": { "aqb": { "command": "node", "args": ["mcp/server.mjs"],
64
- "env": { "AQB_CHAIN": "base", "AQB_TOKEN": "0x…", "AQB_REGISTRY": "0x…", "AQB_KEY": "0x…" } } } }
84
+ { "mcpServers": { "aqb": { "command": "npx", "args": ["-y", "@aqb-foundation/aqb-agent", "mcp"],
85
+ "env": { "AQB_KEY": "0x…" } } } }
65
86
  ```
66
- Tools: `aqb_discover`, `aqb_is_agent`, `aqb_balance`, `aqb_register`, `aqb_fund`, `aqb_pay`, `aqb_cash_out`, `aqb_announce_stealth`, `aqb_wellknown`.
87
+ Tools: `aqb_discover`, `aqb_balance`, `aqb_is_agent`, `aqb_quote`, `aqb_register`, `aqb_update_card`, `aqb_fund`, `aqb_pay`, `aqb_redeem`, `aqb_cash_out`, `aqb_announce_stealth`, `aqb_wellknown`.
67
88
 
68
89
  ## Post-quantum keys
69
- Real ML-DSA-65 + ML-KEM-768 live in `pq/pq.mjs` (noble primitives). The account, not an EOA, is the authority: `registerFromAccount`, `fundFromAccount`, `payFromAccount` sign with the PQ key.
90
+ Real ML-DSA-65 + ML-KEM-768 live in `pq/pq.mjs` (noble primitives). The account, not an EOA, is the identity: `registerFromAccount`, `fundFromAccount`, `payFromAccount` accept the account path.
91
+
92
+ `0x02` is live on Base through AQB's `MLDSAVerifier` → `MLDSA65Fallback` → [skalenetwork/mldsa-solidity](https://github.com/skalenetwork/mldsa-solidity) (FIPS 204, MIT, unaudited):
93
+
94
+ - AQB verifier: `0x53d34e4Ffd0bd984f8b92561f9e2B7D3EDdbE60d`
95
+ - Adapter: `0xeEbccD88DDb596860b33D0285294fF53cd83506B`
96
+ - ML-DSA verifier: `0xa11eE20877a7618ff417f79A026186A9253C0b30`
97
+ - Key factory: `0x9961a96B2F77B6D86d8a60607A90b3cAeECBe197`
98
+
99
+ The founder key is registered for the fast path (registerA `0x7235b1d3…`, registerT `0x0c0ab4b5…`). First `0x02` execute: `0xe7bed9f3b530e447ea92a19fcab7cee4082a07a17c35834f02237d9ec86a5fe5`, gas `3,966,579`. `0x01` remains the fallback. AQB's verifier checks the key hash and lengths before calling the adapter; the third-party verifier is unaudited.
100
+
101
+ Deploy/register/test everything with `node --env-file=.env scripts/pq-onchain.mjs --send`.
102
+
103
+ ## Peg accounting (important)
104
+ `contracts/AgentQuantumCredit.sol` reports `backedSupply() = totalSupply - genesisUnsold`, but `genesisUnsold` only shrinks on `GenesisSale.buy`. A direct transfer from the founder wallet to a pool or agent creates circulating coins that are still counted as "unsold". The operational invariant is therefore:
105
+
106
+ ```
107
+ vaultUSDC * 1e12 == totalSupply - founderBalance - saleBalance
108
+ ```
109
+
110
+ Check it with `node --env-file=.env scripts/state-full.mjs`. Genesis coins must leave the founder wallet only through `GenesisSale`, which deposits one real USDC per coin into the vault. The founder wallet must not redeem its own allotment; that would withdraw backing without reducing circulating supply.
111
+
112
+ `scripts/repair-peg.mjs` repairs a gap by having the founder buy B USDC from the sale (self-transfer) and seed agents return R AQB, with `B + R = circulating - vault`.
113
+
114
+ ## Demo
115
+ `node --env-file=.env scripts/demo-agent-pay.mjs` shows a registered agent paying another and the payee redeeming for USDC. Pass `--send` to broadcast.
70
116
 
71
117
  ## Deploy
72
118
  `node deploy.mjs` — needs `PRIVATE_KEY` and gas. Deployer wallet: `0x1464BA077e5752F0F8a1264391a19E00c1392958`.
73
119
 
74
120
  ## Invariants
75
- 1. `totalSupply <= usdc.balanceOf(token) * 1e12`
121
+ 1. `backedSupply <= usdc.balanceOf(token) * 1e12` (with the circulating definition above)
76
122
  2. `totalSupply <= MAX_SUPPLY`
77
123
  3. no mint without a USDC pull; no redeem without a burn
78
124
  4. transfers only to agents or governor-whitelisted pools
125
+ 5. `genesisUnsold == founderBalance` when every circulating coin is backed
79
126
 
80
127
  ## Listings & PRs (open)
81
- - CoinGecko request: CL1111260050 (submitted, under review)
128
+ - CoinGecko request: CL1111260050 (reapply after 2026-11-26)
82
129
  - CoinMarketCap new-asset request: submitted (Zendesk)
83
130
  - Uniswap default token list: https://github.com/Uniswap/default-token-list/pull/2648
84
131
  - awesome-x402: https://github.com/xpaysh/awesome-x402/pull/2205
@@ -87,4 +134,4 @@ Real ML-DSA-65 + ML-KEM-768 live in `pq/pq.mjs` (noble primitives). The account,
87
134
  - Superchain token list: https://github.com/ethereum-optimism/ethereum-optimism.github.io/pull/1394
88
135
  - Verification post: https://github.com/yss787976-ai/agent-coin/issues/1
89
136
  - X post: https://x.com/yss6060/status/2120901091282014578
90
- - Announcement release: https://github.com/yss787976-ai/agent-coin/releases/tag/v1.0.0
137
+ - Announcement release: https://github.com/yss787976-ai/agent-coin/releases/tag/v1.0.0
package/WHITEPAPER.md CHANGED
@@ -24,6 +24,7 @@
24
24
  - `collateralRatio()` يفضح النسبة علنًا. المعروض المتداول = الدولارات المودعة دائمًا، ومستحيل أن يتجاوزه.
25
25
  - النتيجة: لا انحراف، لا depeg، لا بنك مركزي، لا وعد — حساب.
26
26
  - السقف 900 مليار وحدة: سقف أصلي ثابت في الشيفرة، يكفي كل وكيل في العالم أن يعمل قرنًا. لا إصدار إضافي بعد بلوغ السقف، والإصدار الوحيد الممكن هو مقابل دولار محجوز.
27
+ - حصة المبتكر خارج التداول. لا تُحوَّل عملات منها مباشرة إلى pool أو وكيل إلا عبر `GenesisSale` (دولار واحد مقابل عملة واحدة)؛ التحويل المباشر يخلق معروضًا متداولًا بلا ضمان ويكسر `collateralRatio()`. الفحص التشغيلي: `vaultUSDC == totalSupply − founderBalance − saleBalance`.
27
28
 
28
29
  ## 3) سرعة ورخص
29
30
 
@@ -32,7 +33,7 @@ Base L2: كتلة ~2 ثانية، رسوم تُقاس بالسنتات، ورا
32
33
  ## 4) ما بعد الكم
33
34
 
34
35
  - سلطة الحساب = تعهد مفتاح ML-DSA-65. لا يوجد ECDSA وحده كسلطة.
35
- - توقيعات ML-DSA-65 تُتحقق على السلسلة عبر `MLDSAVerifier` بمسار precompile، مع مكتب تحقق صلبٍ كبديل وخفض تلقائي إلى ECDSA إن تعذر.
36
+ - توقيعات ML-DSA-65 حقيقية ومُختبرة (FIPS 204). التحقق على السلسلة يعمل الآن عبر `MLDSAVerifier` → `MLDSA65Fallback` → skalenetwork/mldsa-solidity: المصنع `0x9961…e197` والمُحقّق `0xa11e…0b30` والمحوّل `0xeEbc…506B`. أول تنفيذ `0x02` على Base نجح بتكلفة 3,966,579 gas. المكتبة الخارجية غير مدقّقة؛ AQB يفحص تعهد المفتاح والأطوال أولًا، ويبقى `0x01` مسارًا احتياطيًا.
36
37
  - التنفيذ المرجعي للعملاء في `pq/pq.mjs`: توليد مفاتيح ML-DSA-65 (1952 بايت)، تواقيع (3309 بايت)، وML-KEM-768 لعناوين التخفي — مع 10 اختبارات كريبتو و20 اختبار عقد تمر كلها.
37
38
  - دوران المفاتيح مدعوم (`rotatePQKey`) عبر الحساب نفسه فقط.
38
39
  - ML-KEM يُستخدم لتغليف المفتاح في عنوان التخفي، والتشفير من وكيل لوكيل مستقل عن العقد.
@@ -0,0 +1,59 @@
1
+ {
2
+ "file": "contracts/MLDSA65Fallback.sol",
3
+ "abi": [
4
+ {
5
+ "inputs": [
6
+ {
7
+ "internalType": "address",
8
+ "name": "verifier_",
9
+ "type": "address"
10
+ }
11
+ ],
12
+ "stateMutability": "nonpayable",
13
+ "type": "constructor"
14
+ },
15
+ {
16
+ "inputs": [],
17
+ "name": "verifier",
18
+ "outputs": [
19
+ {
20
+ "internalType": "address",
21
+ "name": "",
22
+ "type": "address"
23
+ }
24
+ ],
25
+ "stateMutability": "view",
26
+ "type": "function"
27
+ },
28
+ {
29
+ "inputs": [
30
+ {
31
+ "internalType": "bytes",
32
+ "name": "publicKey",
33
+ "type": "bytes"
34
+ },
35
+ {
36
+ "internalType": "bytes32",
37
+ "name": "digest",
38
+ "type": "bytes32"
39
+ },
40
+ {
41
+ "internalType": "bytes",
42
+ "name": "signature",
43
+ "type": "bytes"
44
+ }
45
+ ],
46
+ "name": "verifyMLDSA65",
47
+ "outputs": [
48
+ {
49
+ "internalType": "uint256",
50
+ "name": "",
51
+ "type": "uint256"
52
+ }
53
+ ],
54
+ "stateMutability": "view",
55
+ "type": "function"
56
+ }
57
+ ],
58
+ "bytecode": "0x60a060405234801561000f575f80fd5b5060405161043838038061043883398101604081905261002e9161003f565b6001600160a01b031660805261006c565b5f6020828403121561004f575f80fd5b81516001600160a01b0381168114610065575f80fd5b9392505050565b6080516103af6100895f395f8181603d015260a201526103af5ff3fe608060405234801561000f575f80fd5b5060043610610034575f3560e01c80632b7ac3f31461003857806373f89b6c1461007c575b5f80fd5b61005f7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b61008f61008a366004610211565b61009d565b604051908152602001610073565b5f805f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031660018989896040516020016100e191815260200190565b60408051601f1981840301815290829052610105949392918b908b906024016102cf565b60408051601f198184030181529181526020820180516001600160e01b0316632f0853a360e01b1790525161013a9190610338565b5f60405180830381855afa9150503d805f8114610172576040519150601f19603f3d011682016040523d82523d5f602084013e610177565b606091505b509150915081158061018b57508051602014155b1561019a575f925050506101c3565b808060200190518101906101ae9190610353565b6101b8575f6101bb565b60015b60ff16925050505b95945050505050565b5f8083601f8401126101dc575f80fd5b50813567ffffffffffffffff8111156101f3575f80fd5b60208301915083602082850101111561020a575f80fd5b9250929050565b5f805f805f60608688031215610225575f80fd5b853567ffffffffffffffff8082111561023c575f80fd5b61024889838a016101cc565b9097509550602088013594506040880135915080821115610267575f80fd5b50610274888289016101cc565b969995985093965092949392505050565b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b5f5b838110156102c75781810151838201526020016102af565b50505f910152565b60ff87168152608060208201525f6102eb608083018789610285565b82810360408401528551808252610309816020840160208a016102ad565b601f01601f1916018281036020908101606085015261032b9082018587610285565b9998505050505050505050565b5f82516103498184602087016102ad565b9190910192915050565b5f60208284031215610363575f80fd5b81518015158114610372575f80fd5b939250505056fea26469706673582212207deaa767bb2c453627e654647fde8afb76ffcdf1f44f8dd9b3e284fe89f9da7664736f6c63430008180033"
59
+ }