@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.
- package/LICENSE +4 -16
- package/README.md +68 -21
- package/WHITEPAPER.md +2 -1
- package/artifacts/MLDSA65Fallback.json +59 -0
- package/client/aqb.mjs +232 -148
- package/compile.mjs +44 -0
- package/contracts/AgentQuantumCredit.sol +234 -0
- package/contracts/AgentRegistry.sol +85 -0
- package/contracts/GenesisSale.sol +89 -0
- package/contracts/MLDSA65Fallback.sol +34 -0
- package/contracts/MLDSAVerifier.sol +65 -0
- package/contracts/PQSmartAccount.sol +105 -0
- package/contracts/interfaces/IPQVerifier.sol +19 -0
- package/contracts/mocks/MockUSDC.sol +30 -0
- package/contracts/mocks/MockVerifier.sol +13 -0
- package/docs/CARD.md +1 -1
- package/docs/LAUNCH.md +1 -1
- package/docs/MARKETING.md +3 -3
- package/docs/SPEC.md +5 -4
- package/docs/articles/01-payment-rail-agents.md +55 -0
- package/docs/articles/01.body +56 -0
- package/docs/articles/02-gated-transfers.md +36 -0
- package/docs/articles/03-peg-without-oracle.md +33 -0
- package/docs/articles/04-discovery-over-landing.md +42 -0
- package/docs/articles/04-discovery-over-landing.md.body +40 -0
- package/docs/articles/04-discovery-over-landing.md.title +1 -0
- package/docs/articles/05-identity-survives-key.md +27 -0
- package/docs/articles/05-identity-survives-key.md.body +25 -0
- package/docs/articles/05-identity-survives-key.md.title +1 -0
- package/docs/articles/06-what-an-agent-needs.md +30 -0
- package/docs/articles/06-what-an-agent-needs.md.body +28 -0
- package/docs/articles/06-what-an-agent-needs.md.title +1 -0
- package/docs/articles/body.json +1 -0
- package/docs/articles/body.txt +50 -0
- package/docs/articles/title.txt +1 -0
- package/docs/pq-note.md +1 -0
- package/index.js +241 -0
- package/mcp/server.mjs +118 -25
- package/package.json +41 -11
- package/pq-deployment.json +14 -0
- package/registry/agent-coin.json +26 -11
- package/registry/llms.txt +1 -1
- package/test/e2e.mjs +100 -0
- package/test/evm.mjs +69 -0
- package/test/local.mjs +86 -0
- package/test/pq.mjs +37 -0
- package/test/smoke.mjs +27 -0
- package/vendor/mldsa/LICENSE +21 -0
- package/vendor/mldsa/MLDSAKeyFactory.json +570 -0
- package/vendor/mldsa/MLDSAVerifier.json +154 -0
- package/vendor/mldsa/README.md +20 -0
package/test/pq.mjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Real post-quantum crypto test: identity, digest signing, stealth KEM round trip.
|
|
2
|
+
import { newIdentity, signDigest, verifyDigest, newKemIdentity, stealthFor, stealthCheck, PK_LEN, SIG_LEN } from "../pq/pq.mjs";
|
|
3
|
+
import { stealth as clientStealth, cardHash } from "../client/aqb.mjs";
|
|
4
|
+
import { keccak256, toUtf8Bytes } from "ethers";
|
|
5
|
+
const hex = (b) => (b ? Buffer.from(b).toString("hex") : null);
|
|
6
|
+
|
|
7
|
+
let fails = 0;
|
|
8
|
+
const ok = (c, m) => { console.log((c ? "PASS " : "FAIL ") + m); if (!c) fails++; };
|
|
9
|
+
|
|
10
|
+
const id = newIdentity();
|
|
11
|
+
ok(id.publicKey.length === PK_LEN, `ML-DSA-65 pubkey is ${PK_LEN} bytes`);
|
|
12
|
+
ok(id.keyHash === keccak256(id.publicKey), "keyHash commits the pubkey");
|
|
13
|
+
|
|
14
|
+
const digest = keccak256(toUtf8Bytes("aqb-execute"));
|
|
15
|
+
const blob = signDigest(id, digest);
|
|
16
|
+
ok((blob.length - 2) / 2 === SIG_LEN + 1, "sig blob = scheme tag + 3309 bytes");
|
|
17
|
+
ok(verifyDigest(id.publicKey, digest, blob), "real ML-DSA-65 signature verifies");
|
|
18
|
+
ok(!verifyDigest(id.publicKey, keccak256(toUtf8Bytes("other")), blob), "wrong digest rejected");
|
|
19
|
+
const impostor = newIdentity();
|
|
20
|
+
ok(!verifyDigest(impostor.publicKey, digest, blob), "wrong key rejected");
|
|
21
|
+
|
|
22
|
+
const kem = newKemIdentity();
|
|
23
|
+
const s = stealthFor(kem.publicKey);
|
|
24
|
+
ok(s.addr.length === 42, "stealth address derived");
|
|
25
|
+
ok(hex(stealthCheck(kem, s.ephPubKey, s.viewTag, s.addr)) === hex(s.sharedSecret), "recipient decapsulates to same secret");
|
|
26
|
+
ok(stealthCheck(newKemIdentity(), s.ephPubKey, s.viewTag, s.addr) === null, "stranger cannot claim stealth");
|
|
27
|
+
ok(stealthCheck(kem, s.ephPubKey, "0x00", s.addr) === null, "view-tag mismatch filters announcement");
|
|
28
|
+
const cs = clientStealth(s.ephPubKey, s.sharedSecret);
|
|
29
|
+
ok(cs.addr === s.addr && cs.viewTag === s.viewTag, "client stealth matches pq.stealthFor");
|
|
30
|
+
|
|
31
|
+
const card = { aqb: 1, name: "x", price: { unit: "AQB", amount: "2" }, tags: ["a", "b"] };
|
|
32
|
+
const reordered = { tags: ["a", "b"], price: { amount: "2", unit: "AQB" }, name: "x", aqb: 1 };
|
|
33
|
+
ok(cardHash(card) === cardHash(reordered), "cardHash is recursive key-order independent");
|
|
34
|
+
ok(cardHash(card) !== keccak256(toUtf8Bytes(JSON.stringify(card, Object.keys(card).sort()))), "cardHash keeps nested keys");
|
|
35
|
+
|
|
36
|
+
console.log(fails ? `PQ FAILED (${fails})` : "PQ OK");
|
|
37
|
+
process.exit(fails ? 1 : 0);
|
package/test/smoke.mjs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Post-deploy invariant test. Run after deploy.mjs: node test/smoke.mjs
|
|
2
|
+
import { JsonRpcProvider, Wallet, Contract } from "ethers";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
|
|
5
|
+
const d = JSON.parse(fs.readFileSync("deployment.json", "utf8"));
|
|
6
|
+
const p = new JsonRpcProvider(process.env.RPC_URL);
|
|
7
|
+
const w = new Wallet(process.env.PRIVATE_KEY, p);
|
|
8
|
+
const t = new Contract(d.token, [
|
|
9
|
+
"function mint(uint256)", "function redeem(uint256)", "function totalSupply() view returns(uint256)",
|
|
10
|
+
"function collateralRatio() view returns(uint256)", "function MAX_SUPPLY() view returns(uint256)",
|
|
11
|
+
"function balanceOf(address) view returns(uint256)", "function setPool(address,bool)",
|
|
12
|
+
], w);
|
|
13
|
+
const r = new Contract(d.registry, ["function isAgent(address) view returns(bool)"], w);
|
|
14
|
+
const usdc = new Contract(d.usdc, ["function balanceOf(address) view returns(uint256)"], w);
|
|
15
|
+
|
|
16
|
+
const ok = (c, m) => { console.log((c ? "PASS " : "FAIL ") + m); if (!c) process.exitCode = 1; };
|
|
17
|
+
|
|
18
|
+
ok((await r.isAgent(w.address)) === true, "deployer is agent");
|
|
19
|
+
await (await t.mint(10_000_000n)).wait(); // 10 USDC
|
|
20
|
+
ok((await t.collateralRatio()) === 10n ** 18n, "ratio == 1e18 after mint");
|
|
21
|
+
await (await t.redeem(5n * 10n ** 18n)).wait();
|
|
22
|
+
ok((await t.collateralRatio()) === 10n ** 18n, "ratio == 1e18 after redeem");
|
|
23
|
+
ok((await t.totalSupply()) === 5n * 10n ** 18n, "supply == 5 AQB");
|
|
24
|
+
ok((await usdc.balanceOf(d.token)) === 5_000_000n, "usdc reserves == 5");
|
|
25
|
+
try { await (await t.mint(0n)).wait(); ok(false, "mint(0) reverts"); } catch { ok(true, "mint(0) reverts"); }
|
|
26
|
+
ok((await t.MAX_SUPPLY()) === 900_000_000_000n * 10n ** 18n, "cap == 900e9");
|
|
27
|
+
console.log(process.exitCode ? "SMOKE FAILED" : "SMOKE OK");
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SKALE Labs
|
|
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:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
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.
|