Showcase: TRV Monolith — A unified, source-available cryptographic runtime in pure Rust

Hi everyone,

Today, I’m sharing TRV™ Monolith — a complete, dependency-free cryptographic engine implemented entirely from scratch in pure Rust.

TRV™ Monolith is designed around a compact, register-local architecture providing practical hashing, stream encryption, MAC construction, and KDF functionality. The codebase is fully source-available for academic evaluation, peer review, and cryptanalytic auditing.

:bullseye: Design & Architectural Goals

In standard production environments, cryptographic stacks are heavily segmented—developers import different crates for SHA-3, AES-CTR, and HMAC, pulling in nested transitive dependencies and introducing compiler optimization boundaries.

TRV™ Monolith was engineered as a self-contained cryptographic runtime with exactly zero external dependencies. The same internal state-transformation core is utilized across all four operations:

  • Hashing (TRV-Hash)
  • CTR Stream Generation (TRV-CTR)
  • Keyed Message Authentication (TRV-MAC)
  • Key Derivation (TRV-KDF)

:cyclone: Core Primitive: BTGS

At the center of the engine is a Boolean Transformation Gate System (BTGS), a branch-free Boolean state transformation operating on a compact 256-bit internal state.

The Rust implementation is designed to enforce:

  • Zero Lookup Tables: No memory-indexed S-box operations, eliminating L1/L2 data cache lookups in the hot path.
  • Zero Branch Hazards: The transformation loop is branchless and unrolled, preventing branch-prediction side channels.
  • Secure Memory Sanitation: The TrvState registers implement Drop to clear u128 values upon scope exit, preventing memory residues.

Our objective was to keep the execution state completely register-local to optimize ALU execution frequency and minimize memory bus pressure under parallel multi-core workloads.

:high_voltage: Empirical Performance Baseline

Benchmarks were compiled using native CPU optimizations (-O3 -C target-cpu=native) in software-only environments (no hardware acceleration, no AES-NI):

  • TRV-Hash: ~163 MB/s on Apple Silicon ARM64 / ~340 MB/s on Intel Xeon x86_64 sequentially (outperforming pure software-only Keccak/SHA3-256 by ~5x).
  • TRV-MAC: Outperforms HMAC-SHA3-256 by 15.15x on sequential 10KB network packet authentication due to single-pass length-extension immunity.
  • TRV-KDF: Processes 100,000 sequential non-linear mixing passes in sub-millisecond latency.

:shield: Why is it Fast? (The Microarchitectural Purity)

In cryptography, speed is often viewed with skepticism (as speed can imply a lack of rigorous mathematical work). However, TRV™ Monolith’s velocity is not achieved by reducing cryptographic complexity, but rather through microarchitectural hardware optimization:

  1. Register-Locked Execution: Traditional algorithms shuffle large state arrays across memory or L1/L2 caches. TRV™ Monolith locks its entire 256-bit state directly inside CPU registers (hi and lo 128-bit fields). This achieves a 0-cycle memory latency pipeline, completely eliminating cache-miss overheads and cache-timing side-channels by design.
  2. Branch-Free Pipeline: The entire hot path has absolutely zero conditional jumps or loop hazards, allowing modern super-scalar CPU execution pipelines to operate at maximum execution frequency.
  3. Heavy Mathematical Work (The Algebraic Firewall):
    • Hashing (N + 144 total rounds): Instead of coarse block-wise ingestion, TRV-Hash performs byte-by-byte continuous absorption. Every single byte is XORed into the state and immediately passed through a full BTGS gate transition (running exactly $N$ absorption rounds for an $N$-byte input). Once absorbed, the state is subjected to a 16-round block saturation for deep diffusion of the final bytes, followed by a massive 128-round finalization schedule. These final 128 rounds act as an algebraic firewall, expanding the degree of the state's Boolean polynomials to establish a massive algebraic complexity barrier designed to withstand linear, differential, slide, and equation-solving cryptanalysis.
    • KDF (100,000 sequential passes): The KDF runs 100,000 sequential rounds of dynamic, non-linear BTGS transformations. The strict sequential state-dependency resists ASIC/GPU acceleration, yet executes in sub-millisecond speeds solely because it runs entirely inside registers.

The repository includes reproducible benchmark harnesses, round-by-round avalanche propagation audits, and performance reports.

:test_tube: Verification & Correctness

The crate contains a comprehensive integration test suite validating:

  • Known Answer Tests (KATs) for hashing and key derivation.
  • Padding boundary separation (verifying that trailing null bytes do not cause collision vulnerabilities).
  • CTR stream cipher encryption/decryption round-trip.
  • Compile-time drop sanitation stability.

To execute the test suite:

git clone https://github.com/trvengine/trv-monolith
cd trv-monolith
cargo test

:books: Monograph, Code, & Licensing
GitHub Repository:

Zenodo Monograph (PDF):

DOI

I’d love to hear your feedback, thoughts, or suggestions on the implementation, microarchitectural performance, or systems architecture!

Please note: The engine code and mathematical formulas are distributed under the TRV™ Cryptographic Engine License (TCEL) and BTGS Formula License (BTGSL) for non-commercial research, academic study, and personal evaluation.

Thank you for your time, and I look forward to a highly technical discussion!