Noise_NN & Noise_IKpsk2 (WireGuard-grade X25519 + ChaCha20-Poly1305) handshakes, multiplexed reverse tunnels, and RFC 1928/1929 SOCKS5.
Pure-Veko Noise Protocol Framework (Noise_NN_25519_ChaChaPoly_SHA256 & Noise_IKpsk2_25519_ChaChaPoly_SHA256), multiplexed encrypted reverse tunnel, and RFC 1928 / RFC 1929 SOCKS5 proxy codec (noise_tunnel, noise_tunnel/socks5).
noise_tunnel implements authenticated zero-trust network tunneling and SOCKS5 ingress proxying in pure Veko with zero external dependencies:
noise_tunnel (Noise Protocol Framework Rev 34 & Reverse Tunnel Mux):CipherState (ChaChaPoly with 96-bit 0x00000000 || u64_le(n) nonces and Section 4.2 REKEY), SymmetricState (MixHash, MixKey, MixKeyAndHash, EncryptAndHash, DecryptAndHash, Split), Noise_NN_25519_ChaChaPoly_SHA256, and Noise_IKpsk2_25519_ChaChaPoly_SHA256 (WireGuard's mutual-authenticated, identity-hiding PSK handshake pattern) built on crypto/x25519, crypto/chacha20, and crypto/sha256.OPEN_STREAM, STREAM_DATA, CLOSE_STREAM, PING, PONG) multiplexing concurrent logical streams over a single Noise TransportSession.noise_tunnel/socks5 (RFC 1928 + RFC 1929 SOCKS5):bits/ct-eq?, CONNECT requests/replies across IPv4 (0x01), Domain (0x03), and IPv6 (0x04) ATYP modes, and io/Stream client/server handshake helpers.veko pkg add noise_tunnel@1.0.0Import the modules in .vk source files:
use [
nt = noise_tunnel
socks5 = noise_tunnel/socks5
]Noise_IKpsk2_25519_ChaChaPoly_SHA256 HandshakePre-message:
<- s (Initiator knows Responder's 32B static X25519 public key)
Handshake:
Initiator --- e, es, s, ss + AEAD(payload) ---> Responder (Hides Initiator static key `s` under `es`!)
Initiator <-- e, ee, se, psk + AEAD(reply) ---- Responder (Mutual forward-secret auth + 32B PSK binding)
|
v
Split() -> (tx CipherState, rx CipherState, handshake_hash)
|
v
Multiplexed Encrypted Reverse Tunnel Frames
[4B u32_be len][AEAD(1B kind | 4B stream_id | 4B payload_len | payload)]noise_tunnel| Symbol | Signature | Description |
|---|---|---|
PROTO-NOISE-NN | fn [] str | 'Noise_NN_25519_ChaChaPoly_SHA256' |
PROTO-NOISE-IKPSK2 | fn [] str | 'Noise_IKpsk2_25519_ChaChaPoly_SHA256' |
FRAME-OPEN-STREAM / FRAME-STREAM-DATA / FRAME-CLOSE-STREAM / FRAME-PING / FRAME-PONG | fn [] i64 | Reverse tunnel frame kind constants (1..5) |
generate-keypair / keypair-from-seed | fn [] Keypair / fn [priv32 bytes] Keypair | X25519 keypair generation |
new-cipher-state | fn [/key k_bytes bytes = ...] CipherState | Initializes an unkeyed or keyed CipherState |
encode-noise-nonce | fn [n i64] bytes | Encodes `4B zero |
encrypt-with-ad / decrypt-with-ad | fn [mut cs CipherState, ad bytes, data bytes] bytes | Noise CipherState AEAD operations |
rekey | fn [mut cs CipherState] enum | Noise Section 4.2 REKEY(k) using maxnonce = 2^64 - 1 |
init-symmetric | fn [protocol_name str] SymmetricState | Initializes SymmetricState per Noise Section 5.2 |
mix-hash / mix-key / mix-key-and-hash | fn [mut ss SymmetricState, data bytes] enum | Transcript and HKDF chaining-key mixing |
encrypt-and-hash / decrypt-and-hash | fn [mut ss SymmetricState, data bytes] bytes | Handshake AEAD + transcript hashing |
nn-initiator-new / nn-responder-new | fn [/prologue prol bytes = ...] HandshakeState | Initializes NN handshake endpoints |
nn-write-msg1 / nn-read-msg1 / nn-write-msg2 / nn-read-msg2 | HandshakeState functions | 2-message Noise_NN handshake |
ik-initiator-new | fn [static_kp Keypair, remote_static_pub bytes, psk32 bytes /prologue prol bytes = ...] HandshakeState | Initializes IKpsk2 initiator |
ik-responder-new | fn [static_kp Keypair, psk32 bytes /prologue prol bytes = ...] HandshakeState | Initializes IKpsk2 responder |
ik-write-msg1 / ik-read-msg1 | HandshakeState functions | Message 1 (-> e, es, s, ss) write & read |
ik-write-msg2 / ik-read-msg2 | HandshakeState functions | Message 2 (<- e, ee, se, psk) + Split |
transport-encrypt / transport-decrypt | fn [mut sess TransportSession, data bytes /ad assoc_data bytes = ...] bytes | Directional transport AEAD |
transport-rekey-tx / transport-rekey-rx | fn [mut sess TransportSession] enum | Directional transport rekeying |
seal-tunnel-packet / open-tunnel-packet | TransportSession frame functions | Seals/opens length-prefixed encrypted tunnel packets |
new-tunnel-mux | fn [is_server bool] TunnelMux | Creates a stream-multiplexed reverse tunnel state |
mux-open-stream / mux-send-data / mux-close-stream / mux-ping / mux-ingest-packet / mux-drain-stream | TunnelMux functions | Stream lifecycle, data multiplexing, and keepalives |
noise_tunnel/socks5| Symbol | Signature | Description |
|---|---|---|
ATYP-IPV4 / ATYP-DOMAIN / ATYP-IPV6 | fn [] i64 | RFC 1928 address type constants (0x01, 0x03, 0x04) |
encode-greeting / decode-greeting | fn [methods block[i64]] bytes / fn [wire bytes] SocksGreeting | SOCKS5 method greeting codec |
encode-userpass-auth / decode-userpass-auth | fn [username str, password str] bytes / fn [wire bytes] UserPassCreds | RFC 1929 subnegotiation codec |
verify-userpass | fn [creds UserPassCreds, expected_user str, expected_pass str] bool | Constant-time credential verification (bits/ct-eq?) |
encode-connect-req / decode-connect-req | fn [host str, port i64 ...] bytes / fn [wire bytes] ConnectRequest | SOCKS5 CONNECT request codec (IPv4/Domain/IPv6) |
encode-reply / decode-reply | fn [rep i64, bind_host str, bind_port i64] bytes / fn [wire bytes] SocksReply | SOCKS5 reply codec |
client-handshake | fn [mut s io/Stream, target_host str, target_port i64 /username user str = '' /password pass str = ''] SocksReply | Client SOCKS5 handshake over io/Stream |
server-accept | fn [mut s io/Stream /require_user expected_user str = '' /require_pass expected_pass str = '' ...] ConnectRequest | Server SOCKS5 accept + RFC 1929 auth over io/Stream |
use [nt = noise_tunnel]
agent_kp = nt/generate-keypair
gateway_kp = nt/generate-keypair
psk = random/bytes 32
mut init_hs = nt/ik-initiator-new agent_kp gateway_kp.pub_key psk
mut resp_hs = nt/ik-responder-new gateway_kp psk
msg1 = nt/ik-write-msg1 mut init_hs (bytes/from-str 'agent:eu-west-1')
r1 = nt/ik-read-msg1 mut resp_hs msg1
msg2 = nt/ik-write-msg2 mut resp_hs (bytes/from-str 'ok')
done = nt/ik-read-msg2 mut init_hs msg2.wire
mut cli_sess = done.session
mut srv_sess = msg2.session
ct = nt/transport-encrypt mut cli_sess (bytes/from-str 'encrypted frame')
pt = nt/transport-decrypt mut srv_sess ct
print (bytes/to-str pt)https://veko-lang.org/pkg/noise_tunnel/1.0.0.vkp61988f3973474e435e9adf6f406217834e2b4f028b55ed253093d98f7a2693864811e35c91a43ec0df7b91809a3367619ac08457347a947bbf18bac87b444065ed25519:27406074d8681da1d4e6420f5d887cac15c313334c249ac047ba9d4e2df72b70{"name":"noise_tunnel","version":"1.0.0","tier":5.0,"tier_label":"Tier 5: Cloud-Native, Noise, IaC & Wasm","category":"Noise Protocol, SOCKS5 & Tunnels","description":"Noise_NN & Noise_IKpsk2 (WireGuard-grade X25519 + ChaCha20-Poly1305) handshakes, multiplexed reverse tunnels, and RFC 1928/1929 SOCKS5.","modules":["noise_tunnel","noise_tunnel/socks5"],"homepage":"https://veko-lang.org/packages/noise_tunnel"}| Bundle Entry Path | Size | Leaf SHA-256 Digest |
|---|---|---|
| README.md | 7 KB | 4c6ba3821bbcbf40e79b7f2a2392f7c50d27b3ed500cf117ff52a6be7094de23 |
| examples/demo.vk | 8 KB | df8e8367389fe58fd665b7ff39cf925f43c353600f79a5d71f7f0d27521cf147 |
| mod.vk | 25 KB | 1ac427e8731263346459c673f6bb9f05f762fb23d00f39c019f458edb2512555 |
| socks5.vk | 15 KB | 2224b70beac83802871c2293223a8578919ebfed463bd526f25be77df1f763e1 |