CuaimaCrypt
A symmetric hybrid cipher engine combining block cipher and stream cipher techniques, operating on 128-bit blocks. Security is scalable through the addition of processing blocks (RakeCodecs).
Byte-for-byte compatible with the original Java implementation in BTCrypto — data encrypted with Java can be decrypted by this crate and vice versa.
Features
- 128-bit block encryption with hybrid block/stream cipher design
- Scalable security — configure 2 to 1,024 RakeCodecs per instance
- Stream cipher properties — encrypting the same plaintext twice yields different ciphertext
- Cross-platform interoperability — certified compatible with Java BTCrypto v3.1.0
- Zero external dependencies — self-contained, no runtime deps
- Zero
unsafecode
Quick Start
Add to your Cargo.toml:
[]
= "1.0"
Encrypt and Decrypt
use CuaimaCrypt;
// Encoder
let mut encoder = new;
encoder.password.unwrap;
// Decoder (separate instance, same password)
let mut decoder = new;
decoder.password.unwrap;
let original: = ;
let mut block = original;
encoder.codec; // encrypt
assert_ne!;
decoder.decodec; // decrypt
assert_eq!;
Custom Security Level
Increase the number of RakeCodecs for higher security at the cost of throughput:
use CuaimaCrypt;
let mut cc = with_num_rakes.unwrap; // 2..=1024
cc.password.unwrap;
let mut block: = ;
cc.codec;
Architecture
ShiftCodec (atomic unit — 64-bit shift register with non-linear feedback)
↕ chained in ring topology (upchain / downchain)
RakeCodec (groups 4 ShiftCodecs — processes one 128-bit block)
↕ N blocks in cascade with CrossByte permutations between them
CuaimaCrypt (orchestrator — Walsh + Interleaving + N RakeCodecs + SeedHopping)
Each CuaimaCrypt instance contains N RakeCodec blocks (default 9) arranged in cascade. The encryption pipeline applies:
- Walsh spread-spectrum XOR — diffusion via Walsh code
- Interleaving — 8x8 matrix transposition mixing both block halves
- RakeCodec cascade — N stages of non-linear block transformation with CrossByte permutations between stages
- ShiftCodec advance — all shift registers advance with non-linear feedback
- SeedHopping — state permutation across all ShiftCodecs (stream cipher property)
Decryption reverses the pipeline in exact inverse order.
Java Interoperability
This crate produces identical output to the Java CuaimaCrypt class in BTCrypto v3.1.0. The interoperability test suite validates:
- Identical seed derivation from the same password
- Identical ciphertext for sequential block encryption
- Bidirectional decrypt: Java ciphertext decrypts in Rust and vice versa
- Multi-block sequential state evolution matches exactly
- Coverage across multiple passwords, rake counts, and Unicode
Run the interoperability tests:
See INTEROP_CERTIFICATION.md for the full certification report.
Building
Testing
Benchmarks
Benchmarks measure password initialization, single-block codec/decodec throughput, and throughput scaling across rake counts (2, 9, 16).
Minimum Supported Rust Version
Rust 2021 edition (1.56+).
License
MIT — Julian Bolivar, BolivarTech