Designing Sunder: Threshold Signing Where the Key Never Comes Back Together
Reading time: 10 minutesEvery system that moves value eventually has to sign something: a bridge withdrawal, an oracle attestation, a treasury payout. Most of the time that signature comes from one private key on one machine. If that machine is compromised at the wrong moment, everything that key controls is gone.
Sunder is my attempt at a different shape for that problem. It is self-hosted threshold signing infrastructure: the key is split across N nodes, any T of them can produce a signature together, and the full key is never assembled anywhere during signing. I built it over a weekend in March 2026 for the Shape Rotator Virtual Hackathon (Cryptographic Primitives track), on top of Thetacrypt, a Rust threshold cryptography library from IC3 researchers.
This post is about the system around the math: the threat model, why threshold signatures, how the aggregator works, and where the design is still weak.
What Sunder is, and what it is not
I did not implement any threshold cryptography myself. Thetacrypt provides the primitives: key generation via its thetacli tool, partial signing, share assembly and verification for schemes such as BLS04 and FROST. What it does not provide is a deployment story. There is no HTTP interface, no key naming, no audit trail and no client SDK.
Sunder is that missing layer. It is a Cargo workspace with five crates:
sunder-core: shared request/response types, errors, and an append-only audit logsunder-node: a signing node that loads one key share and exposes/partial-signsunder-aggregator: the public API that fans out to nodes and assembles the resultsunder-cli: an operator CLI forsign,verify,keysandhealthsdk/sunder-client: a small Rust client for applications
The default cluster is 3-of-5 BLS04 on BLS12-381, run with Docker Compose.
The threat model
I find it useful to write down what the attacker can do before talking about architecture. For Sunder I assumed:
- An attacker can fully compromise some signing nodes: read memory, read disk, run arbitrary code.
- Nodes fail independently: crashes, restarts, network partitions, slow disks.
- The network between nodes is not trusted for confidentiality, but nothing secret crosses it during signing. Only messages and partial signatures do.
- Key shares are distributed offline at setup, not over the network.
The goal is two properties:
- Safety: compromising up to T−1 nodes reveals nothing useful about the signing key and does not let the attacker produce signatures.
- Liveness: signing keeps working with up to N−T nodes offline.
With 3-of-5, two nodes can be compromised without losing safety, and two can be down without losing liveness. T is the knob that trades one against the other.
Why threshold signatures
There are three common alternatives, and I want to be precise about why I did not pick them.
| Approach | Where the key lives | What one compromised signer exposes | What the verifier sees |
|---|---|---|---|
| Single hot key | One machine | Everything | One signature |
| On-chain multisig | N complete keys | One complete key | N signatures plus contract logic |
| Threshold signature | N shares, never combined | One useless share | One ordinary signature |
Multisig gives you T-of-N authorization, but each signer holds a complete private key. It is also chain-specific: the threshold logic lives in a contract, and every round costs gas.
Threshold signatures move the T-of-N logic into the cryptography. With BLS04, each node computes a partial signature from its share, and the shares combine into one signature that verifies against one public key. The verifier does not know or care that five machines were involved. That makes the output portable: the same signature can be checked off-chain or, in principle, on-chain through the BLS12-381 precompiles from EIP-2537.
MPC wallets are the closest relative. “MPC” usually means threshold ECDSA or Schnorr protocols, often with multiple interactive rounds between parties. I chose BLS04 specifically because it is non-interactive: each node signs independently with no communication between nodes and no per-session nonce state. That single property is what keeps the coordinator simple, and I will come back to it.
Architecture
flowchart LR
APP["Client application"] -->|"POST /v1/sign/key"| AGG["sunder-aggregator"]
AGG -->|"/partial-sign"| N1["Node 1 (share 1)"]
AGG -->|"/partial-sign"| N2["Node 2 (share 2)"]
AGG -->|"/partial-sign"| N3["Node 3 (share 3)"]
AGG -.->|"timeout"| N4["Node 4 (offline)"]
AGG -->|"/partial-sign"| N5["Node 5 (share 5)"]
AGG -->|"assemble T shares"| SIG["Final signature"]
The signing path, end to end:
- The client sends hex-encoded bytes to
POST /v1/sign/{key}. - The aggregator looks up the public key for
{key}and sends the same request to every node in parallel. - Each node calls Thetacrypt’s
partial_signwith its share and returns the ASN.1-encodedSignatureShareas hex. - The aggregator collects T shares and calls
ThresholdSignature::assemble. - It returns the signature and the list of nodes that participated.
The node side is deliberately tiny. This is the core of NodeSigner::partial_sign:
let mut params = ThresholdSignatureParams::new();
let signature_share =
ThresholdSignature::partial_sign(message, label, sk, &mut params)
.map_err(|e| SunderError::PartialSignFailed(format!("{:?}", e)))?;
let bytes = signature_share
.to_bytes()
.map_err(|e| SunderError::Serialization(format!("{:?}", e)))?;
A node loads its shares from a Thetacrypt keystore at startup. It never sees another node’s share and never talks to another node.
The aggregator: what it holds and what it can do
The aggregator holds only public keys. It loads them from a keystore at startup into a HashMap<String, PublicKey>, keyed by the Thetacrypt key ID. It is also stateless between requests, which matters for availability.
Two questions come up every time I explain this design.
Is the aggregator a single point of failure? For availability, yes, as deployed today: one container, one port. If it goes down, signing stops. But because it holds no secrets and no per-request state, the fix is ordinary: run several instances behind a load balancer, each pointing at the same node list. Nothing in the protocol prevents that. I have not built or tested that setup yet.
What can a malicious aggregator do? This is the more important question, and the honest answer is “more than I would like”. A compromised aggregator cannot learn the key or forge a signature on its own. But nodes in v0.1 sign whatever they are asked to sign. They do not authenticate the caller and they do not apply any policy to the message. So an attacker who controls the aggregator can ask T nodes to sign an arbitrary message and get a perfectly valid threshold signature back. It can also refuse to serve requests, drop specific ones, or return garbage to the client.
Threshold signing protects the key, not the authorization decision, and today that decision lives entirely in the aggregator. The README frames this as “the aggregator is trusted”. Splitting the key only protects against a compromised coordinator if each node independently decides whether a request is legitimate. That is the biggest gap in the current version.
Fan-out, timeouts and slow nodes
The fan-out is straightforward: one tokio::spawn per node, sharing a reqwest::Client built with a 5-second timeout.
for (i, node_url) in self.nodes.iter().enumerate() {
let client = self.client.clone();
let url = format!("{}/partial-sign", node_url);
let body = req_body.clone();
let node_idx = i + 1;
handles.push(tokio::spawn(async move {
let result = client.post(&url).json(&body).send().await;
(node_idx, result)
}));
}
Then the aggregator walks the handles and stops once it has T good responses. An unreachable node, a timeout, or a malformed body is logged and skipped. If fewer than T shares arrive, the request fails with not enough partial signatures: need 3, got 2. Refusing to sign is the correct failure mode.
There is a latency trade-off hidden in that loop that I want to be upfront about. The handles are awaited in node order, not in completion order. If node 1 is hung, the aggregator waits on it for up to the full 5-second timeout even if nodes 2, 3 and 4 answered immediately. Correctness is fine. Tail latency is not. The fix is to collect from a FuturesUnordered (or a JoinSet) so the first T responses win, and to cancel the stragglers once the threshold is met. In the current code, tasks for nodes beyond the threshold are simply left to finish in the background.
The 5-second timeout itself is a guess, not a measured value, and should be configurable.
This is also where the BLS04 choice pays off. Because signing is a single non-interactive round, a node that is slow or offline costs nothing except its own response. With FROST, nodes first commit to nonces and then sign in a second round over a fixed signer set. If one chosen signer disappears between rounds, the whole session restarts. Supporting FROST in Sunder would mean session state on nodes, a two-phase coordinator, and a real retry policy. The service layer would get much more complicated.
Key generation and distribution
Keys come from Thetacrypt’s trusted-dealer keygen. scripts/setup.sh runs it inside Thetacrypt’s Docker image:
./thetacli keygen \
-k=3 \
-n=5 \
--subjects Bls04-Bls12381 \
--output ./conf \
--new
This writes node1.keystore through node5.keystore into config/. The dealer generates the secret, splits it with Shamir secret sharing, and exits. So “the key never exists” needs a qualifier: it never exists during signing. At setup, one process held it in memory.
The Docker Compose demo takes a further shortcut that I want to name. Every container mounts the whole config/ directory read-only, and the aggregator reads its public key from node1.keystore, which also contains node 1’s private share. That is fine for a single-machine demo. In a real deployment, each node’s keystore must live only on that node, and the aggregator should get a public-key-only file. Thetacrypt already emits one under config/pub/.
The proper fix for the dealer is Distributed Key Generation (DKG), where no single party ever sees the whole secret. DKG and proactive share refresh (rotating shares without changing the public key) are both on the roadmap. Neither is implemented.
API design
The public surface is small on purpose:
GET /health: status and number of loaded keysGET /v1/keys: key names, scheme and thresholdPOST /v1/sign/{key}: body{ "message": "<hex>" }POST /v1/verify: body withkey_name,signature,message
A few decisions behind it:
- Keys are named in the path.
/v1/sign/{key}makes the key part of the resource, which is easy to route, log and later authorize per key. - Messages are opaque hex bytes. Sunder does not hash, frame or interpret anything. The application decides what it is signing, whether that is
keccak256(abi.encode(...))or raw transaction bytes. That keeps Sunder chain-agnostic, but it also means Sunder cannot apply semantic policy, which ties back to the aggregator trust problem. - The response includes
nodes_participated. Operators can see which nodes are actually doing the work, and the audit log records it for every request.
Every sign request, success or failure, goes to a JSONL audit log with the key name, message hex and participating nodes. It is append-only by convention, not tamper-evident, and write errors are silently ignored. I would revisit both before relying on it for forensics.
Testing
The honest state is that Sunder has no automated test suite. There are no #[test] functions in the workspace. Verification so far is the end-to-end demo in scripts/demo.sh, which:
- Checks health across all five nodes
- Signs a message and verifies it
- Stops two nodes and signs again
- Verifies the second signature against the same public key
- Brings the nodes back
The README also walks through the below-threshold case: stop three nodes, signing fails, start one, signing recovers. That exercises the property that matters most, but it is not a substitute for tests. What I would add first:
- Unit tests for the collection loop using mock nodes that hang, error or return malformed shares
- A test that a share from the wrong key or a corrupted share causes a clean failure. Today the aggregator does not verify the assembled signature before returning it, which I want to change.
- Property tests that any T-subset of shares assembles to a signature that verifies under the same public key
Limitations and next steps
Things v0.1 does not do, roughly in the order I would tackle them:
- Node-side authorization. Nodes should authenticate the aggregator (mTLS at minimum) and ideally check each request against a policy before signing. This is what turns the threshold into real protection against a compromised coordinator.
- API authentication. The error type has an
Unauthorizedvariant, but no auth check is wired into the aggregator yet. Right now anyone who can reach port 8080 can request signatures. - Completion-order collection and configurable timeouts in the fan-out.
- Verify before returning. Check the assembled signature against the public key and identify bad shares.
- TLS between aggregator and nodes.
- An on-chain verifier for BLS12-381 signatures using the EIP-2537 precompiles.
- Proactive share refresh, then DKG to remove the trusted dealer.
Takeaways
- Threshold signatures protect the key. They do not protect the decision to sign. If only the coordinator decides, the coordinator is your real trust boundary.
- Choosing a non-interactive scheme (BLS04) kept the coordinator stateless and made slow or offline nodes cheap. That choice shaped the whole service layer more than any line of Rust did.
- “The key never exists” is true during signing and false during trusted-dealer setup. Say which one you mean.
- A stateless, secret-free aggregator turns a security problem into an ordinary availability problem, and availability problems have well-known answers.
- The code is at github.com/dicethedev/Sunder. Issues and pushback on the trust model are welcome.