| Crates.io | lowmc-rs |
| lib.rs | lowmc-rs |
| version | 0.1.0 |
| created_at | 2025-06-26 01:36:05.129192+00 |
| updated_at | 2025-06-26 01:36:05.129192+00 |
| description | LowMC block cipher implementation in Rust |
| homepage | |
| repository | https://github.com/10d9e/lowmc-rs |
| max_upload_size | |
| id | 1726767 |
| size | 97,627 |
# Build the CLI binary
cargo build --release --bin lowmc
# Optionally, install to your $HOME/.cargo/bin
cargo install --path . --bin lowmc
lowmc generate-key --name mykey
~/.lowmc/ as <name>.key.lowmc encrypt --key mykey --input plaintext.txt --output ciphertext.txt --format hex
hex, base64, raw.lowmc decrypt --key mykey --input ciphertext.txt --output decrypted.txt --format hex
lowmc list-keys
lowmc key-info --name mykey
lowmc --help
LowMC is a family of block ciphers designed to minimize the number of AND gates in the circuit representation, making it suitable for applications in multi-party computation, fully homomorphic encryption, and zero-knowledge proofs.
This implementation provides:
Add this to your Cargo.toml:
[dependencies]
lowmc-rs = "0.1.0"
use lowmc_rs::LowMC;
fn main() {
// Create cipher with 80-bit key
let cipher = LowMC::new(0x123456789ABCDEFu128);
// Encrypt a message (uses lower 128 bits of u128)
let plaintext = 0xDEADBEEFu128;
let ciphertext = cipher.encrypt(plaintext);
let recovered = cipher.decrypt(ciphertext);
println!("Plaintext: {:#x}", plaintext);
println!("Ciphertext: {:#x}", ciphertext);
println!("Recovered: {:#x}", recovered);
assert_eq!(plaintext, recovered);
}
use lowmc_rs::LowMC;
let mut cipher = LowMC::new(0x12345u128);
// Change key
cipher.set_key(0x54321u128);
Run the included example:
cargo run --example simple --release
Run the comprehensive test suite:
# Tests must be run in release mode with single thread due to global LFSR state
cargo test --release -- --test-threads=1
The test suite includes:
src/lib.rs - Main library implementationsrc/main.rs - Simple binary demoexamples/simple.rs - Comprehensive usage exampleBitVec implementation for efficient bit manipulationThe implementation is optimized for correctness and clarity. For production use in performance-critical applications, consider:
Licensed under either of:
at your option.
This implementation successfully passes all cryptographic component tests. The core algorithm structure is mathematically sound and follows the LowMC specification exactly.