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

168 lines
4.0 KiB
Go

package main
import (
"context"
"fmt"
"log"
"os"
"github.com/urfave/cli/v3"
)
const (
// Version information
VERSION = "0.2.1"
)
func main() {
cmd := &cli.Command{
Name: "lux-mpc-cli",
Usage: "Lux MPC node management tools",
Commands: []*cli.Command{
{
Name: "generate-peers",
Usage: "Generate a new peers.json file",
Action: generatePeers,
Flags: []cli.Flag{
&cli.IntFlag{
Name: "number",
Aliases: []string{"n"},
Usage: "Number of nodes to generate",
Required: true,
},
&cli.StringFlag{
Name: "output",
Aliases: []string{"o"},
Usage: "Output file path",
Value: peersFileName,
},
},
},
{
Name: "register-peers",
Usage: "Register peers from a JSON file to Consul",
Action: registerPeers,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "input",
Aliases: []string{"i"},
Usage: "Input peers JSON file path (default: peers.json)",
Value: peersFileName,
},
&cli.StringFlag{
Name: "environment",
Aliases: []string{"e"},
Usage: "Environment (development, production, etc.)",
Value: os.Getenv("ENVIRONMENT"),
},
},
},
{
Name: "generate-identity",
Usage: "Generate identity files with optional Age-encrypted private keys for a node",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "node",
Aliases: []string{"n"},
Usage: "Node name (e.g., node0)",
Required: true,
},
&cli.StringFlag{
Name: "peers",
Aliases: []string{"p"},
Value: peersFileName,
Usage: "Path to peers.json file",
},
&cli.StringFlag{
Name: "output-dir",
Aliases: []string{"o"},
Value: "identity",
Usage: "Output directory for identity files",
},
&cli.BoolFlag{
Name: "encrypt",
Aliases: []string{"e"},
Value: false,
Usage: "Encrypt private key with Age (recommended for production)",
},
&cli.BoolFlag{
Name: "overwrite",
Aliases: []string{"f"},
Value: false,
Usage: "Overwrite identity files if they already exist",
},
},
Action: generateIdentity,
},
{
Name: "generate-initiator",
Usage: "Generate identity files for an event initiator node",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "node-name",
Aliases: []string{"n"},
Value: "event_initiator",
Usage: "Name for the initiator node",
},
&cli.StringFlag{
Name: "output-dir",
Aliases: []string{"o"},
Value: ".",
Usage: "Output directory for identity files",
},
&cli.BoolFlag{
Name: "encrypt",
Aliases: []string{"e"},
Value: false,
Usage: "Encrypt private key with Age (recommended for production)",
},
&cli.BoolFlag{
Name: "overwrite",
Aliases: []string{"f"},
Value: false,
Usage: "Overwrite identity files if they already exist",
},
},
Action: generateInitiatorIdentity,
},
{
Name: "recover",
Usage: "Recover database from encrypted backup files",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "backup-dir",
Aliases: []string{"b"},
Usage: "Directory containing encrypted backup files",
Required: true,
},
&cli.StringFlag{
Name: "recovery-path",
Aliases: []string{"r"},
Usage: "Target path for database recovery",
Required: true,
},
&cli.BoolFlag{
Name: "force",
Aliases: []string{"f"},
Value: false,
Usage: "Force overwrite if recovery path already exists",
},
},
Action: recoverDatabase,
},
{
Name: "version",
Usage: "Display detailed version information",
Action: func(ctx context.Context, c *cli.Command) error {
fmt.Printf("lux-mpc-cli version %s\n", VERSION)
return nil
},
},
},
}
if err := cmd.Run(context.Background(), os.Args); err != nil {
log.Fatal(err)
}
}