Skip to content
steven3002Public

About

Quantum-safe proof of who owns a QoreChain address, and pay links nobody can forge: ML-DSA-87 identity claims and pay requests verified on chain, plus a look-alike address guard against address poisoning.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

43 Commits

Folders and files

Repository files navigation

Cartouche

Prove who owns a QoreChain address with quantum-safe signatures, and share pay links nobody can forge.

Status: built for the QoreChain Build Before Q-Day fest, on QoreChain testnet (qorechain-diana, EVM chain id 9800). The contracts are deployed on testnet (addresses below), and the web app and their tests are done. The public link is added here once the app is hosted.

Why

People lose money by paying the wrong address.

  • Address poisoning is large-scale. A Carnegie Mellon CyLab study counted about 270 million attack attempts against 17 million victims on Ethereum and BNB Chain, with at least $83.8 million lost between July 2022 and June 2024, and its tool later caught a single $50 million attack (CyLab, USENIX Security 2025 paper).
  • It works because wallets shorten addresses. Attackers make look-alike addresses that share the first and last characters of a real one, and popular wallets show only a few characters at each end (same paper).
  • Pay links are signed with classical keys. QoreX pay links are signed with secp256k1 only, and a page can't verify them itself (qorex-integrations #1). Once classical keys can be broken, such proofs could be forged.

What it does

  • Claim an identity. Link your address to a GitHub account or a domain. You sign a short statement with ML-DSA-87 in QoreX, publish the statement in a public gist or a DNS TXT record, and the contract verifies the signature and stores the claim.
  • Check anyone. Paste an address, a handle or a profile link. The app reads the on-chain claims and re-checks each proof live, then shows “Quantum-safe verified” or a plain reason why not: proof removed, claim revoked or expired, or the key changed.
  • Create a pay request. Sign the amount, a note and an expiry with ML-DSA-87; the request is stored on chain, and the link or QR code holds only its number, so it can't be edited.
  • Pay a request. The app loads the terms from chain, shows the payee's verified identity, and pays with a native QOR transfer that carries the request number in its memo.
  • Look-alike guard. Every address is shown in full. Before paying, the app compares the address with ones you have paid or verified before, and blocks a near-match until you confirm every character.

How it works

Post-quantum design

  • QoreX signs qorechain-msg-v1|qorechain-diana|<text> with ML-DSA-87 (QoreX dApp integration).
  • The contracts rebuild exactly that text and check the signature with QoreChain's pqcVerify precompile, against the key that the pqcKeyStatus precompile reports for the signer. Keys without proof of possession are refused, and an unavailable precompile fails closed.
  • ML-DSA-87 signatures are 4,627 bytes, too big for DNS records and QR codes, so they are verified and stored on chain. GitHub and DNS carry only the short statement.
  • Every signed text names the app, the chain, the contract, a nonce and an expiry, so a signature can't be replayed elsewhere.
  • Claims record a hash of the signer's key. If the owner rotates keys, old claims show “re-sign needed”.

Architecture

Part What it is
apps/contracts Hardhat 3 project from the create-qorechain-dapp hardhat template: CartoucheRegistry (identity claims) and PayRequests (signed pay requests).
apps/web React app from the create-qorechain-dapp viem-wagmi template: claim, profile, check, create-request and pay pages. QoreX connects as an injected wallet.
Proof checks In the browser: gists through the GitHub API, and TXT records through DNS-over-HTTPS.
Backend None. The chain is the source of truth.

How it's made

The two apps come from QoreChain's official scaffolder, create-qorechain-dapp 0.14.0, each in its own folder with the template's structure kept. They were created from apps/ with:

npx create-qorechain-dapp@0.14.0 contracts --template hardhat --network testnet --package-manager pnpm --yes --no-install
npx create-qorechain-dapp@0.14.0 web --template viem-wagmi --network testnet --package-manager pnpm --yes --no-install
Folder Template What we added
apps/contracts hardhat (Hardhat 3, viem, Ignition, the window helper) contracts/claims/CartoucheRegistry.sol, contracts/payments/PayRequests.sol, their tests, ignition/modules/Cartouche.ts, scripts/checkPrecompiles.ts, scripts/exportAbi.ts
apps/web viem-wagmi (Vite, React, wagmi, RainbowKit, QoreX) the pages in src/features/, the app shell in src/app/, src/ui/, src/chain/, unit tests in test/

--no-install lets the repository root install both apps once, as a pnpm workspace with one lockfile.

