đź“– Introduction
Exploring Cryptography with Rust is a hands‑on companion to modern cryptography textbooks, built entirely in Rust. Instead of just reading about algorithms, you can explore self‑contained Rust crates that implement and demonstrate each concept, from error‑correcting codes to probabilistic proofs.
🚀 Project Goals
-
Bridge Theory and Practice
Turn textbook pseudocode into real, tested Rust libraries. -
Learn by Example
Run and modify examples to see how Reed–Solomon encoding, Freivalds’ algorithm, zero‑knowledge proofs, and more really work. -
Organized by Book
Each crate lives under a folder named for the source text (e.g. Proofs, Arguments, and Zero‑Knowledge), letting you browse code chapter by chapter.
📚 What’s Inside
-
fingerprint
Reed–Solomon encoding & Lagrange interpolation examples (from Proofs, Arguments, and Zero‑Knowledge). -
freivalds
Freivalds’ probabilistic matrix multiplication verifier. -
(…and more crates to come, each tied to a classic crypto book.)
Each book defines features that includes:
- A minimal
Cargo.toml
- A
src/lib.rs
implementing the core routines - An
examples/
directory showing how to generate codewords, test proofs, or verify matrices
🛠️ Getting Started
🛠️ Prerequisites
- Rust (via rustup)
This project uses mdBook v0.4.45 to ensure compatibility with mdbook-katex
.
- mdBook and KaTeX support:
cargo install mdbook --version 0.4.45 cargo install mdbook-katex or chmod +x ./setup.sh ./setup.sh
🚀 Quick Start
git clone https://github.com/carougen/exploring-cryptography-with-rust.git
cd exploring-cryptography-with-rust
cargo build --all
mdbook serve book
📦 Build & Tests
# Compile all crates
cargo build --all
# Run test for a specific package
cargo test -p freivalds freivalds_test
# Run all tests
cargo test --all
# Generate the HTML for the book
cd book
mdbook build
# Run benchmark for a specific package
cargo bench --package freivalds --bench freivalds_bench
# Run benchmark for all packages
cargo bench --workspace --all-targets
▶️ Running Examples
From "Proofs, Arguments, and Zero-Knowledge"
fingerprint
cargo run -p fingerprint --example rs_lagrange
cargo run -p fingerprint --example rs_polynomial
freivalds
cargo run -p freivalds --example freivalds
đź“– Documentation & mdBook
To serve the docs locally with live reload:
cd book
mdbook serve
Then open: http://localhost:3000
🤝 Contributing
Thank you for your interest in contributing! Before you begin, please note that this project is licensed under MIT and adheres to the Rust Community Code of Conduct. By participating, you agree to abide by these terms.
âž• Adding a New Book or Chapter
- Fork the repository and create a new branch
git checkout -b feature/<book>-short-description
- Under
crates/your_book/your_feature
, add your crate following the existing structure:Cargo.toml
src/lib.rs
examples/
- In
book/src/<your_language>/your_book>/
, add:index.md
courses/
exercices/
examples/
images/
- Update
book/src/SUMMARY.md
to include your new chapter links
🛠️ Code Quality Checks
- Formatting:
cargo fmt --all -- --check
- Linting:
cargo clippy --all -- -D warnings
- Tests:
Add at least one unit test undersrc/
.
Example: seecrates/proofs_arguments_zeroknowledge/fingerprint/src/lib.rs
for a sample test.
🚀 Pull Request Process
- Ensure all CI checks are passing
- Fill out the PR
- Submit your pull request
- Wait for review and address any feedback
🌿 Branch Naming
- Features:
feature/<book>-short-description
- Bugfixes:
fix/<crate>-short-description
📜 Code of Conduct
Please follow the Rust Community Code of Conduct.
Please follow the Project Code of Conduct.