trnX Documentation
Transport Layer Docs, Examples, and Integration Notes
trnX is a security-first transport layer for encrypted data channels, relay-based routing, and real-time communication primitives. These docs cover channel creation, connection management, streaming patterns, and deployment configuration.
Installation
npm install @rsaha/trnxRequires Node.js 20+. Native crypto module used for performance.
End-to-End Encrypted
AES-256-GCM with X25519 key exchange
Low Latency
Optimized for sub-50ms round-trips
Relay-Based Routing
Multi-hop transport with exit node selection
API Reference
trnx.createChannel(config)
Initialize a secure transport channel with encryption and routing configuration.
import { trnx } from '@rsaha/trnx';
const channel = trnx.createChannel({
protocol: 'trnx-v1',
encryption: 'aes-256-gcm',
keyExchange: 'x25519',
maxRetries: 3,
timeout: 10000,
});channel.connect(endpoint)
Establish a connection to a trnX endpoint with mutual authentication.
const connection = await channel.connect({
host: 'relay.rsaha.tech',
port: 8443,
cert: './certs/client.pem',
verify: true,
});
console.log(connection.state); // 'connected'
console.log(connection.latency); // Round-trip time in ms
console.log(connection.cipher); // Negotiated cipher suiteconnection.send(payload)
Send encrypted payloads through the established channel.
const receipt = await connection.send({
type: 'data',
payload: Buffer.from(JSON.stringify({ event: 'sync', ts: Date.now() })),
priority: 'normal', // 'low' | 'normal' | 'high' | 'critical'
ttl: 60000,
});
console.log(receipt.id); // Unique message ID
console.log(receipt.delivered); // boolean
console.log(receipt.hops); // Relay countconnection.stream(opts)
Open a bidirectional stream for continuous data exchange.
const stream = connection.stream({
mode: 'bidirectional',
bufferSize: 1024 * 64,
compression: 'zstd',
});
stream.on('data', (chunk) => {
console.log('Received:', chunk.length, 'bytes');
});
stream.write(Buffer.from('ping'));Further Reading
Protocol Specification
Wire format, handshake sequence, and frame layout
Relay Deployment Guide
Run your own trnX relay node
Security Model
Threat model, trust boundaries, and cryptographic choices
Performance Tuning
Buffer sizing, connection pooling, and throughput optimization