Thin participant-side SDK on top of tss-lib, designed to run with an external Orchestrator/relay architecture.
Current supported runtime flow:
SessionStartis created by Orchestrator.- Orchestrator sends
KeyExchangeBegin(exchange_id). - Participants exchange signed
key_exchange_hellomessages. - Orchestrator sends
MPCBegin. - SDK runs
keygen/signrounds viatss-lib. - Direct MPC packets are encrypted (E2E); broadcast packets are signed only.
- Protocols:
ECDSA,EdDSA - Operations:
KEYGEN,SIGN - Participant session API:
Start()HandleControl(*protocol.ControlMessage)HandlePeer(*protocol.PeerMessage)Status()
- Security model:
- Control + peer messages are signature-verified
- Direct MPC packet:
encrypt + nonce + sign - Broadcast MPC packet:
signonly (no encryption, nonce must be empty)
participant: main SDK runtimeprotocol: JSON contracts, validation, signing bytesapi/gateway/v1: external cosigner gateway gRPC stream contractinternal/wirecrypto: direct packet key exchange/encryption helpersidentity: identity lookup/signing interfacesstorage: share/preparams/session-checkpoint interfaces
This SDK owns shared participant runtime contracts, not service-specific orchestration APIs.
Owned by SDK:
- signed MPC runtime wire messages in
protocol - participant runtime state machine in
participant - host-provided identity/storage interfaces
- external cosigner gateway stream API in
api/gateway/v1
Not owned by SDK:
- orch client APIs such as keygen/sign request submission
- orch request response envelopes such as accepted/rejected responses
- Apex registry, cosigner revoke records, public key version records, or wallet session storage models
- service transport choices such as NATS subjects or HTTP routes
- mobile app/runtime packaging; that now lives in
cosigner-mobile
If a type is needed because multiple participant runtimes must parse, validate, sign, or verify the same bytes, it belongs in SDK. If a type describes service admission, product state, storage, or backend client submission, it belongs in that service repo.
Mobile-specific bindings and app runtime live in the sibling
cosigner-mobile repo. Its gomobile module imports this SDK for the shared MPC
runtime contracts.
For private GitHub modules in the same org, configure Go to skip the public module proxy and let Git rewrite HTTPS module fetches to SSH:
go env -w GOPRIVATE=github.com/fystack/*
git config --global url."git@github.com:fystack/".insteadOf "https://github.com/fystack/"Below is a minimal orchestrator-to-participant integration skeleton.
package main
import (
"crypto/ed25519"
"fmt"
"github.com/fystack/mpcium-sdk/participant"
"github.com/fystack/mpcium-sdk/protocol"
)
// 1) Implement required interfaces:
// - identity.LocalIdentity
// - identity.PeerLookup
// - identity.OrchestratorLookup
// - storage.PreparamsStore / ShareStore / SessionCheckpointStore
func runSession(
start *protocol.SessionStart,
localID string,
cfg participant.Config,
sendPeer func(msgs []*protocol.PeerMessage) error,
sendEvent func(events []*protocol.SessionEvent) error,
) error {
sess, err := participant.New(cfg)
if err != nil {
return err
}
// Local start emits joined/ready events.
effects, err := sess.Start()
if err != nil {
return err
}
if err := sendPeer(effects.PeerMessages); err != nil {
return err
}
if err := sendEvent(effects.SessionEvents); err != nil {
return err
}
// 2) Handle control from Orchestrator:
// a) KeyExchangeBegin (required)
// b) MPCBegin (only after key exchange done)
handleControl := func(ctrl *protocol.ControlMessage) error {
effects, err := sess.HandleControl(ctrl)
if err != nil {
return err
}
if err := sendPeer(effects.PeerMessages); err != nil {
return err
}
if err := sendEvent(effects.SessionEvents); err != nil {
return err
}
if effects.Result != nil {
fmt.Printf("session result ready: %+v\n", effects.Result)
}
return nil
}
// 3) Handle peer messages routed by transport:
handlePeer := func(peer *protocol.PeerMessage) error {
effects, err := sess.HandlePeer(peer)
if err != nil {
return err
}
if err := sendPeer(effects.PeerMessages); err != nil {
return err
}
if err := sendEvent(effects.SessionEvents); err != nil {
return err
}
if effects.Result != nil {
fmt.Printf("session result ready: %+v\n", effects.Result)
}
return nil
}
_ = handleControl
_ = handlePeer
return nil
}
// Orchestrator signing reminder:
// - Build control payload using protocol.ControlSigningBytes(msg)
// - Sign bytes with orchestrator private key (ed25519)
func signControl(priv ed25519.PrivateKey, msg *protocol.ControlMessage) error {
payload, err := protocol.ControlSigningBytes(msg)
if err != nil {
return err
}
msg.Signature = ed25519.Sign(priv, payload)
return nil
}The participant runtime expects this sequence:
SessionStart(in config)KeyExchangeBegin{exchange_id}- Exchange peer
KeyExchangeHellountil ready MPCBegin
If MPCBegin arrives before key exchange is completed, the session fails with missing prerequisite.
ECDSA keygen now requires a slot-based preparams store. The legacy single-cache model is removed.
PreparamsStoremust implement:LoadPreparamsSlot(protocol, slot)SavePreparamsSlot(protocol, slot, blob)LoadActivePreparamsSlot(protocol)SaveActivePreparamsSlot(protocol, slot)
- Runtime behavior:
- Session resolves preparams with
pinned_slot -> active_slotand fails fast on missing/invalid blobs. - Each session pins one slot in its local
SessionCheckpoint, so in-flight sessions are deterministic across global rotates. - Successful ECDSA keygen writes new preparams to slot
next, then rotates active pointer atomically and snapshots previous active into slotprev.
- Session resolves preparams with
- Integrator requirements:
- Seed at least one valid slot and set
active_slotbefore running ECDSA keygen. - Update any existing preparams backend to the slot-aware API before upgrading SDK.
- Seed at least one valid slot and set
- Every
ControlMessageandPeerMessagemust carry a valid signature. - For direct
PeerMessagewithMPCPacket:broadcast=falseto_participant_idrequirednoncerequired
- For broadcast
PeerMessagewithMPCPacket:broadcast=trueto_participant_idmust be emptynoncemust be empty
RESHAREis not implemented yet.- Mobile bindings and app integration live in
cosigner-mobile.