Liquidity Docs

MPC: How It Works & What We Use

The 2-of-3 threshold-signature scheme behind every user wallet: the Doerner ceremonies, the device -> liq-ats -> ta-api -> wallet-api -> node3 relay chain, the signing modes, the libraries and pins, and the trust boundaries.

Every user wallet on the platform is controlled by a private key that never exists. This page explains what that means mechanically: who holds what, how a key is born, how a transaction gets signed, which libraries do the cryptography, and exactly what each hop in the chain can and cannot see.

1. The model in one paragraph

The user's signing key is produced by threshold ECDSA over secp256k1 and lives as three shares. Two of them (share1, share2) are generated and held on the user's device; the third (share3) is held by the platform party historically called node3. Any two of the three can produce a signature (threshold t = 1, so t + 1 = 2 parties sign); no party — and no combination of servers — ever assembles the full key. wallet-api is the service that relays the ceremony to node3 and then wraps the resulting address in an on-chain multisig wallet. It holds no share.

PartyHoldsWhere it runs
k1-share1share 1The user's device (browser Web Worker / mobile)
k1-share2share 2The user's device — usually kept out of signing as a cold backup
k1-share3share 3node3, the platform party

Because the device runs two parties, a normal signature is device + node3. The second device share exists so the user is not locked out by the loss of a single share, and so a signature is still possible with the platform party plus one device share.

2. The relay chain

The device never talks to node3 directly. It reaches it through the same edge that serves everything else, so the ceremony can be authenticated and audited where every other operation is:

  Browser / mobile device            Backend edge            Platform
  (share1 + share2)

  mpc.wasm Web Workers
        |
        |  WSS /v1/ta/mpc/{config,relay,sign}
        v
  liq-ats            (browser-facing gateway; the only host the device may reach)
        |  /wallet/mpc/{config,relay,sign}   Bearer TA_API_KEY
        v
  ta-api             (Transfer Agent; transparent hop, holds NO node3 secret)
        |  /wallet/mpc/{relay,sign}          Bearer WALLET_API_KEY
        v
  wallet-api         (mints the node3 token, pipes frames)
        |  /k1/d/ws  ·  /k1/d/sign          node3 token
        v
  node3              (share3, the Doerner engine)

Each hop is deliberate:

  • liq-ats is the only origin the browser is allowed to reach. ta-api holds issuer powers (mint, burn, freeze, forced transfer), so it is never browser-routable; liq-ats proxies exactly three ceremony paths and nothing else.
  • ta-api is a transparent hop: it forwards bytes, never decodes a protocol frame, and deliberately does not hold MPC_NODE3_JWT_SECRET. All key material stays in wallet-api.
  • wallet-api is where the node3 credential is minted and where the node3 URL stops. It upgrades the device socket, dials node3, and copies frames both ways without interpreting them.

Paths are gateway-reported, not hardcoded. The device calls GET /wallet/mpc-config (served as /v1/ta/mpc/config at the browser edge) and uses the relay_path, sign_path, parties and threshold it returns. Each gateway rewrites those two path fields to its own, so a path move on any hop needs no client release.

3. The two ceremonies

Keygen and signing are different protocols with different round structures, and node3 serves them at different endpoints. They cannot share one socket.

Ceremonywallet-api pathnode3 pathQuery args the device supplies
Keygen (DKG)GET /wallet/mpc/relay (WebSocket)/k1/d/wssid, party, parties, platform
SigningGET /wallet/mpc/sign (WebSocket)/k1/d/signsid, party, signers, platform, wallet, msg

Keygen carries the full parties set (all three take part); signing carries signers — only t + 1 = 2 of the three, which is what lets share2 stay out of the ceremony as a cold backup.

Keygen, step by step

  1. The device opens one relay socket per party it runs (share1, share2), passing a shared session id (sid).
  2. wallet-api mints a node3 token for that party, strips the client's own auth token from the forwarded query string, and dials node3's /k1/d/ws.
  3. The three parties run distributed key generation. The device ends up with two share files; node3 keeps the third.
  4. The device now has a public key and an Ethereum address — the user_address. No private key was ever assembled anywhere.
  5. The device (via the gateways) calls POST /wallet with that user_address, and wallet-api deploys the on-chain wallet around it. See workflows.

