add workspaces structure & rename repo (plonky2-aes to plonky2-crypto-gadgets) & add GHA (#5)
arnaucube git@arnaucube.com
Tue, 17 Feb 2026 10:33:49 +0100
14 files changed,
127 insertions(+),
31 deletions(-)
jump to
A
.github/workflows/clippy.yml
@@ -0,0 +1,21 @@
+name: Clippy Check + +on: + pull_request: + branches: [ main ] + types: [ready_for_review, opened, synchronize, reopened] + push: + branches: [ main ] + +jobs: + clippy: + if: github.event.pull_request.draft == false + name: Rust formatting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: clippy + - name: Check lints with clippy + run: cargo clippy --tests --examples
A
.github/workflows/rustfmt.yml
@@ -0,0 +1,21 @@
+name: Rustfmt Check + +on: + pull_request: + branches: [ main ] + types: [ready_for_review, opened, synchronize, reopened] + push: + branches: [ main ] + +jobs: + rustfmt: + if: github.event.pull_request.draft == false + name: Rust formatting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: rustfmt + - name: Check formatting + uses: actions-rust-lang/rustfmt@v1
A
.github/workflows/tests.yml
@@ -0,0 +1,20 @@
+name: Rust Tests + +on: + pull_request: + branches: [ main ] + types: [ready_for_review, opened, synchronize, reopened] + push: + branches: [ main ] + +jobs: + test: + if: github.event.pull_request.draft == false + name: Rust tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Rust + uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Run tests + run: cargo test --release
A
.github/workflows/typos.yml
@@ -0,0 +1,21 @@
+name: typos +on: + pull_request: + branches: [ main ] + types: [ready_for_review, opened, synchronize, reopened] + push: + branches: + - main + +jobs: + typos: + if: github.event.pull_request.draft == false + name: Spell Check with Typos + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Use typos with config file + uses: crate-ci/typos@master + with: + config: .github/workflows/typos.toml +
M
Cargo.toml
→
Cargo.toml
@@ -1,14 +1,8 @@
-[package] -name = "plonky2-aes" -version = "0.1.0" -edition = "2024" +[workspace] +members = [ + "aes-gcm" +] -[dependencies] -plonky2 = { git = "https://github.com/0xPARC/plonky2.git", rev = "109d517d09c210ae4c2cee381d3e3fbc04aa3812" } -anyhow = "1.0.56" +resolver = "2" -[dev-dependencies] -rand = "0.10.0" -aes = "0.8.4" -aes-gcm = "0.10.3" -hex = "0.4.3" +[workspace.dependencies]
M
README.md
→
README.md
@@ -1,4 +1,5 @@
-# plonky2-aes -Plonky2 circuits for AES encryption system as described at -- AES: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.197-upd1.pdf -- AES-GCM (Galois Counter Mode): https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf +# plonky2-crypto-gadgets + +- [aes-gcm](/aes-gcm): Plonky2 circuits for AES & AES-GCM encryption system as described at + - AES: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.197-upd1.pdf + - AES-GCM (Galois Counter Mode): https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
A
aes-gcm/Cargo.toml
@@ -0,0 +1,14 @@
+[package] +name = "plonky2-aes" +version = "0.1.0" +edition = "2024" + +[dependencies] +plonky2 = { git = "https://github.com/0xPARC/plonky2.git", rev = "109d517d09c210ae4c2cee381d3e3fbc04aa3812" } +anyhow = "1.0.56" + +[dev-dependencies] +rand = "0.10.0" +aes = "0.8.4" +aes-gcm = "0.10.3" +hex = "0.4.3"
A
rustfmt.toml
@@ -0,0 +1,3 @@
+imports_granularity = "Crate" +reorder_imports = true # default +group_imports = "StdExternalCrate"
M
src/circuit_aes.rs
→
aes-gcm/src/circuit_aes.rs
@@ -13,9 +13,9 @@ plonk::circuit_builder::CircuitBuilder,
}; use crate::{ - constants::{RCON, SBOX}, - native_aes::{rot_word, shift_rows, State}, D, + constants::{RCON, SBOX}, + native_aes::{State, rot_word, shift_rows}, }; #[derive(Debug, Copy, Clone)]@@ -400,12 +400,10 @@ };
use rand::RngExt; use super::{ - sbox_lut, state_mix_matrix_bits, ByteArrayTarget, CircuitBuilderAESState, - PartialWitnessAESState, PartialWitnessByteArray, + ByteArrayTarget, CircuitBuilderAESState, D, PartialWitnessAESState, + PartialWitnessByteArray, sbox_lut, state_mix_matrix_bits, }; - use crate::native_aes::{encrypt_block, key_expansion, mix_columns, sub_bytes, State}; - - use super::D; + use crate::native_aes::{State, encrypt_block, key_expansion, mix_columns, sub_bytes}; #[test] fn test_sub_bytes() -> Result<()> {
M
src/native_aes.rs
→
aes-gcm/src/native_aes.rs
@@ -217,8 +217,8 @@ assert_eq!(flatten_state(c), expected);
} use aes::{ - cipher::{generic_array::GenericArray, BlockDecrypt, BlockEncrypt, BlockSizeUser, KeyInit}, - {Aes128, Aes192, Aes256}, + Aes128, Aes192, Aes256, + cipher::{BlockDecrypt, BlockEncrypt, BlockSizeUser, KeyInit, generic_array::GenericArray}, }; use rand::RngExt; /// test with loop of random-values against a rust well-tested library
M
src/native_gcm.rs
→
aes-gcm/src/native_gcm.rs
@@ -36,7 +36,7 @@ out[..12].copy_from_slice(nonce.as_slice());
out[12..16].copy_from_slice(&[0x00, 0x00, 0x00, 0x01]); out } else { - panic!("unsuported at initial version; nonce.len()=12 (96 bits)"); + panic!("unsupported at initial version; nonce.len()=12 (96 bits)"); }; // 3. C=GCTR()@@ -197,13 +197,13 @@ }
#[cfg(test)] mod tests { - use super::*; - use aes_gcm::{ - aead::{Aead, KeyInit}, Aes128Gcm, Aes256Gcm, Nonce, + aead::{Aead, KeyInit}, }; use rand::Rng; + + use super::*; fn hex_to_array<const N: usize>(h: &str) -> [u8; N] { let bytes = hex::decode(h).unwrap();@@ -266,8 +266,8 @@ fn test_with_external_lib() -> anyhow::Result<()> {
test_with_external_lib_op::<4, 4, 10, Aes128Gcm>()?; test_with_external_lib_op::<8, 4, 14, Aes256Gcm>() } - fn test_with_external_lib_op<const NK: usize, const NB: usize, const NR: usize, C>( - ) -> anyhow::Result<()> + fn test_with_external_lib_op<const NK: usize, const NB: usize, const NR: usize, C>() + -> anyhow::Result<()> where [(); NK * NB]:, [(); 4 * (NR + 1)]:,