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.
| Party | Holds | Where it runs |
|---|---|---|
k1-share1 | share 1 | The user's device (browser Web Worker / mobile) |
k1-share2 | share 2 | The user's device — usually kept out of signing as a cold backup |
k1-share3 | share 3 | node3, 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/configat the browser edge) and uses therelay_path,sign_path,partiesandthresholdit 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.
| Ceremony | wallet-api path | node3 path | Query args the device supplies |
|---|---|---|---|
| Keygen (DKG) | GET /wallet/mpc/relay (WebSocket) | /k1/d/ws | sid, party, parties, platform |
| Signing | GET /wallet/mpc/sign (WebSocket) | /k1/d/sign | sid, 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
- The device opens one relay socket per party it runs (
share1,share2), passing a shared session id (sid). - 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. - The three parties run distributed key generation. The device ends up with two share files; node3 keeps the third.
- The device now has a public key and an Ethereum address — the
user_address. No private key was ever assembled anywhere. - The device (via the gateways) calls
POST /walletwith thatuser_address, and wallet-api deploys the on-chain wallet around it. See workflows.
Signing, step by step
- 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-bytesign_hash(and, for orders, anorder_nonce). - The device opens
GET /wallet/mpc/signfor its signing party, passing the digest asmsgand the wallet public key aswallet. - 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. - 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/preparamsno longer exists on wallet-api or ta-api, andmpc-configno 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.
| Credential | Who checks it | Notes |
|---|---|---|
WALLET_API_KEY | wallet-api | Authorization: Bearer, X-API-Key, or ?token= (a WebSocket handshake cannot set headers). Empty disables auth — dev only. |
| node3 token | node3 | Minted 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_TOKENis a stopgap. The Doerner node3 deployment signs with a secret we were not given, so tokens minted fromMPC_NODE3_JWT_SECRETcome back401 unauthorized: bad signature— which surfaces aswebsocket: bad handshakein 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 asubthat cannot identify the caller. Clear it the momentMPC_NODE3_JWT_SECRETmatches the deployment.
What each hop can see
| Hop | Sees a share? | Decodes protocol frames? | Holds the node3 secret? |
|---|---|---|---|
| Browser / device | Yes — share1, share2 | Yes (it is two parties) | No |
| liq-ats | No | No | No |
| ta-api | No | No | No |
| wallet-api | No | No | Yes (mints per-party tokens) |
| node3 | Yes — share3 only | Yes | n/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.
| Mode | Who signs the user key | Config | Used for |
|---|---|---|---|
| dev | Deterministic in-process dev keys | WALLET_MPC_DEV_KEY_HEX, WALLET_ALLOW_DEV_KEYS=1 | Local testing against Anvil |
| node3 (device) | Device (share1+share2) + node3 (share3), 2-of-3 | MPC_NODE3_URL + MPC_NODE3_JWT_SECRET | The real user-facing flow |
| engine | wallet-api co-signs server-side via an mpcium cluster | WALLET_MPC_MODE=engine, WALLET_MPC_NATS_URL, WALLET_MPC_INITIATOR_KEY | Server-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.MpciumHubtherefore subscribes once and fans results out to per-wallet waiters byWalletID(keygen) /TxID(sign). - Async, event-driven.
CreateWalletpublishes 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:
| Signer | Role | Config |
|---|---|---|
ta-admin | Deployer / owner / agent of the ERC-3643 backbone | WALLET_HSM_ADMIN_LABEL + _ADDRESS |
asset-executor | V42 executor, settlement executor, submits fillBatch | WALLET_HSM_EXECUTOR_LABEL + _ADDRESS |
guardian | Every wallet's guardian | WALLET_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
| Component | What it is | Where |
|---|---|---|
| Doerner engine | The live keygen + signing protocol for user keys; no pre-computation | node3 deployment (/k1/d/ws, /k1/d/sign) |
mpc.wasm + Web Workers | The 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 gateway | Sibling checkout, wired into wallet-api by a local replace |
fystack/tss-lib/v2 v2.0.3 | Threshold-signature library behind mpcium sessions: ECDSA/secp256k1 and EdDSA/Ed25519. A pinned fork of bnb-chain/tss-lib | mpcium |
| HSM keystore | Digest-mode signer for the platform keys; also KEK/DEK unwrapping of the platform share at rest | External service |
| NATS (+ JetStream) | Cluster messaging: keygen/sign requests, results, inter-node protocol traffic | mpcium |
| Consul | Node discovery, readiness, wallet metadata | mpcium |
BadgerDB + age | Encrypted local share storage per node, with periodic encrypted backups | mpcium |
| AWS KMS | Optional signer for the event-initiator key instead of a local Ed25519/P256 key | mpcium 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:
| Candidate | Protocols | Status |
|---|---|---|
Taurus multi-party-sig (pinned commit) | CMP/CGGMP ECDSA (secp256k1), FROST Schnorr / BIP340 Taproot, 2P ECDSA | In-process Go lane; routed only when MPCIUM_ENABLE_TAURUS_CMP is set truthy |
Coinbase cb-mpc | 2P/MP ECDSA, EdDSA (Ed25519), Schnorr | Sidecar 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.3carries the hardened transcript encoding (per-element length prefixes, block-count prefix) anddlnproofat 128 iterations.- The pinned
taurusgroup/multi-party-sigcommit (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.mdfor the user-facing model anddocs/key-resharing-vs-restoring-overview.mdfor 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.
CreateReshareSessionfails 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
| Var | Purpose |
|---|---|
MPC_NODE3_URL | node3 base URL, e.g. https://blockchain09.satschel.com/mpc. Unset ⇒ mpc-config and both relays report 501. |
MPC_NODE3_JWT_SECRET | Shared HS256 secret for minting per-party node3 tokens. |
MPC_NODE3_STATIC_TOKEN | Pre-issued node3 token used instead of minting. Temporary — see §5. |
WALLET_API_KEY | Gates the sensitive routes and both relay sockets. Empty disables auth (dev). |
WALLET_MPC_MODE | engine to enable server-side mpcium signing; unset for the device/node3 flow. |
WALLET_MPC_NATS_URL | Engine mode: the mpcium cluster's NATS endpoint. |
WALLET_MPC_INITIATOR_KEY | Engine mode: the event-initiator key the nodes authorize. |
WALLET_MPC_DEV_KEY_HEX | Dev-only in-process signing key. |
WALLET_ALLOW_DEV_KEYS | 1 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
| Symptom | Cause | Fix |
|---|---|---|
501 on mpc-config / relay / sign | MPC_NODE3_URL or the node3 credential is unset | Set MPC_NODE3_URL + MPC_NODE3_JWT_SECRET (or the static token) |
400 sid and party are required | The device opened the socket without ceremony params | Read them from mpc-config; pass sid + party (+ parties / signers) |
502 dial node3: ... | node3 unreachable or wrong base URL | Check 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 mismatch | Align MPC_NODE3_JWT_SECRET with the deployment, or set MPC_NODE3_STATIC_TOKEN as a stopgap |
| Relay drops mid-ceremony | Either side closed; both pumps end on the first error | Retry 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 wallets | More than one result subscriber load-balancing a durable consumer | Use 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 through | Run the device keygen first and pass the resulting address |
Workflows
Everything wallet-api does: MPC wallet provisioning, ERC-3643 identity onboarding, asset lifecycle, dual-intent trade & settlement, and the MPC ceremony.
Third-Party Services & Libraries
Every external service and library wallet-api touches: the EVM chain, node3/mpcium, the HSM keystore, PostgreSQL, and key Go libraries.