Skip to content
QLab
On this page

Protocol specification, v1

This is the normative description of the QLab protocol on BNB Chain. Sections marked built describe code in the QLab source: the cryptography in backend/packages/pq-crypto, backend/packages/schemes and backend/packages/protocol, pinned by the known-answer vectors in backend/vectors/ (pq-crypto.json, protocol.json, vault.json); the flows in backend/services, backend/packages/txbuild and backend/packages/vault-client; and the Solidity contracts (QuantumAnchor, QuantumVaultFactory, QuantumVault with the libraries XMSS and QuantumDigest, and the launchpad contracts in contracts/src). An independent implementation must reproduce those vectors byte for byte; verify it yourself has a dependency-free one that does. Sections marked planned are not built yet and may still change. Contract addresses are set at deployment and are not part of the protocol.

1. Notation#

  • ‖ concatenation. H(x) = SHA-256. All integers are big-endian.
  • u8, u16, u32, u64: 1-, 2-, 4-, 8-byte unsigned integers. u256: a 32-byte unsigned integer.
  • utf8(s): UTF-8 bytes of s after Unicode NFC normalization.
  • enc(x) = u32(len(x)) ‖ x.
  • HKDF(ikm, salt, info, L): HKDF-SHA256 (RFC 5869).
  • addr(a): the raw 20 bytes of an EVM address. Addresses are written 0x + 40 hex; any letter case is accepted on input, JSON and signed text use lowercase, and the mixed-case EIP-55 form is for display only.
  • b58: Base-58 with the Bitcoin alphabet. Hex is lowercase. Post-quantum material (roots, seeds, signatures, digests) is written as hex without 0x.
  • keccak256 appears only where the EVM itself requires it (CREATE2 addresses, the anchor contract's storage key).

2. DomainBuilt#

Every digest and key is bound to a domain D = (app, chain):

  • app = "qlab", permanent (APP_ID; the same string is compiled into the vault contract). Changing it would change every key and digest.
  • chain = u256(chain id): the EVM chain id as 32 big-endian bytes (chainBinding(chainId), domainFor(chainId)). BNB Chain is 56 and its testnet is 97, so everything signed on one is invalid on the other. A contract rebuilds the same 32 bytes from block.chainid. The chain id must be positive. The protocol vectors use chain id 56.

3. Canonical encodingBuilt#

digest(D, purpose, version, fields) = H( preimage )

preimage = enc(utf8(app))
         ‖ enc(utf8(purpose))
         ‖ u16(version)
         ‖ chain                           (32 bytes, not length-prefixed)
         ‖ u32(number of fields)
         ‖ for each key k in sorted order:  enc(utf8(k)) ‖ tag(k) ‖ enc(value_bytes(k))
TypeTagvalue_bytes
str0x01utf8(value) (NFC)
u640x02u64(value), 0 ≤ value < 2^64
bytes0x03raw bytes

Rules:

  • purpose must match ^[a-z][a-z0-9_-]{0,63}$; every key must match ^[a-z][a-zA-Z0-9_]{0,63}$. Keys are sorted by UTF-16 code unit order (equal to byte order for this alphabet).
  • Every message is built only through its builder in protocol/src/messages.ts, which fixes the field set and validates each value:
    • addresses are encoded as their raw 20 bytes (bytes), never as hex text, so letter case cannot change a digest;
    • amounts are uint256 values in the token's smallest unit, encoded as their 32 big-endian bytes (bytes), because they do not fit the u64 tag;
    • control characters (U+0000–U+001F, U+007F, including \n) are rejected in all signed text;
    • URLs must be https: without credentials (≤ 200 characters, normalized by the URL parser);
    • optional fields use the empty string "" (tag str), never omission, so the field set is always the same.
  • PROTOCOL_VERSION = 1 for every purpose.

Annotated example (vector encoding[0] of pq-crypto.json)#

Domain app = "vectors.test", chain = 00 01 … 1f (a test pattern in place of a chain id), purpose launch, version 1, fields {mint: str "Mint111", name: str "Coin", index: u64 257} (a low-level encoding test, not a real launch message):

0000000c 766563746f72732e74657374        enc("vectors.test")
00000006 6c61756e6368                    enc("launch")
0001                                     version 1
000102…1e1f                              chain (32 bytes)
00000003                                 3 fields
00000005 696e646578 02 00000008 0000000000000101     "index"  u64  257
00000004 6d696e74   01 00000007 4d696e74313131       "mint"   str  "Mint111"
00000004 6e616d65   01 00000004 436f696e             "name"   str  "Coin"

SHA-256 → a3f065f2235b5a283b45b57c5027043f80836447ce72f359fcdc9d7567323b2e

4. Derivation messageBuilt#

The wallet signs, with personal_sign (EIP-191, ECDSA on secp256k1), the UTF-8 bytes of this exact text, lines joined by \n, no trailing newline:

qlab post-quantum identity v1

Signing derives your hash-based keys locally in this browser.
It is not a transaction and costs nothing.
Only sign this on qlab. Any other site asking for it is phishing.

Wallet: <wallet address, 0x + 40 lowercase hex>
Chain ID: <chain id, decimal>

The text is the identity: it never changes within protocol version 1. It names the app and the chain id, so the keys of one app or chain never coincide with those of another.

Determinism check (client, built in the web app): sign the message twice and refuse the wallet if the two signatures differ. ECDSA with RFC 6979 nonces gives the same signature every time; a wallet that signs with fresh randomness would give different keys in every session. Smart-contract wallets are refused: they have no ECDSA key of their own, so there is no signature to derive from.

5. Seed derivationBuilt#

label(s) = enc(utf8(app)) ‖ utf8(s)
info     = chain (32) ‖ addr(wallet) (20)
sig      = r ‖ s, the first 64 bytes of the wallet's 65-byte signature over the derivation message

pubSeed  = HKDF(ikm = sig,             salt = label("pub/v1"), info, 32)

if a passphrase P is set (it must not be empty after NFKC):
  salt_p    = H( label("salt/v1") ‖ addr(wallet) )
  hardening = Argon2id( password = utf8(NFKC(P)), salt = salt_p, m = 64 MiB (65,536 KiB), t = 3, p = 1, length 32 )
else
  hardening = empty

skSeed   = HKDF(ikm = sig ‖ hardening, salt = label("sk/v1"),  info, 32)
personal_sign(msg)secp256k1 · r ‖ s · 64 Bpassphrase (optional)NFKCArgon2id64 MiB · t=3 · p=1 → 32 BHKDF-SHA256salt enc(app) ‖ "pub/v1"pubSeedpublic · 32 BHKDF-SHA256ikm sig ‖ hardeningskSeedsecret · browser onlychildSeed(p, i)"child/v1" · chainsighardeninginfo = chain (32) ‖ wallet (20) · chain = u256(chain id) · pubSeed never depends on the passphrase
Figure: seed derivation. The first 64 bytes (r ‖ s) of the wallet's signature feed HKDF twice; the optional passphrase is stretched with Argon2id and only reaches the secret seed, so the public seed never depends on it.
  • The recovery byte v of the signature is dropped: wallets disagree on its encoding (27/28 or 0/1) and it carries no entropy.
  • pubSeed is public (part of the public key) and never depends on the passphrase.
  • skSeed never leaves the browser; intermediate buffers are wiped.
  • Argon2id parameters: RFC 9106 §4 second recommended option with p = 1. Measured 0.76 s in Node; about 2 s in browsers; once per unlock.
  • Passphrase guessing, honestly. pubSeed is not a guess oracle. But anyone who holds the wallet key can test a guess offline against any published hypertree signature, at the cost of one Argon2id plus about 500 SHA-256 per guess. The protection is that cost and the passphrase's entropy. The web app accepts a passphrase only if zxcvbn-ts estimates at least 2^60 guesses and gives it its top score (4), or if it is the diceware phrase the app generated for you (6 words from the EFF large list, about 77.5 bits). passphraseBits in pq-crypto (floor(log2(pool) × min(length, 2 × distinct characters))) is only an upper bound and never the acceptance test; MIN_PASSPHRASE_BITS = 60.

Child seedsBuilt#

childSeed(purpose, index, length = 32) = HKDF(ikm = skSeed, salt = label("child/v1"),
                                              info = chain (32) ‖ enc(utf8(purpose)) ‖ u64(index) ‖ u16(length), length)

The chain and the output length are bound, so child seeds differ between chains and outputs of different lengths are unrelated. length is 16 to 8,160 bytes (255 × 32, the HKDF-SHA256 limit).

purposeindexUsed forStatus
scheme/<schemeId>0many-time scheme key seed (length = the scheme's seed size)Built
minthypertree index of the WOTS launchCREATE2 salt of the token (LaunchParams.salt); the token address commits to the identityBuilt
mint/schemeper-identity monotonic counter (ledger scope …:mint)CREATE2 salt of the token for scheme launchesBuilt
walletwallet indexprivate key of a derived secp256k1 walletBuilt
vault/skvault indexsecret seed of an XMSS vault key (§16)Built
vault/pubvault indexpublic seed of that vault key; same formula with ikm = pubSeed of the identity, so it never depends on the passphraseBuilt

6. WOTS one-time signaturesBuilt#

Parameters: n = 32, w = 16, len1 = 64, len2 = 3, len = 67. Signature: 67 × 32 = 2,144 bytes.

Address (ADRS), 32 bytes:

OffsetSizeField
04type: 0 chain, 1 leaf, 2 node, 3 secret
44a
84b
124c
164layer
208tree
284zero
F(pubSeed, ADRS, x) = H(pubSeed ‖ ADRS ‖ x)                         tweakable hash (SPHINCS+ "simple" style)
sk_i   = H(skSeed ‖ ADRS(secret, a = leaf, b = i, c = 0, layer, tree))
chain(x, start, steps): for s in start … start+steps−1:  x = F(pubSeed, ADRS(chain, a = leaf, b = i, c = s, layer, tree), x)

digits(m), m = 32 bytes:
  d_0 … d_63  = the 64 nibbles of m, high nibble first
  C           = Σ (15 − d_i)            0 ≤ C ≤ 960
  d_64 … d_66 = (C >> 8) & 15, (C >> 4) & 15, C & 15     (not left-shifted)

public key   pk_i = chain(sk_i, 0, 15)
signature    σ_i  = chain(sk_i, 0, d_i)
verify       pk_i = chain(σ_i, d_i, 15 − d_i)    for all 67 chains
leaf         = H(pubSeed ‖ ADRS(leaf, a = leaf) ‖ pk_0 ‖ … ‖ pk_66)

Verification costs Σ(15 − d_i) chain hashes: 45 (best) to 990 (worst). Correctness is shown by a differential test against an independent naive implementation; with layer = tree = 0 the bytes also equal pqc.market's layout, and their published vault vectors are reproduced as an extra check. The Solidity library XMSS implements the same construction and is pinned to this one by the vectors.

A WOTS key must sign exactly one message. The primitive does not enforce this; the ledger does (§10), and for vault keys the vault contract does too (§16).

7. XMSS treeBuilt#

level 0:  leaf_j                       (§6)
level h:  node(h, j) = H(pubSeed ‖ ADRS(node, a = h, b = j, layer, tree) ‖ node(h−1, 2j) ‖ node(h−1, 2j+1))     h = 1 … 8
root     = node(8, 0)
auth path for leaf i: the sibling at each level 0 … 7 (8 × 32 bytes)

One tree of height 8 costs 256 × (67 + 67 × 15 + 1) + 255 = 274,943 SHA-256 calls.

8. Hypertree identityBuilt#

Two layers (d = 2) of height-8 trees: 65,536 one-time signatures.

layer 1 · 1 tree · 256 leavesroot_topleaf t signs root of tree ttree 0tree 1tree ttree 255· · ·layer 0256 treesleaf i of tree t signs the message · g = 256·t + i256 × 256 = 65,536 one-time keys · public key (root_top, pubSeed)
Figure: the identity hypertree. Each leaf of the top tree signs the root of one of 256 bottom trees; bottom leaves sign messages, for 65,536 one-time signatures under one public key.
  • Layer 1: one top tree (tree = 0). Its leaf t signs the root of bottom tree t.
  • Layer 0: 256 bottom trees (tree = 0 … 255). Leaf i of bottom tree t signs messages.
  • Global index g = 256·t + i, 0 ≤ g < 65,536.
  • Index 0 is reserved for the deterministic registration digest (§11). Every other signer uses g ≥ 1 (enforced by the attestation schema).
  • Public key (root_top, pubSeed); capacity 65,536.
  • Only the top tree and the bottom tree in use are built (at most two bottom trees cached). A top leaf always signs the same message (its bottom root), and signing is deterministic, so signing it again reveals nothing new.
  • Measured (Node, noble): top tree 420 ms; first bottom tree + sign 398 ms; each further signature 1.1 ms.

Signature wire format, 4,804 bytes:

OffsetSizeField
04u32(g)
42,144WOTS signature of the message, bottom tree t, leaf i
2,148256bottom auth path (8 × 32)
2,4042,144WOTS signature of root_bottom, top tree, leaf t
4,548256top auth path (8 × 32)

The bottom root is not transmitted; the verifier recomputes it.

hypertree signature · 4,804 bytes04 BWOTS σ, bottom tree t, leaf i42,144 B2,148256 BWOTS σ of root_bottom, top leaf t2,4042,144 B4,548256 B4,804auth = 8 sibling hashes × 32 B · the bottom root is not transmitted: the verifier recomputes it
Figure: the 4,804-byte hypertree signature, to scale: index, the bottom WOTS signature and auth path, then the top WOTS signature over the bottom root and its auth path.

Verification of a 32-byte message m: check the length and g < 65,536; r0 = root implied by the bottom signature for m at (layer 0, tree t, leaf i); r1 = root implied by the top signature for r0 at (layer 1, tree 0, leaf t); accept iff r1 == root_top (constant-time). Cost ≤ 2 × 990 + 2 + 16 hashes.

9. pq addressBuilt#

pq_address = "pq1" ‖ b58( digest(D, "address", 1, {root: bytes(root_top), pubSeed: bytes(pubSeed)})[0 … 19] )

A 160-bit label for humans. It is not an EVM address and cannot receive funds. Verification always uses the full public key.

10. One-time-key ledger and signing session#

ClientBuilt#

OneTimeKeyLedger (pq-crypto) under a lock named ledger:<scope>, scope = app:chain(hex):root(hex):

  1. allocate(scope, purpose, serverHint) returns max(highest local index + 1, serverHint). A hint can only move the index forward. Past capacity: LedgerCapacityError.
  2. sign persists msgHash (state signing) before signing, and the signature (state signed) before returning it.
  3. The same message again returns the cached, byte-identical signature. A different message at a used index throws OneTimeKeyReuseError, even after a crash mid-sign.
  4. pin(scope, 0) is used only for the registration digest, which is deterministic and safe to sign on any device.

IdentitySession (protocol) is the only API that produces identity signatures: signRegistration() (index 0), signOneTime(purpose, build, serverNextIndex) (allocates ≥ 1, lets the caller build the digest that commits to the index, signs through the ledger), certifyScheme(scheme), signScheme(scheme, purpose, build, cert), signWarPlates(purpose, build, certs), signVaultSpend(vaultIndex, build, usedOnChain), destroy().

Browser store: IndexedDB (strict durability, keyed by scope and index) under an exclusive Web Lock per scope (built, web app). Signing is refused in browsers without Web Locks.

ServerBuilt#

  • leaf_ledger, primary key (identity_id, idx), states reserved → signed → burned. There is no release state: a reserved index is never issued again, even if unused.
  • CHECK constraints: idx in 0–65,535; a non-reserved row has a 32-byte msg_hash and signed_at; a burned row has burned_at.
  • Burn order: verify → all fallible work (pin, build the transaction request) → burn → respond.

11. Registration and anchor#

Message formats, contract and flow · built.

Registration statement (the wallet signs it with personal_sign), registrationStatement:

qlab — register post-quantum identity

Wallet: <wallet address, 0x + 40 lowercase hex>
PQ address: <pq1…>
Root: <root hex>
Public seed: <pubSeed hex>
Capacity: <capacity>
Chain ID: <chain id, decimal>
Protocol: qlab/v1 hypertree(d=2,h=8,WOTS w=16 SHA-256)

Registration digest (signed by hypertree index 0), registrationDigest: purpose register, fields {wallet: bytes (20), root: bytes, pubSeed: bytes, capacity: u64}.

Anchor. The wallet calls the QuantumAnchor contract; the arguments come from anchorArgs(identity):

anchor(bytes32 root, bytes32 pubSeed, uint32 capacity)          msg.sender = the wallet
  requires root ≠ 0 and 1 ≤ capacity ≤ 65,536
  reverts if this wallet already anchored exactly this identity
  first anchor of a wallet → stored as its origin: root, pubSeed, capacity, block number, timestamp
  every anchor             → anchoredAt[wallet][keccak256(abi.encode(root, pubSeed, capacity))] = block number
  emits Anchored(wallet, root, pubSeed, capacity, origin)

originOf(wallet)                               → the first identity the wallet anchored; blockNumber = 0 if none
isAnchored(wallet, root, pubSeed, capacity)    → block number of that anchor; 0 = never

The contract has no owner, and no function changes or removes an entry: the first anchor wins for good.

Flow. The client registers the identity (state pending_anchor) and the API returns the transaction request: to = the anchor contract, data = the call above. The browser decodes the request and checks it against the identity it derived, the wallet sends it, and the client reports the transaction hash. The API activates the identity only when isAnchored(wallet, …) is non-zero at a confirmed block and, for a wallet's first identity, originOf(wallet) is this identity (otherwise EARLIER_ANCHOR_EXISTS). Only then does the identity become active (also a database CHECK). Unanchored identities cannot reserve one-time keys or launch.

Verifiers trust the wallet's origin. The standalone verifier (§17) needs two view calls and scans nothing: isAnchored for the attested identity, and originOf for the launching wallet. The attested identity must be the origin itself, or the end of a rotation chain that starts at the origin.

Rotation · built, rotateDigest: purpose rotate, {wallet: bytes (20), fromRoot, toRoot, toPubSeed: bytes, toCapacity: u64}, signed by one of the current identity's indices (≥ 1) and submitted to POST /v1/identities/:id/rotate. The successor registers like any identity and must be anchored by the same wallet; the contract records it as a later entry. Rotation certificates stay off-chain: a successor's launch attestations carry them back to the original identity (identity.rotations, up to 32 hops). A verifier checks every hop and requires the first identity of the chain to equal originOf(wallet), so a later anchor counts only when the wallet's origin certified it.

12. Many-time schemes and certificatesBuilt#

Scheme idAlgorithmStandardSignature (bytes)Public key (bytes)Seed (bytes)Context
ml_dsa_65ML-DSA-65FIPS 2043,3091,95232yes
ml_dsa_87ML-DSA-87FIPS 2044,6272,59232yes
slh_dsa_sha2_128sSLH-DSA-SHA2-128sFIPS 2057,8563248yes
slh_dsa_shake_128fSLH-DSA-SHAKE-128fFIPS 20517,0883248yes
falcon_512Falcon-512 (FN-DSA)FIPS 206 (draft)≤ 66689748no
falcon_1024Falcon-1024 (FN-DSA)FIPS 206 (draft)≤ 1,2801,79348no
composite_mldsa65_ed25519ML-DSA-65 + Ed25519, SHA-512draft-ietf-lamps-pq-composite-sigs-19, OID 1.3.6.1.5.5.7.6.483,3731,98464yes
  • Keys: keygen(childSeed("scheme/<id>", 0, seedBytes)), deterministic from the identity.
  • Context: every signature carries ctx = utf8("qlab/<chain id>/<purpose>"), for example qlab/56/launch (FIPS 204/205 context, or the composite ctx). Falcon has no context; the signed digest is domain-bound in all cases.
  • Composite: M' = "CompositeAlgorithmSignatures2025" ‖ "COMPSIG-MLDSA65-Ed25519-SHA512" ‖ u8(len(ctx)) ‖ ctx ‖ SHA-512(M); sig = ML-DSA-65.Sign(M', ctx = label) ‖ Ed25519.Sign(M'); pk = mldsaPK ‖ edPK. Valid only if both verify. Checked against the draft's own known-answer test. The Ed25519 half is the classical part of this hybrid; it has nothing to do with wallet keys.
  • Certificate: a hypertree signature (index ≥ 1) over bindDigest: purpose bind, {root: bytes, pubSeed: bytes, scheme: str, publicKeyHash: bytes = H(public key)}.
  • Verification (verifySigner) checks the certificate against the identity, then the scheme signature with the scheme's context.

13. Launch attestationBuilt#

Launch digest, launchDigest, purpose launch:

FieldTypeRule
mintbytes (20)the token's address: the CREATE2 address the factory will deploy it at
launcherbytes (20)must equal the identity's wallet
namestr1–32 characters
symbolstr1–10, [A-Za-z0-9]
descriptionstr≤ 500
imageCidstrIPFS CID (CIDv0 Qm… or base32 CIDv1 b…)
twitter, telegram, websitestrhttps URL or ""
quoteMintbytes (20)what the pool is quoted in; the zero address is the native coin (BNB)
modestrstandard, quantum or war
vaultbytes (20) or str ""required for (and only for) quantum and war
devBuyWeibytes (u256)the creator's first buy, in the quote asset's smallest unit; > 0 for quantum and war
feeCreatorBpsu640–10,000: the creator side of quote-side swap fees, fixed at launch
configIdu64the factory launch config: supply, opening market cap and pool fee
antiSnipeSecondsu640–1,800; 0 = a plain pool with no hook
holdersBpsu640–10,000: the part of the creator side that is streamed to the token's holders
signerKindstrwots or scheme
signerIndexu64if wots: hypertree index (≥ 1)
signerScheme, signerKeyHashstr, bytesif scheme: scheme id and H(public key)

Pinned format. The coin's IPFS metadata JSON carries a qlab key holding a LaunchAttestation (strictly validated, no unknown keys, lowercase hex of exact lengths, lowercase 0x addresses):

JSON
{
  "qlab": {
    "protocol": "qlab/launch/v1",
    "chainId": 56,
    "identity": {
      "wallet": "0x<40 hex>",
      "pqAddress": "pq1…",
      "root": "<hex 32>",
      "pubSeed": "<hex 32>",
      "capacity": 65536,
      "anchorTx": "0x<64 hex: the transaction in which the wallet anchored this identity>"
    },
    "fields": {
      "mint": "0x…", "launcher": "0x…", "name": "…", "symbol": "…", "description": "…",
      "imageCid": "…", "twitter": "", "telegram": "", "website": "",
      "quoteMint": "0x0000000000000000000000000000000000000000",
      "mode": "standard", "vault": "", "devBuyWei": "0", "feeCreatorBps": 8500,
      "configId": 0, "antiSnipeSeconds": 0, "holdersBps": 0
    },
    "digest": "<hex 32>",
    "signer": { "kind": "wots", "index": 4812, "signature": "<hex, 4,804 bytes>" }
  }
}

For a many-time scheme, signer is {kind: "scheme", scheme, publicKey (hex), signature (hex), cert: {index, signature}}. A rotated identity adds identity.rotations: one {root, pubSeed, capacity, index, signature} per predecessor, oldest first (§11). devBuyWei is a decimal string. anchorTx is a pointer for people and explorers; verifiers read the anchor contract's state instead. (feeCreatorBps: 8500 above is only an example value; the real one is read from the factory.)

War modeBuilt#

A war launch is a Quantum launch signed by four algorithms. Besides the one-time hypertree signature in signer, the attestation carries plates: exactly three scheme signatures, in this order (WAR_PLATE_SCHEMES):

PlateSchemeFamily
1slh_dsa_sha2_128sstateless hash-based
2ml_dsa_65module lattices
3falcon_512NTRU lattices

Each plate has the shape of a scheme signer ({kind: "scheme", scheme, publicKey, signature, cert}) and signs the launch digest built for its own key (signerKind = "scheme", signerScheme, signerKeyHash), exactly like a single-scheme launch; its key is certified by the identity. The primary signer of a war launch must be the hypertree key, and any other mode must carry no plates. Forging the provenance of such a coin means breaking all four.

Launch transaction and feesBuilt#

A launch is one call, QuantumFactory.launch(LaunchParams), prepared by the gateway (packages/txbuild) as a transaction request {to, data, value, chainId} and sent by the launcher's wallet. When the first buy is paid in an ERC-20, an approve of exactly that amount to the factory comes first. The attested fields become the call's arguments:

LaunchParamsValue
name, symbol, configId, quoteToken, antiSnipeSecondsas attested
metadataURIipfs://<cid> of the pinned metadata; the factory stores it on the token once. It is not part of the token address
saltchildSeed("mint", signerIndex) for a hypertree launch (wotsMintSeed), childSeed("mint/scheme", counter) for a scheme launch (allocateSchemeMintSeed)
initialBuyAmount, initialBuyMinTokensOutdevBuyWei, with a non-zero floor on what it must return
initialBuyRecipientthe attested vault for quantum and war: the pool pays the first buy straight to the vault. The launcher otherwise
creatorFeeRecipient, feeSharesholdersBps = 0: creatorFeeRecipient = launcher. 0 < h < 10,000: feeShares = [(launcher, 10,000 − h), (zero address = the holders, h)]. h = 10,000: [(zero address, 10,000)]
minOpeningTick, maxOpeningTickthe factory's previewLaunch reading ± a few tick spacings; the launch reverts outside them
maxLaunchFeeWeithe highest launch fee the launcher agrees to
native valueexactly the launch fee, plus the first buy when the quote asset is the native coin

Token address. The factory deploys the token with CREATE2, using keccak256(abi.encode(launcher, salt)) as the CREATE2 salt, so the address depends on the launcher, the salt, the name, the symbol and the config's supply, and on nothing else. factory.predictTokenAddress(launcher, salt, name, symbol, configId) (or predictRewardTokenAddress when holders earn) returns it before the launch. The client computes it over its own RPC connection and signs it as mint. Because the salt comes from the signing key's index, the address commits to the identity, and nobody else can deploy at it.

In the transaction the factory deploys the token (18 decimals, fixed supply, no owner), writes metadataURI, opens a PancakeSwap Infinity concentrated-liquidity pool at the config's opening market cap converted into the quote asset, places the whole supply as one-sided liquidity from that price upward, locks the position in QuantumLocker (which has no function that removes liquidity), fills the first buy, and records the launch (launches(token), event TokenLaunched).

Checks around it.

  1. Prepare. The gateway verifies the attestation, recomputes the predicted address (MINT_MISMATCH), checks feeCreatorBps, the config and the quote asset against the chain, pins the metadata, builds the request, stores the SHA-256 of the exact request (chain id, target, value, calldata) and burns the one-time key last.
  2. Before signing. The browser decodes the request and checks every field against what it attested (verifyLaunchTransaction in @app/txbuild/verify): target = the pinned factory, salt, metadata URI, fee route, first-buy amount, recipient and floor, tick bounds, launch fee and native value. The decoded call list is shown; an unknown contract or function is listed as such, never hidden.
  3. Submit. The client reports the transaction hash; the gateway accepts it only if the transaction's sender, target, value and input equal the prepared request (TX_MISMATCH otherwise).
  4. Listing. The indexer lists the token when it sees TokenLaunched for that address from the pinned factory, with that creator and metadata URI. A coin that is not in the launches table is never shown as attested (SR-9).

Fees. Nothing here is set by the gateway; it reads the factory.

  • The pool's swap fee is fixed by the launch config and can never change for that pool. It accrues to the locked position, in whatever the trader paid with: buys accrue the quote asset, sells accrue the token.
  • QuantumLocker.collectFees(token) can be called by anyone. It splits the quote side between the protocol and the creator side at protocolFeeBps, and burns the token side. The locker stores protocolFeeBps when the coin launches, read from the factory at that moment, so the split is fixed per coin: feeCreatorBps = 10,000 − factory.protocolFeeBps(). The gateway refuses a launch whose signed feeCreatorBps differs. The contract caps the protocol's share at 5,000.
  • Credits are pull balances: each earner takes its own with locker.claimFees(currency, to).
  • With holdersBps > 0 the launch deploys a reward token, and the holders' part of the creator side is credited to the token contract itself. sync() (anyone) pulls it in and streams it to the holders in proportion to what they hold while it streams; a batch streams for as long as it took to build up, at least one hour and at most seven days. A holder takes their part with claim(to).
  • With antiSnipeSeconds > 0 the pool has the anti-snipe hook and a dynamic fee: for that many seconds a buy pays a fee that starts at 99 % and falls in a straight line to the config's fee. Sells always pay the config's fee, and so does the creator's first buy inside the launch. The extra is an ordinary pool fee, collected and split like the rest.
  • A flat launch fee in the native coin, read from the factory (launchFeeWei, capped by the contract at 1 BNB), goes to the treasury in the launch transaction. The request names the highest fee the launcher accepts.
  • The factory's owner can change the protocol's share, the launch fee and the configs on offer for new launches only. A part of the protocol's share may go to a buyback contract; that part is inside protocolFeeBps and never touches the creator side.
  • Fee collection (collectFees, and sync for reward tokens) is permissionless; our worker calls it for active coins.

Sealed launchesBuilt#

A creator can announce a launch before the coin exists, without revealing it. The browser encrypts the coin's details and publishes only the ciphertext and a commitment (api-contract/src/seal.ts):

plaintext  = UTF-8 of the JSON {"v":1,"mint","name","symbol","description","imageCid","quoteMint","mode","configId"}
             keys in exactly this order, no whitespace, at most 2,048 bytes
key        = 32 random bytes          iv = 12 random bytes
ciphertext = AES-256-GCM(key, iv, plaintext), no additional data, 16-byte tag appended
commitment = H(iv ‖ ciphertext)

revealAt is 60 seconds to 24 hours after the seal is created; the launch is accepted from revealAt and for 24 hours, then the seal expires. An identity has one open seal at a time. At launch the creator hands the key over with the prepare request; the gateway decrypts the stored ciphertext and refuses the launch unless every sealed field equals the attested coin (SEAL_MISMATCH), before it pins anything or burns the key. Afterwards the key is public (GET /v1/sealed/:id), so anyone can decrypt the seal and see that it opens to exactly that coin. The seal is stored and published by the gateway, not written on-chain.

14. Proof of possessionBuilt#

proofDigest, purpose proof: {wallet: bytes (20), nonce: bytes (32, server-issued, single use), index: u64}, signed through IdentitySession.signOneTime. A valid signature against the anchored root yields a session. The nonce comes from a single-use challenge, and an expired challenge never lets a key sign a second message.

15. Derived wallets and transfersBuilt#

  • A derived wallet is an ordinary secp256k1 account whose private key is childSeed("wallet", index) (IdentitySession.walletSeed). The key is never stored; it is re-derived on demand.
  • walletAttachDigest, purpose wallet-attach: {root: bytes, address: bytes (20), walletIndex: u64 (≤ 2^32 − 1), signer…}. A derived wallet attaches only with this signature; the client re-derives every displayed address.
  • walletRotateDigest, purpose wallet-rotate: {root: bytes, from: bytes (20), to: bytes (20), toIndex: u64 (≤ 2^32 − 1), signer…}; from ≠ to. The identity authorizes moving everything held by derived wallet from to its derived wallet to, which also certifies to, so the server never chooses where a sweep goes.
  • transferDigest, purpose transfer: {from: bytes (20), to: bytes (20), mint: bytes (20) or "" for the native coin, amount: bytes (u256) > 0, nonce: bytes (32, unique), txNonce: u64, signer…}; from ≠ to. txNonce is the sending account's transaction nonce, so the attestation belongs to exactly one transaction of from.
  • The transaction. The gateway builds a complete unsigned transaction (nonce, gas limit and fee caps; EIP-1559 or legacy). The browser decodes it and checks chain, nonce, recipient, asset, amount and attestation hash, with gas and fees bounded so that fees cannot drain the wallet (verifyTransferTransaction), the derived key signs it locally, and the gateway relays it with eth_sendRawTransaction only if it is, apart from the signature, byte for byte what it prepared.
  • The attestation hash rides in the transaction. It is the 32-byte digest the identity signed (transferDigest; walletRotateDigest for the steps of a wallet rotation): appended to the ERC-20 transfer(to, amount) calldata (the token ignores what follows its arguments), or sent as the data of a native transfer to an address without code.

16. Quantum vaultBuilt#

Spend digest, vaultSpendDigest, purpose vault-spend: {program: bytes (20, the QuantumVaultFactory), vault: bytes (20), leaf: u64 (0–255), recipient: bytes (20), mint: bytes (20, the token; the zero address is the native coin), amount: bytes (u256) > 0}. The vault contract rebuilds it byte for byte (QuantumDigest.vaultSpend), taking chain from block.chainid. vaultSpendPreimage in protocol.json is the full preimage of this spend of 4 BNB at leaf 3:

00000004 716c6162                                    enc("qlab")
0000000b 7661756c742d7370656e64                      enc("vault-spend")
0001                                                 version 1
00000000…00000038                                    chain = u256(56)
00000006                                             6 fields
00000006 616d6f756e74       03 00000020 00…003782dace9d900000    "amount"     bytes  u256(4·10^18)
00000004 6c656166           02 00000008 0000000000000003         "leaf"       u64    3
00000004 6d696e74           03 00000014 0000…0000                "mint"       bytes  zero address (native coin)
00000007 70726f6772616d     03 00000014 0f0f…0f0f                "program"    bytes  vault factory
00000009 726563697069656e74 03 00000014 0101…0101                "recipient"  bytes
00000005 7661756c74         03 00000014 0606…0606                "vault"      bytes

SHA-256 → 4111680291ec7d1bab55333db6a1ed70145748545348ac89855899b3276bdaa8

Registration, vaultRegisterDigest, purpose vault-register: {root: bytes, program: bytes (20), vault: bytes (20), vaultIndex: u64 (≤ 2^32 − 1), vaultRoot: bytes, vaultPubSeed: bytes, signer…}, signed by the identity. It binds a vault to the identity so deposits (for example a Quantum launch's first buy) are attributed to it; whoever verifies recomputes the vault address from the vault key.

The contracts (QuantumVaultFactory, QuantumVault; client in packages/vault-client):

  • Key: one XMSS tree of height 8 (256 one-time keys) per vault, at layer = 0, tree = 0, with the seeds vault/sk and vault/pub of §5.
  • Address: vault = CREATE2(factory, salt = H(root ‖ pubSeed), EIP-1167 minimal clone of factory.implementation()), that is keccak256(0xff ‖ factory ‖ salt ‖ keccak256(clone creation code))[12 … 31]. It depends on the vault key and the factory deployment and on nothing a server says; the client computes it locally (vaultAddress()), and factory.vaultAddress(root, pubSeed) returns the same. It is stable and shareable as a deposit address.
  • Deposits are plain transfers of BNB or any ERC-20 to that address, before or after the vault is deployed there. Deploying (factory.create(root, pubSeed)) is open to anyone and can only produce the one vault that key controls.
  • State: root, pubSeed, nextLeaf and spends (both uint16), and the immutable factory.
  • Signature: 2,401 bytes, u8(leaf) ‖ σ (2,144) ‖ auth path (256) (VAULT_SIG_BYTES).
  • A withdrawal is one transaction that carries the whole 2,401-byte signature as calldata: vault.withdraw(recipient, token, amount, signature), or factory.withdraw(root, pubSeed, recipient, token, amount, signature), which deploys the clone first if needed. The contract checks the length, amount > 0 and a non-zero recipient; reads the leaf from the first byte and requires leaf ≥ nextLeaf; rebuilds the spend digest from the chain id, the factory, its own address, the leaf, the recipient, the token and the amount; recomputes the XMSS root from the signature with the SHA-256 precompile (WOTS chains, 45–990 calls, then the leaf hash and the 8-level auth path) and requires it to equal root; sets nextLeaf = leaf + 1, counts the spend and emits Withdrawn(leaf, recipient, token, amount, digest); then pays. There is nothing to stage and nothing to relay.
  • Leaf counter. Every leaf below nextLeaf is dead. Landing any newer spend invalidates every older signature: a stale, aborted or blocked spend can never execute later, and a retry can never pay twice. To cancel a signed spend, land any spend at a newer leaf; the client uses 1 wei of the native coin paid to the vault itself (planCancel).
  • Who sends it. Anyone may send a signed withdrawal; it can only pay the signed recipient, token and amount. The sending account pays the gas and decides nothing.
  • No owner. The vault has no owner, no upgrade path, no pause and no rescue function. The factory has no owner and holds nothing.
  • After 256 spends the vault is exhausted (nextLeaf = 256). The client's pre-flight warns when the last leaf is about to be used: use that spend to move everything to a new vault. There is no automatic rotation.
  • Client. The deployment (chain id, factory, implementation) is pinned in the application's own configuration, never taken from an API response. Before a leaf signs, the pre-flight checks the pinned deployment against the chain, the leaf, the balance, the payment itself by simulation and the sender's gas. A signed withdrawal is persisted as a spend plan before it is returned, and while a plan is open the client refuses to sign a different spend until that plan is executed or cancelled.
  • Gas (local measurements). The on-chain XMSS verification is about 215k gas; it varies with the digest (45–990 chain steps at about 360 gas each). A whole withdrawal measured 265k–320k gas for a deployed vault and 360k–415k when the first spend also deploys the clone. The client budgets 700,000 and 850,000 gas, which leaves room for a token with an expensive transfer.
  • Planned: an independent audit of the contracts.

17. Verifying a launchBuilt#

verifyLaunchAttestation(attestation, expectedChainId, chainFacts?) is pure (no network, no database) and returns {valid, trace}; each trace step is {step, ok, detail}:

StepChecks
formatstrict schema of the qlab block
chainchainId equals the expected chain id
pq addresspqAddress derives from root and pubSeed
launcherfields.launcher equals identity.wallet
digestthe fields rebuild digest through launchDigest
scheme certificate(scheme signers) the identity certified this scheme key
signaturehypertree signature at index recomputes the root, or the scheme signature verifies under the certified key
plate <scheme>(war mode) each of the three plates is a valid, certified scheme signature; armor plates reports a missing or misplaced set
rotation chain(rotated identities) every certificate in identity.rotations was signed by its predecessor, from the original identity to this one
mint(with chain facts) the attestation names this token
creator on-chain(with chain facts) the launch factory records the launcher as this token's creator
anchor(with chain facts) the launching wallet anchored this identity in the anchor contract
earliest anchor(with chain facts) this identity, or the origin of its rotation chain, is the wallet's origin in the anchor contract; a different origin means a possible post-break forgery

verifyCoin(token, {rpcUrl, factory, anchor, chainId, ipfsGateways}) in packages/verifier gathers the chain facts with nothing but an RPC endpoint and IPFS gateways. The launch factory and the anchor contract are pinned in the verifier or passed by the caller; they never come from a server. Its own trace steps come first:

StepChecks
networketh_chainId of the endpoint (and that it is the expected chain, when one is given)
tokenthe token's metadataURI, creator, factory, name and symbol
factory, launch recordthe token names the pinned factory, and that factory's own registry (launches(token)) records it as launched for that creator
metadata, content addressthe metadata JSON fetched by CID (size-capped, no redirects by default) and re-hashed to the CID where the CID allows it
attestationthe metadata carries a qlab block
the steps of the first tableisAnchored and originOf are read from the anchor contract, and verifyLaunchAttestation runs with those facts
on-chain name, quote asset, launch config, metadata fieldsthe token's name and symbol, the launch record's quote asset and config, and the name, symbol and image the metadata shows equal the signed fields
first buy(quantum and war) the launch's InitialBuyExecuted log shows the first buy going to the attested vault; reported as not checked when the endpoint does not serve logs

The verdict is verified, not verified, or no verdict when an endpoint could not be reached or the metadata could not be checked against its CID; no verdict is never reported as a failure. The same code runs as the qlab-verify CLI and as a single self-contained verify.html (verify it yourself).

18. Test vectorsBuilt#

  • backend/vectors/pq-crypto.json (domain vectors.test, chain 00 01 … 1f): three encoding digests (one with its full preimage, one with a uint256 amount), the derivation message, plain and hardened seeds, a child seed, a WOTS key and signature, and a hypertree public key with signatures at indices 0, 257 and 65,535.
  • backend/vectors/protocol.json (domain qlab, chain id 56): inputs and digests of register, rotate, bind, launchWots, launchScheme, proof, walletAttach, transfer, vaultRegister, vaultSpend, vaultSpendToken and walletRotate, the registration statement, the anchor call's arguments, and the full vault-spend preimage.
  • backend/vectors/vault.json (chain id 56): a vault key, its factory, implementation and CREATE2 address, and four signed withdrawals (leaves 0, 1, 7 and 255; the native coin and an ERC-20). The Solidity tests replay them against the vault contract.

Regenerate only on a deliberate protocol change and review the diff.