Signing, step by step

  1. A caller asks wallet-api to build an unsigned transaction — e.g. POST /trade/propose-tx — and gets back the unsigned tx plus a 32-byte sign_hash (and, for orders, an order_nonce).
  2. The device opens GET /wallet/mpc/sign for its signing party, passing the digest as msg and the wallet public key as wallet.
  3. Device + node3 co-sign the digest and the device assembles a standard secp256k1 signature (r, s, recovery id), which it attaches to the tx and broadcasts.
  4. wallet-api sees a signed transaction, never a key.

The four "act with your key" endpoints that pair with this are forwarded verbatim by ta-api: /trade/propose-tx, /trade/cancel-tx, /wallet/tx/approve, /wallet/approve/execute.

4. The engine: Doerner, not CMP

The live engine is Doerner — threshold ECDSA with no pre-computation, run here in a 2-of-3 party set. It replaced a CMP engine, and the reason is worth recording because it removed an endpoint from the API:

CMP keygen needs a 2048-bit Paillier keypair per party before the ceremony can begin. Those were fetched from node3's /k1/preparams pool at 33-94s per party on a pool hit, and a miss ran into node3's 120s ceiling — so a two-party keygen routinely failed before round one. Doerner has no pre-computation at all.

Consequences, if you are reading older code or docs:

  • GET /wallet/mpc/preparams no longer exists on wallet-api or ta-api, and mpc-config no longer reports a preparams path.
  • There is no pool to warm, no 5-minute client timeout to tune, and no Paillier-generation latency in the keygen budget.

5. Authentication and the trust boundary

Two independent credentials guard the ceremony.

CredentialWho checks itNotes
WALLET_API_KEYwallet-apiAuthorization: Bearer, X-API-Key, or ?token= (a WebSocket handshake cannot set headers). Empty disables auth — dev only.
node3 tokennode3Minted server-side by wallet-api, one per party: HS256 over {sub: party, iat, exp} with MPC_NODE3_JWT_SECRET, default TTL 10 minutes.

wallet-api strips the token / api_key params the device sent for wallet-api's own auth before forwarding, then injects the node3 token — otherwise node3 would read our API key as its credential and reject the handshake.

⚠️ MPC_NODE3_STATIC_TOKEN is a stopgap. The Doerner node3 deployment signs with a secret we were not given, so tokens minted from MPC_NODE3_JWT_SECRET come back 401 unauthorized: bad signature — which surfaces as websocket: bad handshake in wallet-api and a bare "websocket error" in the browser. A pre-issued static token bypasses minting and is strictly worse: one shared bearer for all three parties, days of validity instead of minutes, and a sub that cannot identify the caller. Clear it the moment MPC_NODE3_JWT_SECRET matches the deployment.

What each hop can see

HopSees a share?Decodes protocol frames?Holds the node3 secret?
Browser / deviceYes — share1, share2Yes (it is two parties)No
liq-atsNoNoNo
ta-apiNoNoNo
wallet-apiNoNoYes (mints per-party tokens)
node3Yes — share3 onlyYesn/a

The relay is a byte pipe: wallet-api can refuse, authenticate, log, and audit a ceremony, and it cannot learn a key from one.

6. The three signing modes

wallet-api supports three signing models, selected by configuration.

ModeWho signs the user keyConfigUsed for
devDeterministic in-process dev keysWALLET_MPC_DEV_KEY_HEX, WALLET_ALLOW_DEV_KEYS=1Local testing against Anvil
node3 (device)Device (share1+share2) + node3 (share3), 2-of-3MPC_NODE3_URL + MPC_NODE3_JWT_SECRETThe real user-facing flow
enginewallet-api co-signs server-side via an mpcium clusterWALLET_MPC_MODE=engine, WALLET_MPC_NATS_URL, WALLET_MPC_INITIATOR_KEYServer-to-server automation, no device present

Engine mode (mpcium cluster)

Engine mode is the no-device path: wallet-api talks to an mpcium node cluster over NATS, which runs DKG and signing among its own nodes.

  • One hub per process. mpcium's result queues are shared durable JetStream consumers (mpc_keygen_result, mpc_signing_result), so two subscribers load-balance results between them — a result for wallet A can be delivered to wallet B's handler and dropped. MpciumHub therefore subscribes once and fans results out to per-wallet waiters by WalletID (keygen) / TxID (sign).
  • Async, event-driven. CreateWallet publishes a keygen request and blocks for the matching result event; the default keygen budget is 120s.
  • Compliance gate. mpcium nodes only run keygen for a request countersigned by the configured authorizers, so KYC/AML approval plugs in as an authorizer signature on the keygen request. wallet-api relays whatever signatures it is given; passing none is an unauthorized keygen (dev/test only).

7. Platform keys are not MPC

Only user keys are MPC-split. The platform's own signers are HSM-backed:

SignerRoleConfig
ta-adminDeployer / owner / agent of the ERC-3643 backboneWALLET_HSM_ADMIN_LABEL + _ADDRESS
asset-executorV42 executor, settlement executor, submits fillBatchWALLET_HSM_EXECUTOR_LABEL + _ADDRESS
guardianEvery wallet's guardianWALLET_HSM_GUARDIAN_LABEL + _ADDRESS

The HSM signs in digest mode: wallet-api builds the transaction (nonce, gas, chain id), computes the EIP-155 signing hash locally, and posts only that 32-byte digest to POST {WALLET_HSM_URL}/sign with a key label; the service returns r || s || v, which wallet-api reassembles into a signed transaction. Per-wallet executor keys are provisioned with POST /generate-address?curve=secp256k1, whose returned label id must be persisted — the label is how that key is later addressed.

wallet-api refuses to boot with well-known Anvil/Hardhat dev keys as platform signers unless WALLET_ALLOW_DEV_KEYS=1 is set explicitly, so a deployment mispointed at a shared chain cannot come up with a public, grief-able admin key.

8. What we are using

Runtime, today

ComponentWhat it isWhere
Doerner engineThe live keygen + signing protocol for user keys; no pre-computationnode3 deployment (/k1/d/ws, /k1/d/sign)
mpc.wasm + Web WorkersThe device-side parties in the browser (two per user)Frontend, served as static assets
mpcium (github.com/fystack/mpcium)The MPC engine and node cluster used by engine mode; also ships our platform-party gatewaySibling checkout, wired into wallet-api by a local replace
fystack/tss-lib/v2 v2.0.3Threshold-signature library behind mpcium sessions: ECDSA/secp256k1 and EdDSA/Ed25519. A pinned fork of bnb-chain/tss-libmpcium
HSM keystoreDigest-mode signer for the platform keys; also KEK/DEK unwrapping of the platform share at restExternal service
NATS (+ JetStream)Cluster messaging: keygen/sign requests, results, inter-node protocol trafficmpcium
ConsulNode discovery, readiness, wallet metadatampcium
BadgerDB + ageEncrypted local share storage per node, with periodic encrypted backupsmpcium
AWS KMSOptional signer for the event-initiator key instead of a local Ed25519/P256 keympcium client

The platform-party gateway

mpcium ships cmd/mpc-gateway, the device-facing endpoint for the platform's own party — "the endpoint older code called node3", and not a fourth cluster node. It serves GET /k1/healthz and GET /k1/ws, resolves the platform share per wallet, and co-signs a digest with the device over one socket. In dev the share resolver reads a plaintext {walletID: shareJSON} file (MPC_GATEWAY_SHARE_FILE); in production shares are unwrapped through the HSM KEK/DEK path so share3 never rests in plaintext.

Evaluation lanes (not in any live path)

A provider seam (pkg/cryptoengine + per-wallet engine selection) exists so a keygen or sign request can name an engine other than the default. It fails closed:

CandidateProtocolsStatus
Taurus multi-party-sig (pinned commit)CMP/CGGMP ECDSA (secp256k1), FROST Schnorr / BIP340 Taproot, 2P ECDSAIn-process Go lane; routed only when MPCIUM_ENABLE_TAURUS_CMP is set truthy
Coinbase cb-mpc2P/MP ECDSA, EdDSA (Ed25519), SchnorrSidecar spike; benchmark/audit gate
Fireblocks mpc-lib, Silence DKLs23 / Schnorr—Descriptors only; license gate

tss-lib stays the default and nothing flips implicitly: a legacy request with no engine named routes to tss-lib, and the engine field is covered by the request's signed payload so it cannot be flipped in flight onto a different key namespace. Multi-chain lanes (BTC Taproot via FROST/Schnorr, Solana via Ed25519) live in this evaluation tier, not in the wallet-api user flow, which is secp256k1/EVM only.

Security posture on the crypto pins

Verichains' TSSHOCK disclosure (Black Hat USA 2023) broke GG18/GG20-era threshold-ECDSA implementations through unsound ZK-proof implementations (ambiguous Fiat-Shamir transcript encoding, single-challenge composite-order proofs, reduced dlnproof iterations). Both library pins postdate the fixes:

  • fystack/tss-lib/v2 v2.0.3 carries the hardened transcript encoding (per-element length prefixes, block-count prefix) and dlnproof at 128 iterations.
  • The pinned taurusgroup/multi-party-sig commit (2025-08) postdates its 2023 fix and uses a domain-separated, length-delimited transcript.

The standing TSSHOCK guidance is to rotate wallets created on pre-fix versions; all wallets here postdate the fixed pins.

9. Recovery and the reshare gap

  • mpcium / tss-lib wallets support key resharing: a lost share is replaced by a new one derived with the surviving parties, keeping the same public key and address, and without ever reconstructing the key. See mpcium's docs/key-resharing-overview.md for the user-facing model and docs/key-resharing-vs-restoring-overview.md for the reshare-vs-restore trade-offs.
  • CMP (Taurus) wallets cannot be reshared at the pinned commit: the library implements same-committee refresh only, so a share-less party can never be onboarded. Committee-changing reshare is a missing protocol, not an integration gap. CreateReshareSession fails closed with an explicit error, and recovery from party loss means sweeping to a new wallet — an on-chain migration for an EVM account. This is one reason CMP is not promoted by default.

10. Configuration reference

VarPurpose
MPC_NODE3_URLnode3 base URL, e.g. https://blockchain09.satschel.com/mpc. Unset ⇒ mpc-config and both relays report 501.
MPC_NODE3_JWT_SECRETShared HS256 secret for minting per-party node3 tokens.
MPC_NODE3_STATIC_TOKENPre-issued node3 token used instead of minting. Temporary — see §5.
WALLET_API_KEYGates the sensitive routes and both relay sockets. Empty disables auth (dev).
WALLET_MPC_MODEengine to enable server-side mpcium signing; unset for the device/node3 flow.
WALLET_MPC_NATS_URLEngine mode: the mpcium cluster's NATS endpoint.
WALLET_MPC_INITIATOR_KEYEngine mode: the event-initiator key the nodes authorize.
WALLET_MPC_DEV_KEY_HEXDev-only in-process signing key.
WALLET_ALLOW_DEV_KEYS1 to permit well-known dev keys as platform signers (throwaway chains only).
WALLET_HSM_URL + WALLET_HSM_{ADMIN,EXECUTOR,GUARDIAN}_{LABEL,ADDRESS}The HSM-backed platform signers.

11. Failure modes

SymptomCauseFix
501 on mpc-config / relay / signMPC_NODE3_URL or the node3 credential is unsetSet MPC_NODE3_URL + MPC_NODE3_JWT_SECRET (or the static token)
400 sid and party are requiredThe device opened the socket without ceremony paramsRead them from mpc-config; pass sid + party (+ parties / signers)
502 dial node3: ...node3 unreachable or wrong base URLCheck MPC_NODE3_URL and network egress. wallet-api dials node3 before upgrading the device socket precisely so this is a clean HTTP error
websocket: bad handshake (server) / bare "websocket error" (browser)node3 rejected the token — usually a secret mismatchAlign MPC_NODE3_JWT_SECRET with the deployment, or set MPC_NODE3_STATIC_TOKEN as a stopgap
Relay drops mid-ceremonyEither side closed; both pumps end on the first errorRetry with a fresh sid; check for a timeout middleware wrapping the WS routes (they must be mounted outside it)
Engine-mode signs time out for some walletsMore than one result subscriber load-balancing a durable consumerUse exactly one MpciumHub per process and mint per-wallet signers from it
POST /wallet rejected with "user_address is required"The keygen ceremony has not run, or its address was not carried throughRun the device keygen first and pass the resulting address