Skip to content
QORECHAIN
Register

Encrypted Apps

Tirai

Smart meter readings sealed in your browser so only your utility can open them.

Share on X

About

A smart meter reports how much power a home used every half hour. That curve shows when a home is empty, when people sleep and when they cook. Researchers showed this in 2010 with off-the-shelf statistics on plain meter data (Molina-Markham et al., "Private memoirs of a smart meter", BuildSys '10). Meter data travels through networks and sits in systems for years, which is where "harvest now, decrypt later" matters. Tirai keeps the meter honest and the readings private. The utility registers an ML-KEM-1024 encryption key on QoreChain and binds it to its ML-DSA-87 identity with a signed recipient card. The meter seals each day of readings in the browser to the utility's address, after checking the card against the keys on chain, and signs the sealed bytes with its own ML-DSA-87 key. The chain keeps only the hash, after the pqcVerify precompile accepts the meter's signature. The utility console decrypts in the browser and checks the hash on chain and the meter's signature. The household can let an energy auditor read one day for an hour: the browser re-seals it to the auditor's registered key, and the household's consent, signed with ML-DSA-87, lands on chain. It can withdraw that consent. Try it without a wallet at tirai.sasateguh.com. Five steps, each a real testnet transaction paid by a relay that never sees a reading: install a meter, seal yesterday, open it as the utility (and change one bit to see it refused), look at it as a snoop whose own key cannot open it, then grant the auditor one hour, open it as the auditor and withdraw the consent. You can also press "Make the relay lie": the relay serves the utility's card with its own X25519 key swapped in, and the browser refuses to seal (CARD_INVALID), because it checks the card against the utility's signing keys on chain and reads the ML-KEM-1024 key from the chain itself. And "Break X25519 (quantum attacker)" tries to open your day with the utility's real X25519 secret but not its ML-KEM-1024 secret: it stays closed. The live contract is under constant attack. pnpm hostile turns every write TiraiLedger has accepted into forgeries: replays, signatures with one bit flipped, real signatures moved to another day or meter, 65-byte classical signatures where ML-DSA-87 is required, strangers' household keys, auditors with no post-quantum key, days in the future and consents beyond the 30-day limit. Each is simulated with eth_call against the live contract (no key, nothing broadcast) and must be refused for the reason the threat model expects. 1,040 hostile calls, 0 accepted; real transactions re-simulated at the block before they landed are accepted, so the ML-DSA-87 check really runs. GitHub Actions runs 60 more every hour until 16 December and fails if one gets through. Limits: the demo publishes the utility's and the auditor's decryption seeds so you can play those roles; their account keys stay private. Readings are simulated in the browser. Once an auditor has opened a day, the chain cannot take that back. The relay can refuse to relay but cannot read, change or forge a reading. I'm a solo builder in Malaysia. I built Tirai with AI coding agents, and AI_USAGE.md says how.

How it's made

TiraiLedger is one Solidity contract, built and tested with Foundry, deployed on diana at 0xf0bf5d45a474db5ac80eece7cfb154e5d24d90b9. It has no owner, no upgrade and no payable function. enrol checks the utility's ML-DSA-87 signature with pqcKeyStatus and pqcVerify; commit checks the meter's signature over the envelope hash with pqcVerify and only lets days move forward; grant and revoke check the household's signature, a per-meter counter and that the auditor has a possession-proven ML-DSA-87 key. Every signed message carries a domain tag, the chain id and the contract address. Keys: the utility and the auditor each registered an ML-DSA-87 key with proof of possession, then an ML-KEM-1024 key with MsgRegisterKEMKey, and signed a QoreSeal recipient card. The browser seals with sealToAddresses from @qorechain/qoreseal (ML-KEM-1024 + X25519), signs with @qorechain/qoresign, and reads the ledger straight from the public EVM RPC. The utility console and pnpm verify re-check every meter signature with @qorechain/pqc, a second ML-DSA-87 implementation. A small Node server relays the transactions from an EVM window scoped to TiraiLedger alone, checks every ML-DSA-87 signature before paying gas, and stores the envelopes, which anyone can check against the hashes on chain. It pauses itself with a clear message if its test QOR falls below a floor, so judges never meet a half-broken demo. pnpm verify re-checks the keys, cards, sealed days and grants from public endpoints with no key. Tests: 34 Foundry tests (31 unit, 3 fuzz) and 4 invariants (no forged reading accepted, day counts, last day, enrolments), 26 vitest tests, and a Playwright run that clicks the whole demo path with real testnet transactions in Chromium and in WebKit on an iPhone 13 profile. Against the live contract, pnpm hostile simulates 1,040 hostile calls in 20 classes with eth_call (evidence/adversarial-2026-12-02.json, 0 accepted), and an hourly workflow repeats 60 of them until the end of judging. CI runs gitleaks and lints the contract with Sisir. Credit: QoreChain workshop 3 (QoreSeal) and workshop 2 (pqcVerify), Apache-2.0. Pqc.sol, the test mocks and the deploy pattern come from my earlier entry Mentari.

Timeline

TiraiEncrypted Apps

Pushed 1 commit to main

  • 760b92c Hostile workflow: register the hourly schedule again after GitHub's Actions outage · aimanmalib
TiraiEncrypted Apps

Pushed 1 commit to main

  • 2ab9561 CI can be started by hand · aimanmalib
TiraiEncrypted Apps

Pushed 2 commits to main

  • 30b8247 Hostile campaign: forged, replayed and classical-only calls against the live ledger, simulated with eth_call; hourly workflow · aimanmalib
  • 8975c82 Evidence of 1,040 hostile calls, README EN/BM line and badge, site footer, judge pack (1.2.0) · aimanmalib
TiraiEncrypted Apps

Pushed 1 commit to main

  • 6a0f8f7 Explorer links open on the testnet (?network=testnet): site, footer, README proof table, judge pack (1.1.3) · aimanmalib
TiraiEncrypted Apps

Pushed 1 commit to main

  • e6c5699 Version 1.1.2 · aimanmalib
TiraiEncrypted Apps

Pushed 1 commit to main

  • abf84ef Back to 240 relayed transactions a day now the relay holds enough test QOR to the end of judging · aimanmalib
TiraiEncrypted Apps

Pushed 1 commit to main

  • 2f9e17a Relay budget to the end of judging: 40 relayed transactions a day, with a clear message when they are used up · aimanmalib
TiraiEncrypted Apps

Pushed 23 commits to main

  • 2b545b7 README: judges in 2 minutes, demo video and judge pack links at the top (1.1.1) · aimanmalib
  • 8dfb0e2 Version 1.1.0: changelog, AI usage after the review, film notes · aimanmalib
  • 6261490 Break X25519: a quantum attacker with the utility's X25519 key still cannot open a sealed day; narration transcript check · aimanmalib
  • 57908c9 Re-check meter signatures with @qorechain/pqc in the utility console and pnpm verify · aimanmalib
  • e94790c Relay lie: accurate wording, usable before a meter is installed; README section and screenshot · aimanmalib

and 18 more commits

TiraiEncrypted Apps

New project.

Comments and questions

  • No comments yet.