Contracts

  • CartoucheRegistry: publishClaim(platform, handle, nonce, expiry, signature) rebuilds the claim text from its inputs and the caller, then checks the caller's ML-DSA-87 signature with PQApproval from our Bowline library: the key comes from the pqcKeyStatus precompile and must be registered and possession-proven, and pqcVerify must return true. An inactive precompile (empty answer) is a refusal. The claim stores keccak256 of the key, so a later key rotation shows as “re-sign needed”. revokeClaim(id) is for the owner only. Reads: getClaim, claimIdsOf, claimIdsOfHandle, claimsOf (active claims) and claimText.
  • PayRequests: createRequest(amountUqor, note, expiry, nonce, signature) hashes the note itself, so the stored note always matches the signed one, and checks the payee's signature the same way. Reads: requestOf, requestIdsOf, requestText.
  • The signed texts are cartouche-v1|claim|9800|<registry>|<github or domain>|<handle>|<owner>|<nonce>|<expiry> and cartouche-v1|pay|9800|<payrequests>|<payee>|<amountUqor>|<noteHash>|<nonce>|<expiry>. QoreX signs qorechain-msg-v1|qorechain-diana|<text>; the contracts rebuild exactly that. Both apps are tested against the same vectors (apps/contracts/test/vectors/texts.json).
  • The ABIs (and, once deployed, the addresses) are written to apps/web/src/chain/generated/contracts.ts by pnpm --filter contracts export:abi.

Web app

  • Home (/): what Cartouche does, a lookup field, a live verified profile, the look-alike problem on labelled demo addresses, and three things to try without a wallet.
  • Look-alike demo (/demo): the real look-alike guard, fed a verified testnet address and a generated copy of its first 3 and last 4 characters. Nothing is sent.
  • Claim (/claim): four steps (connect, sign, publish the proof, record on chain); the flow survives a page refresh. Sign the claim in QoreX, publish the text in a public gist or a _cartouche.<domain> TXT record (value cartouche-v1 <address> <nonce>), let the app check it, then send publishClaim.
  • Check (/check) and profile (/@handle): every claim is read from chain and its proof is looked up again (GitHub API and gist files; Cloudflare, then Google DNS-over-HTTPS). “Quantum-safe verified” appears only when the claim is active, signed with the owner's current key and its proof was found just now. GitHub answers are cached for 10 minutes.
  • Request payment (/request): sign an amount, note and expiry; share /pay/<id> or its QR code.
  • Pay (/pay/<id>): terms from chain, the payee's claims, the look-alike guard, then a native QOR transfer through QoreX signAndBroadcast with the memo cartouche:pay:<PayRequests address>:<id>, which ties the payment to one request of one contract. QoreX signs it with both its classical and its ML-DSA-87 key. Paid status reads the payee's transfers from QoreChain REST, from the block the request was created in, page by page, and counts only successful transfers that carry the request's memo and cover the amount; if it cannot read every transfer it says so instead of calling the request unpaid.
  • Look-alike guard: an address that shares the first 3 and last 4 of its 40 hex characters with an address you paid or saw verified, but is different, is blocked until you tick that you checked every character. Addresses are always shown in full, in both their 0x and qor1 forms.

Run it locally

Requirements: Node.js 22, pnpm 11, and Bowline checked out as a folder named pq-kit two levels above this repository's root (see “Known limits”).

pnpm install
pnpm test                    # contracts (Hardhat, simulated network) and web (Vitest)
pnpm build                   # contracts build and web production build
pnpm --filter web dev        # http://localhost:5173

Use QoreX on Testnet. Before the first signature, the account needs a registered post-quantum key: send one transaction from QoreX.

Deploy the contracts yourself

cd apps/contracts
cp .env.example .env         # set QORE_MNEMONIC and the matching PRIVATE_KEY of a funded testnet account
pnpm window register         # once: registers the account's ML-DSA-87 key
pnpm window open             # opens an EVM window (do this before any window limited to contracts)
pnpm deploy                  # Ignition: ignition/modules/Cartouche.ts on qorechainTestnet
pnpm check:precompiles 0xYourAddress
pnpm export:abi              # writes the ABIs and addresses into apps/web

Deploy the web app on Vercel

Import the repository in Vercel with Root Directory apps/web with the Vite framework preset, build command pnpm build and output directory dist. apps/web/vercel.json rewrites every path to index.html, so links such as /@alice and /pay/7 open directly.

Testnet deployment

Contract 0x address qor1 address
CartoucheRegistry 0xFF3a4c058E3358ACF9103F1a418A76cCD97a3CAc qor1luaycpvwxdv2e7gs8udyrznkenvh509vkz85wt
PayRequests 0xfb08182bAc1288773Fb7deAd62Df0Ce389244aa4 qor1lvyps2avz2y8w0ahm6kk9hcvuwyjgj4ymk3uq4

Deployed on 1 December 2026 with Hardhat Ignition (record in apps/contracts/ignition/deployments/chain-9800/): CartoucheRegistry in transaction 0x3f9c0e7e1bcafc1e009cc6d523b268607e64392826429083ff38d24e50427350 (block 11,064,906) and PayRequests in 0x0cfd135ffc62c3c160dd82a64355b50cedf4dd12d0f493e1b498ddc0457e5ee0 (block 11,064,907).

A first run with test accounts driven from Node (not QoreX), each signing with its own ML-DSA-87 key:

Step Transaction Gas used
Claim 1: GitHub steven3002, checked by pqcVerify on chain 0x18a059327a2623a1d2125572496f657ac4f8ccacfca6dbe12c7e48f9fc3d5772 502,569
Claim 2: a domain claim, then revoked 0x25d8b3869c69c75de38627bbc00a7f860373ec0b33124341c85e6da79977346a, revoked in 0xc8fd2b5adb337bddd8025ae208eb8fd3f1eb9e4724f1869d1c2ec826ec1afbcb 468,367 and 30,027
Pay request 1: 0.25 QOR 0x6d51bbcc8b4ce35f277cde35d7b62de6e76a1e2ae808450eb2e61ace0a2a7627 565,228
Its payment: native transfer with memo cartouche:pay:1 (the first memo format), hybrid-signed (PQCHybridSignature, ML-DSA-87) 701F18C869BA869AEBF3332FA6C33ACAB8D6618FB8947BCBF4B883D846A3BB4A

The explorer is https://explore.qore.network (switch it to Testnet).

Tests

  • apps/contracts: 25 tests on Hardhat's simulated network with Bowline's precompile test doubles: valid claims and requests, signatures from the wrong account or for another contract, replayed nonces, expiry, handle and note limits, revocation, keys without proof of possession, and inactive precompiles.
  • apps/web: 127 Vitest tests: the signed texts against the shared vectors, gist and DNS parsing against answers saved from GitHub, Cloudflare and Google, claim states, the cache, every refusal message, the look-alike rule and its group-by-group comparison, the history, paid status against a saved QoreChain REST answer, the five checks shown on each claim, the page notice rule and the saved claim flow.

Known limits

  • Testnet only. QoreChain's PQC precompiles are active on testnet; on mainnet they need a chain upgrade and a governance vote.
  • QoreX accounts. QoreX signs EVM transactions (publishing a claim, creating a request) only from accounts imported from MetaMask (coin type 60). Payments use the native lane and work from any QoreX account.
  • GitHub limits. Without a token, GitHub allows 60 API requests an hour per IP address. The app caches each check for 10 minutes and reads gist files from gist.githubusercontent.com, which does not use that quota.
  • Gists are found by handle. A claim records the GitHub username, not the gist, so the check page looks through the user's latest 100 public gists and reads files up to 4,096 bytes.
  • Paid status reads every transfer to the payee since the request was created, up to 2,000; a busier payee is reported as unchecked. Requests 1 and 2 were paid with the first memo format (cartouche:pay:<id>), which is accepted only for those two requests of the first deployment.
  • A handle with several owners. When a GitHub username or domain has live proofs for two or more addresses, no address is shown as verified and the pages say so.
  • Anyone can publish a claim naming any handle. Only a claim whose proof is live counts as verified.
  • Bowline by local path. Until Bowline's public tag exists, both apps depend on it with link:../../../../pq-kit, so a fresh clone installs only when Bowline is checked out at that path: for a clone at work/me/cartouche, Bowline goes in work/pq-kit. Without it, pnpm install succeeds but the tests stop with HHE901 (Hardhat cannot resolve bowline/contracts/...).

Design and credits

  • Fonts, self-hosted through Fontsource 5.3.0 (MIT packaging): Plus Jakarta Sans for the interface, Instrument Serif for headlines and Atkinson Hyperlegible Mono for addresses, amounts and signed text (it tells 0 from O and 1 from l). All three are under the SIL Open Font License 1.1.
  • Icons: Lucide (lucide-react 1.84.0, ISC; icons derived from Feather are MIT).
  • Styling: Tailwind CSS 3.4.19 with PostCSS and Autoprefixer (all MIT). Version 3 because version 4 needs Safari 16.4, and the QoreX app supports iOS from 15.1.
  • Visual style inspired by designs on Dribbble.

Colours, type sizes and every text and control colour pair meet WCAG 2.2 AA contrast; status is always shown with an icon and words, never colour alone.

Credits

  • create-qorechain-dapp 0.14.0 (Apache-2.0): the hardhat and viem-wagmi templates.
  • QoreChain: @qorechain/evm and @qorechain/sdk 0.14.0, @qorechain/qorex-rainbowkit 0.1.0 (Apache-2.0); the QoreX wallet; the pqcVerify and pqcKeyStatus precompiles.
  • Bowline, our own open-source helper library for QoreChain post-quantum approvals (MIT): PQApproval, PQText, approvalText, signText, sendNative, keyStatus and the test doubles. It uses OpenZeppelin Contracts Strings (MIT), @qorechain/pqc 0.2.3 and @qorechain/qoresign 0.2.0 (Apache-2.0).
  • Web: React 18.3.1, React Router (react-router-dom 7.18.7), wagmi 2.19.5, viem 2.53.1, RainbowKit 2.2.11, TanStack Query 5, qrcode 1.5.4, Vite 5 (all MIT).
  • Contracts and tooling: Hardhat 3.23.0 with the viem toolbox and Ignition (MIT), @cosmjs/stargate 0.39.0 (Apache-2.0), TypeScript 5.9.3 (Apache-2.0), tsx and Vitest 3.2.7 (MIT).
  • Research: the look-alike rule and its mitigations come from Tsuchiya and Christin, “Blockchain Address Poisoning”, USENIX Security 2025.

ke guard

  • Public deployment and demo video

License

MIT. See LICENSE.

About

Quantum-safe proof of who owns a QoreChain address, and pay links nobody can forge: ML-DSA-87 identity claims and pay requests verified on chain, plus a look-alike address guard against address poisoning.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages