chore: rename Avalanche references to Lux and remove backup files

- Rename Avalanche chain references to Lux in LSS adapters
- Update chain symbol from AVAX to LUX
- Remove obsolete .old and .bak test files
- Update README to reflect Lux branding
This commit is contained in:
Zach Kelling
2025-12-10 02:01:01 +00:00
parent 50b62443a9
commit 5e7261e4c9
7 changed files with 13 additions and 572 deletions
+1 -1
View File
@@ -51,7 +51,7 @@ The most comprehensive threshold signature implementation supporting **20+ block
| **Cardano** | EdDSA/ECDSA/Schnorr | Multi-era, Plutus scripts | ✅ Production |
### Tier 2 - Ready for Integration
Cosmos, Polkadot, Avalanche, BSC, NEAR, Aptos, Sui, Tezos, Algorand, Stellar, Hedera, Flow, Kadena, Mina
Cosmos, Polkadot, Lux, BSC, NEAR, Aptos, Sui, Tezos, Algorand, Stellar, Hedera, Flow, Kadena, Mina
## 🚀 Quick Start
-345
View File
@@ -1,345 +0,0 @@
package test
import (
"context"
"encoding/json"
"fmt"
"sync"
"time"
"github.com/luxfi/threshold/pkg/party"
"github.com/luxfi/threshold/pkg/protocol"
zmq "github.com/luxfi/zmq/v4"
)
// ZMQNetwork provides real network message passing for integration tests
type ZMQNetwork struct {
mu sync.RWMutex
parties []party.ID
publisher *zmq.Socket
subscribers map[party.ID]*zmq.Socket
ports map[party.ID]int
basePort int
ctx context.Context
cancel context.CancelFunc
wg sync.WaitGroup
}
// NewZMQNetwork creates a ZeroMQ-based test network
func NewZMQNetwork(parties []party.ID, basePort int) (*ZMQNetwork, error) {
ctx, cancel := context.WithCancel(context.Background())
publisher, err := zmq.NewSocket(zmq.PUB)
if err != nil {
cancel()
return nil, fmt.Errorf("failed to create publisher: %w", err)
}
// Bind publisher to port
pubPort := basePort
err = publisher.Bind(fmt.Sprintf("tcp://127.0.0.1:%d", pubPort))
if err != nil {
publisher.Close()
cancel()
return nil, fmt.Errorf("failed to bind publisher: %w", err)
}
n := &ZMQNetwork{
parties: parties,
publisher: publisher,
subscribers: make(map[party.ID]*zmq.Socket),
ports: make(map[party.ID]int),
basePort: basePort,
ctx: ctx,
cancel: cancel,
}
// Create subscribers for each party
for i, id := range parties {
subscriber, err := zmq.NewSocket(zmq.SUB)
if err != nil {
n.Close()
return nil, fmt.Errorf("failed to create subscriber for %s: %w", id, err)
}
// Connect to publisher
err = subscriber.Connect(fmt.Sprintf("tcp://127.0.0.1:%d", pubPort))
if err != nil {
subscriber.Close()
n.Close()
return nil, fmt.Errorf("failed to connect subscriber for %s: %w", id, err)
}
// Subscribe to messages for this party (and broadcasts)
subscriber.SetSubscribe(string(id))
subscriber.SetSubscribe("BROADCAST")
n.subscribers[id] = subscriber
n.ports[id] = basePort + i + 1
}
// Allow time for connections to establish
time.Sleep(100 * time.Millisecond)
return n, nil
}
// Send broadcasts a message through ZeroMQ
func (n *ZMQNetwork) Send(msg *protocol.Message) {
if msg == nil {
return
}
n.mu.RLock()
defer n.mu.RUnlock()
// Serialize message
data, err := json.Marshal(msg)
if err != nil {
return
}
// Determine routing
var topic string
if msg.To == "" {
topic = "BROADCAST"
} else {
topic = string(msg.To)
}
// Send through ZeroMQ
_, err = n.publisher.Send(topic, zmq.SNDMORE)
if err != nil {
return
}
_, err = n.publisher.Send(string(data), 0)
if err != nil {
return
}
}
// Next returns a channel for receiving messages for a party
func (n *ZMQNetwork) Next(id party.ID) <-chan *protocol.Message {
ch := make(chan *protocol.Message, 100)
n.wg.Add(1)
go func() {
defer n.wg.Done()
defer close(ch)
n.mu.RLock()
subscriber, ok := n.subscribers[id]
n.mu.RUnlock()
if !ok {
return
}
poller := zmq.NewPoller()
poller.Add(subscriber, zmq.POLLIN)
for {
select {
case <-n.ctx.Done():
return
default:
}
// Poll with timeout
sockets, err := poller.Poll(100 * time.Millisecond)
if err != nil || len(sockets) == 0 {
continue
}
// Receive topic
topic, err := subscriber.Recv(0)
if err != nil {
continue
}
// Receive data
data, err := subscriber.Recv(0)
if err != nil {
continue
}
// Skip if not for us
if topic != string(id) && topic != "BROADCAST" {
continue
}
// Deserialize message
var msg protocol.Message
err = json.Unmarshal([]byte(data), &msg)
if err != nil {
continue
}
// Send to channel
select {
case ch <- &msg:
case <-n.ctx.Done():
return
}
}
}()
return ch
}
// Close shuts down the ZeroMQ network
func (n *ZMQNetwork) Close() {
n.cancel()
n.wg.Wait()
n.mu.Lock()
defer n.mu.Unlock()
if n.publisher != nil {
n.publisher.Close()
}
for _, subscriber := range n.subscribers {
if subscriber != nil {
subscriber.Close()
}
}
}
// MessageWrapper provides copy-by-value semantics for messages
type MessageWrapper struct {
data []byte
}
// NewMessageWrapper creates a wrapper that ensures copy-by-value
func NewMessageWrapper(msg *protocol.Message) (*MessageWrapper, error) {
data, err := json.Marshal(msg)
if err != nil {
return nil, err
}
return &MessageWrapper{data: data}, nil
}
// Unwrap returns a copy of the message
func (w *MessageWrapper) Unwrap() (*protocol.Message, error) {
var msg protocol.Message
err := json.Unmarshal(w.data, &msg)
if err != nil {
return nil, err
}
return &msg, nil
}
// FunctionalNetwork provides a functional, composable network interface
type FunctionalNetwork struct {
mu sync.RWMutex
parties []party.ID
channels map[party.ID]chan *MessageWrapper
ctx context.Context
cancel context.CancelFunc
}
// NewFunctionalNetwork creates a functional message-passing network
func NewFunctionalNetwork(parties []party.ID) *FunctionalNetwork {
ctx, cancel := context.WithCancel(context.Background())
channels := make(map[party.ID]chan *MessageWrapper)
for _, id := range parties {
channels[id] = make(chan *MessageWrapper, 1000)
}
return &FunctionalNetwork{
parties: parties,
channels: channels,
ctx: ctx,
cancel: cancel,
}
}
// Send broadcasts a message with copy-by-value semantics
func (n *FunctionalNetwork) Send(msg *protocol.Message) {
if msg == nil {
return
}
// Create wrapper for copy-by-value
wrapper, err := NewMessageWrapper(msg)
if err != nil {
return
}
n.mu.RLock()
defer n.mu.RUnlock()
// Route message
if msg.To == "" {
// Broadcast to all except sender
for _, id := range n.parties {
if id == msg.From {
continue
}
select {
case n.channels[id] <- wrapper:
case <-n.ctx.Done():
return
default:
// Drop if channel full
}
}
} else {
// Send to specific party
if ch, ok := n.channels[msg.To]; ok {
select {
case ch <- wrapper:
case <-n.ctx.Done():
default:
// Drop if channel full
}
}
}
}
// Next returns a channel for receiving messages
func (n *FunctionalNetwork) Next(id party.ID) <-chan *protocol.Message {
ch := make(chan *protocol.Message, 100)
go func() {
defer close(ch)
n.mu.RLock()
incoming, ok := n.channels[id]
n.mu.RUnlock()
if !ok {
return
}
for {
select {
case <-n.ctx.Done():
return
case wrapper := <-incoming:
if wrapper == nil {
continue
}
// Unwrap to get copy
msg, err := wrapper.Unwrap()
if err != nil {
continue
}
select {
case ch <- msg:
case <-n.ctx.Done():
return
}
}
}
}()
return ch
}
// Close shuts down the network
func (n *FunctionalNetwork) Close() {
n.cancel()
}
-214
View File
@@ -1,214 +0,0 @@
package corona_test
import (
"testing"
"time"
"github.com/luxfi/threshold/internal/test"
"github.com/luxfi/threshold/pkg/party"
"github.com/luxfi/threshold/pkg/pool"
"github.com/luxfi/threshold/pkg/protocol"
"github.com/luxfi/threshold/protocols/corona"
"github.com/luxfi/threshold/protocols/corona/config"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestCoronaKeygen(t *testing.T) {
pl := pool.NewPool(0)
defer pl.TearDown()
n := 3
threshold := 2
partyIDs := test.PartyIDs(n)
// Run keygen using test.RunProtocol
configs := make(map[party.ID]*config.Config)
sessionID := []byte("test-corona-keygen")
results, err := test.RunProtocolWithTimeout(t, partyIDs, sessionID, 2*time.Minute, func(id party.ID) protocol.StartFunc {
return corona.Keygen(id, partyIDs, threshold, pl)
})
// Allow partial success for now as the protocol is new
if err != nil {
t.Logf("Keygen protocol error (expected during development): %v", err)
}
// Check any successful results
successCount := 0
for id, result := range results {
if result != nil {
if output, ok := result.(*config.Config); ok {
configs[id] = output
successCount++
// Verify basic properties
assert.Equal(t, id, output.ID)
assert.Equal(t, threshold, output.Threshold)
assert.NotNil(t, output.PublicKey)
assert.NotNil(t, output.PrivateShare)
}
}
}
t.Logf("Corona keygen: %d/%d parties succeeded", successCount, n)
// If we got at least threshold parties, verify they have the same public key
if successCount >= threshold {
var firstPubKey []byte
for _, cfg := range configs {
if firstPubKey == nil {
firstPubKey = cfg.PublicKey
} else {
assert.Equal(t, firstPubKey, cfg.PublicKey, "All parties should have same public key")
}
}
}
}
func TestCoronaSign(t *testing.T) {
pl := pool.NewPool(0)
defer pl.TearDown()
// Create test configs
n := 3
threshold := 2
partyIDs := test.PartyIDs(n)
message := []byte("test message for corona signing")
// First run keygen with a longer timeout
sessionID := []byte("test-corona-keygen-for-sign")
keygenResults, err := test.RunProtocolWithTimeout(t, partyIDs, sessionID, 2*time.Minute, func(id party.ID) protocol.StartFunc {
return corona.Keygen(id, partyIDs, threshold, pl)
})
if err != nil {
t.Skipf("Skipping sign test - keygen failed: %v", err)
return
}
// Collect configs
configs := make(map[party.ID]*config.Config)
for id, result := range keygenResults {
if cfg, ok := result.(*config.Config); ok {
configs[id] = cfg
}
}
if len(configs) < threshold {
t.Skipf("Skipping sign test - insufficient keygen results: %d < %d", len(configs), threshold)
return
}
// Select signers (first threshold parties)
signers := partyIDs[:threshold]
// Run signing protocol with longer timeout
signSessionID := []byte("test-corona-sign")
signResults, err := test.RunProtocolWithTimeout(t, signers, signSessionID, 2*time.Minute, func(id party.ID) protocol.StartFunc {
cfg := configs[id]
return corona.Sign(cfg, signers, message, pl)
})
if err != nil {
t.Logf("Sign protocol error (expected during development): %v", err)
}
// Check results
for id, result := range signResults {
if result != nil {
t.Logf("Party %s produced signature result", id)
// The signature verification would go here once fully implemented
}
}
}
func TestCoronaRefresh(t *testing.T) {
pl := pool.NewPool(0)
defer pl.TearDown()
n := 3
threshold := 2
partyIDs := test.PartyIDs(n)
// First run keygen
sessionID := []byte("test-corona-keygen-for-refresh")
keygenResults, err := test.RunProtocolWithTimeout(t, partyIDs, sessionID, 2*time.Minute, func(id party.ID) protocol.StartFunc {
return corona.Keygen(id, partyIDs, threshold, pl)
})
if err != nil {
t.Skipf("Skipping refresh test - keygen failed: %v", err)
return
}
// Collect configs
configs := make(map[party.ID]*config.Config)
for id, result := range keygenResults {
if cfg, ok := result.(*config.Config); ok {
configs[id] = cfg
}
}
if len(configs) < n {
t.Skipf("Skipping refresh test - insufficient keygen results: %d < %d", len(configs), n)
return
}
// Run refresh protocol with same parties and threshold
refreshSessionID := []byte("test-corona-refresh")
refreshResults, err := test.RunProtocolWithTimeout(t, partyIDs, refreshSessionID, 2*time.Minute, func(id party.ID) protocol.StartFunc {
cfg := configs[id]
return corona.Refresh(cfg, partyIDs, threshold, pl)
})
if err != nil {
t.Logf("Refresh protocol error (expected during development): %v", err)
}
// Check results
successCount := 0
for id, result := range refreshResults {
if result != nil {
if newCfg, ok := result.(*config.Config); ok {
oldCfg := configs[id]
successCount++
// Verify refresh maintains same public key
assert.Equal(t, oldCfg.PublicKey, newCfg.PublicKey, "Public key should remain same after refresh")
// Private share should be different
assert.NotEqual(t, oldCfg.PrivateShare, newCfg.PrivateShare, "Private share should change after refresh")
}
}
}
t.Logf("Corona refresh: %d/%d parties succeeded", successCount, n)
}
func TestCoronaSecurityLevels(t *testing.T) {
levels := []config.SecurityLevel{
config.Security128,
config.Security192,
config.Security256,
}
for _, level := range levels {
cfg := config.NewConfig("test", 2, level)
require.NotNil(t, cfg)
params := cfg.GetParameters()
assert.Greater(t, params.N, 0)
assert.Greater(t, params.Q, 0)
assert.Greater(t, params.Sigma, 0.0)
switch level {
case config.Security128:
assert.Equal(t, 128, params.SecurityBits)
case config.Security192:
assert.Equal(t, 192, params.SecurityBits)
case config.Security256:
assert.Equal(t, 256, params.SecurityBits)
}
}
}
+5 -5
View File
@@ -1,5 +1,5 @@
// Package adapters - Generic EVM blockchain adapter
// Supports: Ethereum, BSC, Polygon, Avalanche, Arbitrum, Optimism, Base, etc.
// Supports: Ethereum, BSC, Polygon, Lux, Arbitrum, Optimism, Base, etc.
package adapters
import (
@@ -18,7 +18,7 @@ const (
Ethereum EVMChain = "ethereum"
BSC EVMChain = "bsc"
Polygon EVMChain = "polygon"
Avalanche EVMChain = "avalanche"
Lux EVMChain = "lux"
Arbitrum EVMChain = "arbitrum"
Optimism EVMChain = "optimism"
Base EVMChain = "base"
@@ -74,10 +74,10 @@ func GetChainConfig(chain EVMChain) *ChainConfig {
ExplorerURL: "https://polygonscan.com",
SupportsEIP1559: true,
},
Avalanche: {
Lux: {
ChainID: big.NewInt(43114),
Name: "Avalanche C-Chain",
Symbol: "AVAX",
Name: "Lux C-Chain",
Symbol: "LUX",
ExplorerURL: "https://snowtrace.io",
SupportsEIP1559: true,
},
+1 -1
View File
@@ -20,7 +20,7 @@ func TestAllChainsSupported(t *testing.T) {
// Verify major chains are included
expectedChains := []string{
"xrpl", "ethereum", "bitcoin", "solana", "cardano",
"cosmos", "polkadot", "avalanche", "binance",
"cosmos", "polkadot", "lux", "binance",
// Note: TON adapter is included in adapters package
}
+1 -1
View File
@@ -258,7 +258,7 @@ func GetSupportedChains() []string {
"ton",
"cosmos",
"polkadot",
"avalanche",
"lux",
"binance",
"cardano",
"near",
+5 -5
View File
@@ -19,7 +19,7 @@ const (
BNBChain Chain = "bnb"
Solana Chain = "solana"
Cardano Chain = "cardano"
Avalanche Chain = "avalanche"
Lux Chain = "lux"
Polygon Chain = "polygon"
TRON Chain = "tron"
TON Chain = "ton"
@@ -182,14 +182,14 @@ func GetChainInfo(chain Chain) *ChainInfo {
Symbol: "MATIC",
Decimals: 18,
},
Avalanche: {
Name: "Avalanche C-Chain",
Lux: {
Name: "Lux C-Chain",
Type: TypeEVM,
SignatureType: adapters.SignatureECDSA,
Curve: "Secp256k1",
ChainID: 43114,
TestnetID: 43113, // Fuji
Symbol: "AVAX",
Symbol: "LUX",
Decimals: 18,
},
Arbitrum: {
@@ -373,7 +373,7 @@ func (l *LSS) GetConfig() *FactoryConfig {
func SupportedChains() []Chain {
return []Chain{
Bitcoin, Ethereum, BNBChain, Solana, Cardano,
Avalanche, Polygon, TON, Sui, Aptos,
Lux, Polygon, TON, Sui, Aptos,
Near, Cosmos, Algorand, Stellar, Hedera,
Flow, Tezos, EOS, XRPL, Polkadot,
Arbitrum, Optimism, Base, zkSync, Scroll,