veko-lang.org
Download Free EPUB 3.0

Part II · Files, Codecs, Web & Zero-FFI SQLite

Chapter 4

Files, Streams, Archives, Compression & Regex

Polymorphic io/Stream testing, ReDoS-proof Thompson NFA regex, Zstandard compression, and ZIP/TAR archives

79-MODULE STDLIB & PQC

Pure-Veko Standard Library & Post-Quantum Cryptography Architecture

1,043 exported structs and functions across 79 modules — from core data structures to NIST FIPS 203/204/205 PQC.

CORE DATA, CLI, CODECS & ARCHIVES Zero OS capabilities required CLASSICAL & POST-QUANTUM CRYPTOGRAPHY lib/crypto/* + lib/auth/* buf / bits Wire frames SHA3 / SHAKE AES-GCM / EdDSA ML-KEM / ML-DSA TLS / Vault / JWT FoundationsCore, Text, Math & CLIfmt, cli, coll, seq, regex, utf8 SerializationCodecs, Wire & Archivescbor, csv, toml, der, deflate, zip Systems LayerStreams, Reactor, DB & UIio, reactor, web, db/*, durable, ui Classical CryptoAEAD, Hashes & CurvesAES-GCM, ChaCha20, SHA-2/3, X25519 Post-QuantumNIST FIPS 203 / 204 / 205ML-KEM, ML-DSA & SLH-DSA Envelope & Authcrypto/seal & Auth TokensSealed Envelopes + JWT/OAuth2/TOTP
Component & ModuleArchitectural Role
Core, Text, Math & CLI
lib/fmt.vk + lib/cli.vk + lib/coll.vk
Provides formatting, subcommand CLI parsing, sets/rings/heaps/LRU, regex NFA, and UTF-8.
Codecs, Wire & Archives
lib/codec/* + lib/archive/*
Encodes and decodes binary and text wire formats plus compressed TAR/ZIP archives.
Streams, Reactor, DB & UI
lib/reactor.vk + lib/web.vk + lib/durable.vk
Builds high-level networking, persistence, workflows, and UIs over the capability PAL.
AEAD, Hashes & Curves
lib/crypto/aes.vk + lib/crypto/x25519.vk
Constant-time symmetric AEADs, cryptographic Sponge/Merkle hashes, KDFs, and elliptic curves.
NIST FIPS 203 / 204 / 205
lib/crypto/mlkem.vk + lib/crypto/mldsa.vk
Quantum-resistant lattice KEMs, lattice signatures, and stateless hash signatures.
crypto/seal & Auth Tokens
lib/crypto/seal.vk + lib/auth/jwt.vk
Combines sealed AEAD envelopes with EdDSA/ML-DSA65 JWTs, OAuth2 PKCE, and RFC 6238 TOTP.

Recipe 4.1: Polymorphic io/Stream Pipelines (Memory, Files & TLS Sockets)

Write protocol parsers and serializers against io/Stream so unit tests feed io/mem-stream in memory with zero capabilities while production code passes TCP or TLS 1.3 streams:

VEKO
use [io]

write-netstring = fn [mut s io/Stream, msg str] i64 [
    raw = bytes/from-str msg
    frame = bytes/from-str `{(len raw)}:{msg},`
    io/write-all mut s frame
]

// Test purely in memory with zero .fs or .net capabilities
mut mem = io/mem-stream (bytes/with-cap 0)
_ = write-netstring mut mem 'homoiconic'
wire_text = bytes/to-str (io/read-all mut mem)  // '10:homoiconic,'

Recipe 4.2: Linear-Time ReDoS-Proof Regex Capture Groups (lib/text/re.vk)

Veko's text/re compiles patterns to a Thompson NFA with guaranteed O(n * m) execution time — immune to catastrophic backtracking on untrusted user input:

VEKO
use [re = text/re]

sem_rx = re/compile '([a-z0-9_]+)@([0-9]+\\.[0-9]+\\.[0-9]+)'
m = re/match sem_rx 'http_router@1.2.0'
if m.matched [
    pkg_name = m.groups[1]   // 'http_router'
    pkg_ver  = m.groups[2]   // '1.2.0'
    println `Resolved package {pkg_name} version {pkg_ver}`
]

Recipe 4.3: Zstandard Compression & Deterministic TAR/ZIP Archives

Compress payloads with RFC 8878 Zstandard (compress/zstd) and bundle multi-file release archives in memory with archive/zip or archive/tar:

VEKO
use [zstd = compress/zstd, zip = archive/zip]

pack-diagnostic-bundle = fn [readme_txt str, log_json str] bytes [
    compressed_log = zstd/compress (bytes/from-str log_json)
    zip/pack [
        zip/ZipEntry { path = 'README.txt',    data = (bytes/from-str readme_txt), compress = true }
        zip/ZipEntry { path = 'events.json.zst', data = compressed_log,            compress = false }
    ]
]