Files
zeekay 7620698a36 feat: sr25519 threshold signing for Polkadot/Substrate
MPC daemon now supports sr25519 (Schnorrkel) key generation and
threshold signing using FROST over the ristretto255 group.

New files:
- pkg/mpc/sr25519_keygen_session.go — threshold keygen
- pkg/mpc/sr25519_signing_session.go — threshold signing
- pkg/mpc/sr25519_config_marshal.go — CBOR serialization
- pkg/mpc/ristretto255.go — local curve implementation
- pkg/eventconsumer/signing_handler_sr25519.go — event routing

Wiring:
- KeyTypeSR25519 constant + session type
- Event consumer routes sr25519 keygen/signing events
- API accepts "sr25519" as valid protocol
- DOT/KSM network codes mapped to sr25519 key type
- Signing context configurable (default "substrate")

14 tests passing.
2025-12-27 21:41:32 -08:00

74 lines
1.9 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package eventconsumer
import "encoding/json"
type KeyType string
const (
KeyTypeSecp256k1 KeyType = "secp256k1"
KeyTypeEd25519 KeyType = "ed25519"
KeyTypeSR25519 KeyType = "sr25519"
)
// InitiatorMessage is anything that carries a payload to verify and its signature.
type InitiatorMessage interface {
// Raw returns the canonical byte‐slice that was signed.
Raw() ([]byte, error)
// Sig returns the signature over Raw().
Sig() []byte
// InitiatorID returns the ID whose public key we have to look up.
InitiatorID() string
}
type GenerateKeyMessage struct {
WalletID string `json:"wallet_id"`
Signature []byte `json:"signature"`
}
type SignTxMessage struct {
KeyType KeyType `json:"key_type"`
WalletID string `json:"wallet_id"`
NetworkInternalCode string `json:"network_internal_code"`
TxID string `json:"tx_id"`
Tx []byte `json:"tx"`
Signature []byte `json:"signature"`
}
func (m *SignTxMessage) Raw() ([]byte, error) {
// omit the Signature field itself when computing the signed‐over data
payload := struct {
KeyType KeyType `json:"key_type"`
WalletID string `json:"wallet_id"`
NetworkInternalCode string `json:"network_internal_code"`
TxID string `json:"tx_id"`
Tx []byte `json:"tx"`
}{
KeyType: m.KeyType,
WalletID: m.WalletID,
NetworkInternalCode: m.NetworkInternalCode,
TxID: m.TxID,
Tx: m.Tx,
}
return json.Marshal(payload)
}
func (m *SignTxMessage) Sig() []byte {
return m.Signature
}
func (m *SignTxMessage) InitiatorID() string {
return m.TxID
}
func (m *GenerateKeyMessage) Raw() ([]byte, error) {
return []byte(m.WalletID), nil
}
func (m *GenerateKeyMessage) Sig() []byte {
return m.Signature
}
func (m *GenerateKeyMessage) InitiatorID() string {
return m.WalletID
}