Files
mpc/e2e/benchmark_test.go
zeekay 821bd09da5 chore: remove bridge stub, fix all TODOs with real implementations
- Remove lux-mpc-bridge command (bridge is in T-Chain, not MPC)
- Remove empty pkg/bridge directory
- Fix sign.go: remove stale TODO (ECDSA/EdDSA already supported)
- Fix pubsub.go: remove obsolete subscription TODO
- Fix benchmark_test.go: implement real protocol benchmarks
- Fix xrpl_test.go: implement full XRPL E2E tests
- Update goreleaser: remove bridge build target
- Update docker-compose: remove bridge-compat services

MPC is now a clean standalone threshold signature tool.
2025-12-25 10:44:16 -08:00

151 lines
3.6 KiB
Go

package e2e
import (
"crypto/rand"
"testing"
"github.com/luxfi/mpc/pkg/threshold"
)
// BenchmarkProtocolKeyGen benchmarks key generation for MPC protocols
// This runs protocol-level benchmarks without requiring full E2E infrastructure
func BenchmarkProtocolKeyGen(b *testing.B) {
api := threshold.NewUnifiedThresholdAPI()
defer api.Close()
partyIDs := []string{"party1", "party2", "party3"}
thresholdValue := 1 // t+1 = 2 parties needed for signing
b.Run("ECDSA_3_of_2", func(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
party, err := api.KeyGen(threshold.SchemeECDSA, "party1", partyIDs, thresholdValue)
if err != nil {
b.Fatal(err)
}
_ = party
}
})
b.Run("EdDSA_3_of_2", func(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
party, err := api.KeyGen(threshold.SchemeEdDSA, "party1", partyIDs, thresholdValue)
if err != nil {
b.Fatal(err)
}
_ = party
}
})
b.Run("Taproot_3_of_2", func(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
party, err := api.KeyGen(threshold.SchemeTaproot, "party1", partyIDs, thresholdValue)
if err != nil {
b.Fatal(err)
}
_ = party
}
})
}
// BenchmarkProtocolKeyGen5Parties benchmarks key generation with 5 parties
func BenchmarkProtocolKeyGen5Parties(b *testing.B) {
api := threshold.NewUnifiedThresholdAPI()
defer api.Close()
partyIDs := []string{"party1", "party2", "party3", "party4", "party5"}
thresholdValue := 2 // t+1 = 3 parties needed for signing
b.Run("ECDSA_5_of_3", func(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
party, err := api.KeyGen(threshold.SchemeECDSA, "party1", partyIDs, thresholdValue)
if err != nil {
b.Fatal(err)
}
_ = party
}
})
b.Run("EdDSA_5_of_3", func(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
party, err := api.KeyGen(threshold.SchemeEdDSA, "party1", partyIDs, thresholdValue)
if err != nil {
b.Fatal(err)
}
_ = party
}
})
}
// BenchmarkProtocolSchemeSelection benchmarks protocol selection by scheme
func BenchmarkProtocolSchemeSelection(b *testing.B) {
api := threshold.NewUnifiedThresholdAPI()
defer api.Close()
b.Run("GetSupportedSchemes", func(b *testing.B) {
for i := 0; i < b.N; i++ {
schemes := api.GetSupportedSchemes()
_ = schemes
}
})
b.Run("IsSchemeSupported_ECDSA", func(b *testing.B) {
for i := 0; i < b.N; i++ {
supported := api.IsSchemeSupported(threshold.SchemeECDSA)
_ = supported
}
})
b.Run("IsSchemeSupported_EdDSA", func(b *testing.B) {
for i := 0; i < b.N; i++ {
supported := api.IsSchemeSupported(threshold.SchemeEdDSA)
_ = supported
}
})
}
// BenchmarkConcurrentKeyGen benchmarks concurrent protocol instantiation
func BenchmarkConcurrentKeyGen(b *testing.B) {
api := threshold.NewUnifiedThresholdAPI()
defer api.Close()
partyIDs := []string{"alice", "bob", "charlie"}
thresholdValue := 1
b.Run("Concurrent_ECDSA_EdDSA", func(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
// Create both ECDSA and EdDSA parties concurrently
ecdsaParty, err := api.KeyGen(threshold.SchemeECDSA, "alice", partyIDs, thresholdValue)
if err != nil {
b.Fatal(err)
}
eddsaParty, err := api.KeyGen(threshold.SchemeEdDSA, "alice", partyIDs, thresholdValue)
if err != nil {
b.Fatal(err)
}
_, _ = ecdsaParty, eddsaParty
}
})
}
// BenchmarkMessageHashGeneration benchmarks message hash generation for signing
func BenchmarkMessageHashGeneration(b *testing.B) {
messageHash := make([]byte, 32)
b.Run("GenerateRandomHash", func(b *testing.B) {
for i := 0; i < b.N; i++ {
_, err := rand.Read(messageHash)
if err != nil {
b.Fatal(err)
}
}
})
}