mirror of
https://github.com/hanzoai/mpc.git
synced 2026-10-30 19:45:28 +00:00
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.
49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package infra
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/hashicorp/consul/api"
|
|
"github.com/spf13/viper"
|
|
|
|
"github.com/hanzoai/mpc/pkg/constant"
|
|
"github.com/hanzoai/mpc/pkg/logger"
|
|
)
|
|
|
|
type ConsulKV interface {
|
|
Put(kv *api.KVPair, options *api.WriteOptions) (*api.WriteMeta, error)
|
|
Get(key string, options *api.QueryOptions) (*api.KVPair, *api.QueryMeta, error)
|
|
Delete(key string, options *api.WriteOptions) (*api.WriteMeta, error)
|
|
List(prefix string, options *api.QueryOptions) (api.KVPairs, *api.QueryMeta, error)
|
|
}
|
|
|
|
func GetConsulClient(environment string) *api.Client {
|
|
config := api.DefaultConfig()
|
|
if environment != constant.EnvProduction {
|
|
config.Scheme = "http"
|
|
} else {
|
|
config.Scheme = "https"
|
|
config.Token = viper.GetString("consul.token")
|
|
config.HttpAuth = &api.HttpBasicAuth{
|
|
Username: viper.GetString("consul.username"),
|
|
Password: viper.GetString("consul.password"),
|
|
}
|
|
}
|
|
|
|
config.Address = viper.GetString("consul.address")
|
|
config.WaitTime = 10 * time.Second
|
|
// Ping the Consul server to verify connectivity
|
|
|
|
client, err := api.NewClient(config)
|
|
if err != nil {
|
|
logger.Fatal("Failed to create consul client", err)
|
|
}
|
|
|
|
_, err = client.Status().Leader()
|
|
if err != nil {
|
|
logger.Fatal("failed to connect to Consul", err)
|
|
}
|
|
|
|
return client
|
|
}
|