Files
zeekay 19b49809fd Implement threshold MPC signing with CGGMP21, FROST, and LSS protocols
This commit adds complete multi-party computation (MPC) threshold signing
for multiple cryptographic protocols:

CGGMP21 (ECDSA/secp256k1):
- Key generation for Bitcoin/Ethereum/EVM chains
- Threshold signing with t-of-n security
- Recovery byte calculation for Ethereum compatibility

FROST/Taproot (EdDSA/BIP-340):
- EdDSA key generation for Solana/Sui/Polkadot
- BIP-340 compatible Schnorr signatures (64 bytes)
- CBOR serialization for TaprootConfig crypto types

LSS (Linear Secret Sharing):
- Dynamic resharing support (change participants)
- ECDSA signing with blinding protocol
- Protocol adapter for unified interface

Key fixes:
- Use MarshalBinary/UnmarshalBinary for protocol messages
- CBOR serialization for FROST TaprootConfig (not JSON)
- Correct type assertion for taproot.Signature ([]byte)
- Sorted party IDs for deterministic ordering

E2E tests pass for both ECDSA and EdDSA signing.
2026-01-24 23:41:43 -08:00

41 lines
1.1 KiB
Go

package event
const (
KeygenBrokerStream = "mpc-keygen"
KeygenConsumerStream = "mpc-keygen-consumer"
KeygenRequestTopic = "mpc.keygen_request.*"
)
type KeygenResultEvent struct {
WalletID string `json:"wallet_id"`
ECDSAPubKey []byte `json:"ecdsa_pub_key"`
EDDSAPubKey []byte `json:"eddsa_pub_key"`
ResultType ResultType `json:"result_type"`
ErrorReason string `json:"error_reason"`
ErrorCode string `json:"error_code"`
}
// CreateKeygenSuccess creates a successful keygen event
func CreateKeygenSuccess(walletID string, pubKeyHex string, metadata map[string]any) *KeygenResultEvent {
return &KeygenResultEvent{
WalletID: walletID,
ECDSAPubKey: []byte(pubKeyHex),
ResultType: ResultTypeSuccess,
}
}
// CreateKeygenFailure creates a failed keygen event
func CreateKeygenFailure(walletID string, metadata map[string]any) *KeygenResultEvent {
errorMsg := ""
if err, ok := metadata["error"].(string); ok {
errorMsg = err
}
return &KeygenResultEvent{
WalletID: walletID,
ResultType: ResultTypeError,
ErrorReason: errorMsg,
ErrorCode: string(ErrorCodeKeygenFailure),
}
}