Files
node/mesh/kem/canonical_numbering_test.go
zeekayandHanzo Dev 37e2940ead mesh is the peer layer, network is the validator set
Two packages were named for the same word and meant different things. network/
dialed peers, exchanged keys, throttled and tracked them; nets/ tracked which
chains share a validator set and when they have all bootstrapped. One letter
apart, and neither name said which was which.

The peer layer is mesh — the word this estate already uses for it, in
lux-rs/node's own mesh.rs. That frees network for the thing that is actually a
network: a set of chains sharing a validator set. A network holds chains; a
chain belongs to one network.

github.com/luxfi/p2p stays what it is, the gossip library the VMs use. Three
concerns, three names, none of them borrowed from another.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-07 21:17:09 -07:00

43 lines
1.4 KiB
Go

// Copyright (C) 2019-2026, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package kem_test
import (
"testing"
"github.com/luxfi/consensus/config"
"github.com/luxfi/node/mesh/kem"
)
// TestKEMSchemeIDs_AllUseCanonicalNumbering confirms the node's KEM
// package re-exports config.KeyExchangeID byte-for-byte. A second
// declaration here — ML-KEM-768 as 0x62, ML-KEM-1024 as 0x63 — is a
// second wire numbering, and two numberings for one wire byte is a
// handshake that fails on the value alone. Aliasing keeps one source
// of truth.
func TestKEMSchemeIDs_AllUseCanonicalNumbering(t *testing.T) {
cases := []struct {
name string
node kem.KeyExchangeID
canon config.KeyExchangeID
wantHex uint8
}{
{"ml-kem-768", kem.KeyExchangeMLKEM768, config.KeyExchangeMLKEM768, 0x01},
{"ml-kem-1024", kem.KeyExchangeMLKEM1024, config.KeyExchangeMLKEM1024, 0x02},
{"x25519-unsafe", kem.KeyExchangeX25519Unsafe, config.KeyExchangeX25519Unsafe, 0x90},
{"none", kem.KeyExchangeNone, config.KeyExchangeInvalid, 0x00},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
if c.node != c.canon {
t.Errorf("node/kem.%s and config.%s diverge: node=0x%02x config=0x%02x",
c.name, c.name, uint8(c.node), uint8(c.canon))
}
if uint8(c.node) != c.wantHex {
t.Errorf("node/kem.%s wire byte = 0x%02x, want 0x%02x", c.name, uint8(c.node), c.wantHex)
}
})
}
}