dtrh.net~/blog
KBS
│KBS all posts

Leverine Licensing Is Live: Licence Keys Signed for the Quantum Era

Leverine Licensing Is Live: Licence Keys Signed for the Quantum Era

Every indie developer eventually builds the same miserable thing: a licensing system. Usually it's a weekend project that grows teeth — a key generator nobody documented, a verification check that phones home to a server that died two laptops ago, a database of live keys sitting in a spreadsheet. I know because I've written that system more than once.

This time I built it once, properly, as a product. Leverine Licensing is live in production today at licence.leverine.com around 2am (go figure haha). And because a licence is a long-lived artifact, every single one is signed with a post-quantum signature.

A key built out of a lattice — which is more or less literally what signs these licences.

The keys: derived, not stored

A Leverine licence key looks like this in shape:

text1 line
LVN-XXXXX-XXXXX-XXXXX-XXXXX

The groups are Crockford base32, and the key is derived, not generated-and-filed: it's computed deterministically from the licence's ID using HMAC-SHA256 keyed by a server-side pepper, with a CRC check group on the end so a typo'd key fails fast before it ever hits the network.

That one design decision deletes a whole category of problems:

  • The database never holds live keys. It stores a lookup hash and the last four characters — enough to find a licence and enough for a human to confirm "yes, that's mine," and nothing worth stealing.
  • "I lost my key" is a solvable ticket. The full key is shown once at issuance, but because it's derived, it can be re-derived on proof of purchase. No key vault, no spreadsheet, no "sorry, it's gone forever."

The signatures: ML-DSA-65, on purpose

Here's the part I actually built this around. Licence tokens are signed with ML-DSA-65 — the lattice-based signature scheme standardized as FIPS 204, implemented via @noble/post-quantum.

The reasoning is simple. A licence issued today might need to verify in five or ten years, inside software that's still running on someone's machine. RSA and Ed25519 are excellent algorithms that a sufficiently capable quantum computer would break outright; lattice problems are the ones the standards bodies picked to survive that. Ed25519 was the original plan for this system. I dropped it deliberately. If you're minting artifacts meant to outlive your hardware refresh cycle, you sign them with the algorithm chosen for the world they'll be verified in.

Every token is an envelope that names its own cryptography, so keys and algorithms can rotate without a flag day:

json13 lines
{
  "alg": "ML-DSA-65",
  "kid": "2026-12-prod",
  "licence": {
    "id": "…",
    "product": "…",
    "tier": "…",
    "features": ["…"],
    "deviceCap": 3,
    "expiresAt": "…"
  },
  "signature": "…"
}

The production signing key (2026-12-prod) was generated in a small ceremony: the seed was captured into a 1Password vault, a full restore was tested from that backup before anything depended on it, and the working copies were destroyed. The only backup of the seed is that vault copy. Losing it would mean rotating to a new key ID and re-issuing — survivable by design, because kid is in every envelope.

How a sale becomes a licence

The pipeline is deliberately boring, which is what you want from something that touches money:

  1. Paddle sells. Paddle is the merchant of record — checkout, taxes, the works. Plans are Indie ($19/month), Studio ($49), and Publisher ($99), each monthly or annual, each with a 1-day free trial.
  2. A webhook fires. It's HMAC-verified with a timestamp tolerance window, and replays are no-ops — deliver the same event twice, get one licence.
  3. A licence is issued with a real term: rolling monthly renews a calendar month at a time, annual pays a year up front. Past-due subscriptions get a 7-day grace; cancellations shorten the term, never extend it.
  4. The customer's app activates against a hard device cap. Hit the cap and activation is refused — not flagged, not "we'll email you," refused.
  5. Verification happens offline. The app checks the token against the issuer's published public keys using the @leverine/licence-verify package. No phone-home, no account, no telemetry about end users — the issuer knows a licence has some number of active devices, and nothing about what those devices do.

Verification is a state, not a boolean

The verify library doesn't answer "valid: yes/no." It derives a state:

  • licensed — signature good, term current.
  • grace — payment failed, inside the 7-day window. Software keeps working; the human gets time to fix a card.
  • read-only — term over or grace exhausted. Data stays accessible; new work stops. This is the state that matters most to me: a lapsed licence should never hold someone's files hostage.
  • unlicensed — no valid token, bad signature, or revoked.

There's also a monotonic clock guard: the library remembers the latest timestamp it has seen, so rolling a device clock backwards doesn't resurrect an expired licence.

Already folding into real software

This isn't a landing page with a waitlist. The first integration is PVEZ-v2 — the shop software I built for Matt's PowerDesk business — running the verify library in dark mode right now: it activates, verifies, and reports its state, and enforces nothing yet while we watch it behave. That integration caught a real bug before any customer did: for a stretch, the development issuer was stamping the production key ID on tokens signed with the development key, and PVEZ's app derived unlicensed / bad signature while the server happily reported the licence active. The app believed the cryptography over the server's word. That's the system working exactly as designed — and it's why the first integration runs dark.

The full PVEZ run — purchase webhook to issued licence to activation to grace to revocation — is written up as a worked example in the docs. Matt's founding licence on the system is comped; dealers count, and he's dealer number one.

File Handler is the other planned home, with a deliberate boundary: the mobile app uses store in-app purchases, full stop — no downloadable code modules, no custom unlock, nothing that gets an app bounced from a store review. Licensing belongs to the future desktop and web tier, where real downloadable modules exist and this system is how they'll be sold. Hoistmark's billing was designed on top of the same engine. One issuer, several products, no per-app reinvention.

Read more

Onboarding is by conversation for now — I'd rather walk the first developers through it personally than hand out a self-serve form and a prayer. If you're an indie dev tired of maintaining your own key spreadsheet, you know where to find me.

normal~/dtrh.net│Leverine Licensing Is Live: Licence Keys Signed for the Quantum Era