Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ $ mpcium start -n node2

Mpcium supports flexible client authentication through a signer interface, allowing you to use either local keys or AWS KMS for signing operations.

#### Client ID (Result Routing)

When multiple client instances connect to the same MPC cluster, each client **must** set a unique `ClientID` to avoid result routing conflicts. Without distinct client IDs, two clients requesting operations concurrently may race for the same result message, causing one client to receive the other's response.

- `ClientID` scopes the NATS consumer and result subject so each client only receives its own results.
- Allowed characters: alphanumeric, hyphens, and underscores (e.g. `"backend-svc-1"`, `"mobile_api"`).
- If you only run a single client instance, `ClientID` can be omitted (empty string).

#### Local Signer (Ed25519)

```go
Expand Down Expand Up @@ -193,10 +201,11 @@ func main() {
logger.Fatal("Failed to create local signer", err)
}

// Create MPC client with signer
// Create MPC client with signer and a unique client ID
mpcClient := client.NewMPCClient(client.Options{
NatsConn: natsConn,
Signer: localSigner,
ClientID: "backend-svc-1", // unique per client instance
})

// Handle wallet creation results
Expand Down Expand Up @@ -253,6 +262,7 @@ func main() {
mpcClient := client.NewMPCClient(client.Options{
NatsConn: natsConn,
Signer: kmsSigner,
ClientID: "kms-client-1", // unique per client instance
})
// ... rest of the client code
}
Expand Down
6 changes: 6 additions & 0 deletions cmd/mpcium-cli/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ func benchmarkCommand() *cli.Command {
Value: false,
Category: "authentication",
},
&cli.StringFlag{
Name: "client-id",
Usage: "Client ID for result routing (scopes results to this client instance)",
Category: "configuration",
},
&cli.BoolFlag{
Name: "debug",
Usage: "Enable debug logging",
Expand Down Expand Up @@ -244,6 +249,7 @@ func createMPCClient(cmd *cli.Command) (client.MPCClient, error) {
opts := client.Options{
NatsConn: nc,
Signer: signer,
ClientID: cmd.String("client-id"),
}
return client.NewMPCClient(opts), nil
}
Expand Down
12 changes: 4 additions & 8 deletions cmd/mpcium/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,13 @@ func runNode(ctx context.Context, c *cli.Command) error {
}

directMessaging := messaging.NewNatsDirectMessaging(natsConn)
mqManager := messaging.NewNATsMessageQueueManager("mpc", []string{
"mpc.mpc_keygen_result.*",
event.SigningResultTopic,
"mpc.mpc_reshare_result.*",
}, natsConn)
mqManager := messaging.NewNATsMessageQueueManager("mpc", event.ResultStreamSubjects(), natsConn)

genKeyResultQueue := mqManager.NewMessageQueue("mpc_keygen_result")
genKeyResultQueue := mqManager.NewMessageQueue("mpc_keygen_result", event.KeygenResultSubscriptionSubject(""))
defer genKeyResultQueue.Close()
singingResultQueue := mqManager.NewMessageQueue("mpc_signing_result")
singingResultQueue := mqManager.NewMessageQueue("mpc_signing_result", event.SigningResultSubscriptionSubject(""))
defer singingResultQueue.Close()
reshareResultQueue := mqManager.NewMessageQueue("mpc_reshare_result")
reshareResultQueue := mqManager.NewMessageQueue("mpc_reshare_result", event.ReshareResultSubscriptionSubject(""))
defer reshareResultQueue.Close()

logger.Info("Starting mpcium node", "version", Version, "ID", nodeID, "name", nodeName)
Expand Down
1 change: 1 addition & 0 deletions e2e/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ func (s *E2ETestSuite) SetupMPCClient(t *testing.T) {
mpcClient := client.NewMPCClient(client.Options{
NatsConn: s.natsConn,
Signer: localSigner,
ClientID: "e2e-suite",
})
s.mpcClient = mpcClient
t.Log("MPC client created")
Expand Down
2 changes: 1 addition & 1 deletion e2e/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/fystack/mpcium/e2e

go 1.25.5
go 1.25.8

require (
github.com/bnb-chain/tss-lib/v2 v2.0.2
Expand Down
Loading
Loading