About
Files shared over the internet are stored in plain text, authenticated
with classical ECDSA keys that a quantum computer will forge. A person who
records your traffic today can read your files and forge your signatures
after Q-Day.
Folio addresses both. Files are encrypted in the seller's browser before
they are uploaded: the file is split into 1 MiB chunks and each is sealed
with AES-256-GCM under a fresh key. Only ciphertext ever reaches storage.
When someone buys a file, its key is sealed to the buyer with ML-KEM-1024
+ X25519 (QoreSeal). Their browser opens it, checks every chunk against a
SHA3-256 commitment and the content root the seller signed, and decrypts
the file. Nothing leaves their browser.
The payment waits in an escrow contract (FolioMarket, Solidity) on the
QoreChain testnet. If the key is not delivered within the listing's
window, anyone can trigger a refund. No operator holds the funds, and the
contract has no admin, no pause switch and no upgrade path.
Every listing, purchase, delivery, dispute and share carries a 4,627-byte
ML-DSA-87 (FIPS 204) signature verified on chain by the pqcVerify
precompile.
Before sealing to a buyer, the sender reads that buyer's ML-KEM-1024 key
from the on-chain KEM registry and checks it against their signed
recipient card. A swapped or copied key is refused before a single byte is
encrypted.
Sellers can also send files to up to 32 QoreX accounts without payment.
Each envelope is sealed to that account's registered on-chain key and can
only be opened in the recipient's browser.
How it's made
Architecture: four packages in a pnpm monorepo.
contracts/ — FolioMarket.sol (Solidity 0.8.28, Hardhat 3, viem). The
contract stores listings (price, delivery window, dispute window, arbiter,
content root, key commitment, metadata hash), escrows payments, verifies
ML-DSA-87 signatures with pqcVerify (0x...0a01) and pqcKeyStatus
(0x...0a02), and enforces the full escrow state machine: Paid → Delivered
→ Released / Refunded / Disputed → Resolved. HybridTx.sol (copied from the
same author's Purser project, MIT) parses the QoreChain native TxRaw and
rebuilds the ML-DSA-87 sign bytes and tx hash, so the contract can verify
that an account-link transaction was really signed by the owner. 132 tests
with real ML-DSA-87 signatures. Deployed in block 11,153,811, tx
0x1976d1b8.
core/ — @folio/core, an isomorphic TypeScript library (browser + Node
20+). QoreSeal file encryption: 1 MiB chunks through sealBatch
(AES-256-GCM, SHA3-256 commitments), sealed manifest (private file name
and chunk index), content root and key commitment. Licence sealing:
QoreSeal seal() with aad binding each envelope to its purchase id, listing
id and version. Recipient cards: signRecipientCard / verifyRecipientCard
against both registered keys on chain. ML-KEM-1024 key registration
(msg.pqc.registerKemKey from @qorechain/sdk, hybrid-signed). Signed intent
strings for all 13 contract functions. Market reads (viem getLogs,
paginated, in-memory cache) and writes. 74 unit tests plus a 7-step live
testnet suite.
web/ — Vite + React 18. Pure black and white design. All crypto in a Web
Worker via Comlink; keys never enter the page. PDF/image/audio/video/text
viewers (pdfjs-dist with a local worker). QoreX wallet connection adapted
from the author's Purser project. Data hooks layer (TanStack Query) wired
to the live FolioMarket contract on testnet. Strict CSP (no inline
scripts, no third-party scripts), self-hosted fonts. Deployed to Vercel.
bot/ — delivery bot (CLI + Vercel function). Watches FolioMarket for
Purchased events, reads the buyer's recipient card from storage, verifies
it against both registered keys on chain, opens the file key sealed to the
bot, seals the licence to the buyer with QoreSeal (aad = purchase id +
listing id + version), uploads it, and calls deliver().
What was hard:
- QoreX today does not expose signArbitrary to websites (the
profile=current mock returns "not yet supported"), so the owner's
wallet can only sign plain bank sends. The account-link flow uses a
hybrid-signed MsgSend with a memo, and the contract parses the full TxRaw (body,
authInfo, classical sig) to verify the ML-DSA-87 signature and extract
the memo.
- The chain's KEM registry (MsgRegisterKEMKey) requires a prior registered
ML-DSA-87 key and a hybrid-signed transaction. The feasibility spike
(scripts/spike.ts) proved the full path on the testnet before any code was
written.
- QoreSeal's buildRegisterKemKeyMessage returns a pre-encoded Any; the SDK
signer does not accept it. The correct call is msg.pqc.registerKemKey from
@qorechain/sdk, found by reading the SDK's index.d.ts directly.
- The pnpm workspace monorepo deploy to Vercel: Vercel's build runs from
the project root, so the vercel.json at the repo root sets installCommand
to pnpm install (whole workspace) and buildCommand to pnpm --filter
@folio/web run build, with outputDirectory web/dist.