dialer
Package dialer
import "github.com/luxfi/node/network/dialer"Functions
DestinationFromPublicKeys
func DestinationFromPublicKeys(edPublicKey, xPublicKey []byte) ([endpoints.RNSDestinationLen]byte, error)DestinationFromPublicKeys computes the destination hash from public keys. This is useful for computing destinations without creating full identity objects.
VerifyWithPubKey
func VerifyWithPubKey(publicKey, message, signature []byte) boolVerifyWithPubKey is an alias for VerifyWithPublicKey. Used by the RNS link protocol.
VerifyWithPublicKey
func VerifyWithPublicKey(publicKey, message, signature []byte) boolVerifyWithPublicKey verifies a signature using an external public key. This is a static method for verifying signatures from other identities.
Types
Announce
Announce represents a Reticulum destination announcement.
func UnmarshalAnnounce(data []byte) (*Announce, error)func (a *Announce) Marshal() []bytefunc (a *Announce) Sign(priv ed25519.PrivateKey)func (a *Announce) SignableBytes() []bytefunc (a *Announce) Verify() boolfunc (a *Announce) VerifyDestination() boolAnnounceEntry
AnnounceEntry contains information about a known destination.
AnnounceHandler
AnnounceHandler receives validated announcements.
AnnounceHandlerFunc
AnnounceHandlerFunc adapts a function to AnnounceHandler.
func (f AnnounceHandlerFunc) OnAnnounce(a *Announce) errorAnnouncer
Announcer manages announcement creation, validation, and propagation.
func NewAnnouncer(config AnnouncerConfig, logger log.Logger) *Announcerfunc (a *Announcer) AddHandler(h AnnounceHandler)func (a *Announcer) CreateAnnounce() (*Announce, error)func (a *Announcer) DestTable() *DestTablefunc (a *Announcer) HandleReceived(data []byte) (*Announce, error)func (a *Announcer) Lookup(dest [AnnounceDestLen]byte) *Announcefunc (a *Announcer) SetBroadcastFunc(fn func(*Announce) error)func (a *Announcer) SetIdentity(identity *RNSIdentity, appData []byte)func (a *Announcer) Start()func (a *Announcer) Stop()func (a *Announcer) Validate(ann *Announce) errorAnnouncerConfig
AnnouncerConfig configures the Announcer.
func DefaultAnnouncerConfig() AnnouncerConfigConfig
DNSCacheConfig
DNSCacheConfig configures the DNS resolution cache.
func DefaultDNSCacheConfig() DNSCacheConfigDestTable
DestTable tracks destinations with LRU eviction and expiry.
func NewDestTable(maxSize int, expiry time.Duration) *DestTablefunc (t *DestTable) All() []*Announcefunc (t *DestTable) Get(dest [AnnounceDestLen]byte) *Announcefunc (t *DestTable) Len() intfunc (t *DestTable) Prune() intfunc (t *DestTable) Put(a *Announce) boolfunc (t *DestTable) Remove(dest [AnnounceDestLen]byte)Dialer
Dialer attempts to create a connection with the provided IP/port pair
func NewDialer(network string, dialerConfig Config, logger log.Logger) DialerEndpointDialer
EndpointDialer attempts to create a connection with IP:port, hostname:port, or RNS destination.
func NewEndpointDialer(network string, config EndpointDialerConfig, logger log.Logger) EndpointDialerEndpointDialerConfig
EndpointDialerConfig extends Config with DNS and RNS settings.
HybridIdentity
HybridIdentity represents a post-quantum hybrid RNS identity. It combines classical (Ed25519/X25519) and post-quantum (ML-DSA-65/ML-KEM-768) algorithms for TLS 1.3-like hybrid security.
func LoadHybridIdentity(path string) (*HybridIdentity, error)func LoadOrGenerateHybridIdentity(path string) (*HybridIdentity, error)func NewHybridIdentity() (*HybridIdentity, error)func (id *HybridIdentity) Close() errorfunc (id *HybridIdentity) Destination() [endpoints.RNSDestinationLen]bytefunc (id *HybridIdentity) Hash() [endpoints.RNSDestinationLen]bytefunc (id *HybridIdentity) HybridDecapsulate(ciphertext []byte) ([]byte, error)func (id *HybridIdentity) HybridEncapsulate(recipientPub *HybridPublicIdentity) ([]byte, []byte, error)func (id *HybridIdentity) HybridKEMPublicKey() []bytefunc (id *HybridIdentity) IsHybrid() boolfunc (id *HybridIdentity) MLDSAPublicKey() []bytefunc (id *HybridIdentity) PublicIdentity() (*HybridPublicIdentity, error)func (id *HybridIdentity) Save(path string) errorfunc (id *HybridIdentity) Sign(message []byte) ([]byte, error)func (id *HybridIdentity) SignEd25519(message []byte) []bytefunc (id *HybridIdentity) SignMLDSA(message []byte) ([]byte, error)func (id *HybridIdentity) SigningPublicKey() []bytefunc (id *HybridIdentity) ToClassicalIdentity() (*RNSIdentity, error)func (id *HybridIdentity) Verify(message, signature []byte) boolfunc (id *HybridIdentity) X25519PublicKey() [x25519KeySize]byteHybridPublicIdentity
HybridPublicIdentity represents the public portion of a hybrid identity. Used for verifying signatures and encapsulating secrets to remote peers.
func NewHybridPublicIdentity(
edPubKey, xPubKey []byte,
mldsaPubKey *mldsa.PublicKey,
hybridKEMPubKey kem.PublicKey,
) (*HybridPublicIdentity, error)func UnmarshalHybridPublicIdentity(data []byte) (*HybridPublicIdentity, error)func (pub *HybridPublicIdentity) Destination() [endpoints.RNSDestinationLen]bytefunc (pub *HybridPublicIdentity) HybridKEMPublicKey() []bytefunc (pub *HybridPublicIdentity) MLDSAPublicKey() []bytefunc (pub *HybridPublicIdentity) MarshalBinary() ([]byte, error)func (pub *HybridPublicIdentity) SigningPublicKey() []bytefunc (pub *HybridPublicIdentity) Verify(message, signature []byte) boolfunc (pub *HybridPublicIdentity) X25519PublicKey() [x25519KeySize]bytePublicIdentity
PublicIdentity represents a read-only identity from public keys. This is used to verify signatures and encrypt messages to a remote identity.
func NewPublicIdentity(edPublicKey, xPublicKey []byte) (*PublicIdentity, error)func UnmarshalPublicIdentity(data []byte) (*PublicIdentity, error)func (pi *PublicIdentity) Destination() [endpoints.RNSDestinationLen]bytefunc (pi *PublicIdentity) EncryptionPublicKey() []bytefunc (pi *PublicIdentity) MarshalBinary() ([]byte, error)func (pi *PublicIdentity) PublicKey() []bytefunc (pi *PublicIdentity) Verify(message, signature []byte) boolRNSAnnouncer
RNSAnnouncer wraps Announcer with the interface expected by rns_transport.go.
func NewRNSAnnouncer(identity *RNSIdentity, config RNSAnnouncerConfig, loggers ...log.Logger) *RNSAnnouncerfunc (a *RNSAnnouncer) AddEntry(entry *AnnounceEntry)func (a *RNSAnnouncer) Announce() errorfunc (a *RNSAnnouncer) GetTable() map[[endpoints.RNSDestinationLen]byte]*AnnounceEntryfunc (a *RNSAnnouncer) Lookup(dest [endpoints.RNSDestinationLen]byte) *Announcefunc (a *RNSAnnouncer) LookupEntry(dest [endpoints.RNSDestinationLen]byte) (*AnnounceEntry, error)func (a *RNSAnnouncer) ProcessAnnouncement(packet []byte, transportAddr netip.AddrPort) errorfunc (a *RNSAnnouncer) RegisterHandler(handler interface{})func (a *RNSAnnouncer) Size() intfunc (a *RNSAnnouncer) Start() errorRNSAnnouncerConfig
RNSAnnouncerConfig configures the RNS announcer.
func DefaultRNSAnnouncerConfig() RNSAnnouncerConfigRNSConfig
RNSConfig configures the Reticulum Network Stack transport.
func DefaultRNSConfig() RNSConfigRNSIdentity
RNSIdentity represents a Reticulum Network Stack identity. It consists of an Ed25519 keypair for signing and an X25519 keypair for encryption. The destination hash is derived from the public keys.
func LoadOrGenerateIdentity(path string) (*RNSIdentity, error)func LoadRNSIdentity(path string) (*RNSIdentity, error)func NewRNSIdentity() (*RNSIdentity, error)func (id *RNSIdentity) Close() errorfunc (id *RNSIdentity) Decrypt(ephemeralPublicKey []byte) (sharedSecret []byte, err error)func (id *RNSIdentity) Destination() [endpoints.RNSDestinationLen]bytefunc (id *RNSIdentity) Encrypt(recipientXPublicKey []byte) (ephemeralPub []byte, sharedSecret []byte, err error)func (id *RNSIdentity) EncryptionPublicKey() []bytefunc (id *RNSIdentity) Hash() [endpoints.RNSDestinationLen]bytefunc (id *RNSIdentity) PublicKey() []bytefunc (id *RNSIdentity) Save(path string) errorfunc (id *RNSIdentity) Sign(message []byte) []bytefunc (id *RNSIdentity) SigningPublicKey() []bytefunc (id *RNSIdentity) Verify(message, signature []byte) boolfunc (id *RNSIdentity) X25519Exchange(peerPublicKey [x25519KeySize]byte) ([x25519KeySize]byte, error)func (id *RNSIdentity) X25519PublicKey() [x25519KeySize]byteRNSLink
RNSLink represents an encrypted bidirectional link between two RNS identities. Supports both classical (X25519-only) and hybrid (X25519 + ML-KEM-768) modes.
func NewHybridRNSLink(conn net.Conn, identity *HybridIdentity) *RNSLinkfunc NewRNSLink(conn net.Conn, identity *RNSIdentity) *RNSLinkfunc (l *RNSLink) Close() errorfunc (l *RNSLink) Handshake(initiator bool, peerDestination [endpoints.RNSDestinationLen]byte) errorfunc (l *RNSLink) IsEstablished() boolfunc (l *RNSLink) IsHybrid() boolfunc (l *RNSLink) LocalAddr() net.Addrfunc (l *RNSLink) PeerDestination() [endpoints.RNSDestinationLen]bytefunc (l *RNSLink) PeerIdentity() *HybridPublicIdentityfunc (l *RNSLink) Read(b []byte) (int, error)func (l *RNSLink) RemoteAddr() net.Addrfunc (l *RNSLink) SetDeadline(t time.Time) errorfunc (l *RNSLink) SetReadDeadline(t time.Time) errorfunc (l *RNSLink) SetWriteDeadline(t time.Time) errorfunc (l *RNSLink) Write(b []byte) (int, error)RNSTransport
RNSTransport provides connectivity over Reticulum Network Stack. Implementations wrap RNS Links as net.Conn interfaces.
func NewRNSTransport(config RNSConfig, logger log.Logger) RNSTransportZWingDialer
ZWingDialer wraps an underlying EndpointDialer so every produced
net.Conn is upgraded with a Z-Wing 1-RTT mutual-auth handshake.
The base dialer is responsible for picking the transport (plain TCP or RNS mesh link); the Z-Wing layer is identical in both cases — the secure channel rides byte-for-byte over whatever bytes the base transport delivers.
func NewZWingDialer(base EndpointDialer, cfg ZWingDialerConfig, logger log.Logger) (*ZWingDialer, error)func (z *ZWingDialer) Dial(
ctx context.Context,
ip netip.AddrPort,
expectedRemote *zwing.IdentityPublic,
) (net.Conn, error)func (z *ZWingDialer) DialEndpoint(
ctx context.Context,
endpoint endpoints.Endpoint,
expectedRemote *zwing.IdentityPublic,
) (net.Conn, error)func (z *ZWingDialer) Wrap(raw net.Conn, expectedRemote *zwing.IdentityPublic) (net.Conn, error)ZWingDialerConfig
ZWingDialerConfig configures a Z-Wing-secured dialer.
ZWingListener
ZWingListener wraps a raw TCP/RNS listener so every accepted
connection is post-handshake by the time the caller sees it. The
listener spec mirrors zwing.Listen but is built on top of any
net.Listener to reuse the existing RNS / TCP listener plumbing.
func NewZWingListener(raw net.Listener, cfg ZWingDialerConfig, logger log.Logger) (*ZWingListener, error)func (l *ZWingListener) Accept() (net.Conn, error)func (l *ZWingListener) Addr() net.Addrfunc (l *ZWingListener) Close() error