diff --git a/crates/binius-mayo/Cargo.toml b/crates/binius-mayo/Cargo.toml index de13d44..f0f1286 100644 --- a/crates/binius-mayo/Cargo.toml +++ b/crates/binius-mayo/Cargo.toml @@ -29,7 +29,7 @@ binius-prover = { git = "https://github.com/binius-zk/binius64", rev = "3bc7 binius-verifier = { git = "https://github.com/binius-zk/binius64", rev = "3bc7451dc3c52af6383fcd99892c6892f57e89b0" } binius-hash = { git = "https://github.com/binius-zk/binius64", rev = "3bc7451dc3c52af6383fcd99892c6892f57e89b0" } sha3 = "=0.10.9" -aes = "=0.8.4" +aes = "=0.9.2" rand = "0.10" [dev-dependencies] diff --git a/crates/binius-mayo/src/api.rs b/crates/binius-mayo/src/api.rs index 62895c2..33933e1 100644 --- a/crates/binius-mayo/src/api.rs +++ b/crates/binius-mayo/src/api.rs @@ -34,9 +34,9 @@ use std::fmt; use aes::{ Aes128, cipher::{ - BlockEncrypt, + Block, + BlockCipherEncrypt, KeyInit, - generic_array::GenericArray, }, }; use binius_core::word::Word; @@ -666,7 +666,7 @@ fn expand_pk_to_lanes(cpk: &[u8; CPK_BYTES]) -> PkLanes { .expect("CPK_BYTES >= PK_SEED_BYTES"); let p3_packed = &cpk[PK_SEED_BYTES..CPK_BYTES]; - let cipher = Aes128::new(GenericArray::from_slice(pk_seed)); + let cipher = Aes128::new_from_slice(pk_seed).expect("pk_seed must be 16 bytes"); let mut counter: u32 = 0; let mut fill_entry = |entry: &mut [u8; M]| { @@ -674,7 +674,8 @@ fn expand_pk_to_lanes(cpk: &[u8; CPK_BYTES]) -> PkLanes { let mut block = [0u8; 16]; block[12..16].copy_from_slice(&counter.to_be_bytes()); counter = counter.wrapping_add(1); - let mut blk = GenericArray::clone_from_slice(&block); + let mut blk = Block::::default(); + blk.copy_from_slice(&block); cipher.encrypt_block(&mut blk); let off = half * 32; for b in 0..16 { diff --git a/crates/binius-mayo/tests/common/oracle.rs b/crates/binius-mayo/tests/common/oracle.rs index 307311f..a804bb4 100644 --- a/crates/binius-mayo/tests/common/oracle.rs +++ b/crates/binius-mayo/tests/common/oracle.rs @@ -11,9 +11,9 @@ use aes::{ Aes128, cipher::{ - BlockEncrypt, + Block, + BlockCipherEncrypt, KeyInit, - generic_array::GenericArray, }, }; use sha3::{ @@ -299,26 +299,23 @@ pub fn mul_gf16(a: u8, b: u8) -> u8 { /// fallback `aes_c.c`: `iv[16] = {0}` and `ivw[3] = swap32(cc)` → /// counter occupies bytes 12..15 big-endian, starting at 0). fn aes128_ctr_keystream(pk_seed: &[u8; PK_SEED_BYTES], output_len: usize) -> Vec { - let key = GenericArray::from_slice(pk_seed); - let cipher = Aes128::new(key); + let cipher = Aes128::new_from_slice(pk_seed).expect("pk_seed must be 16 bytes"); let n_full = output_len / 16; let tail = output_len % 16; let mut out = vec![0u8; output_len]; for i in 0..n_full { - let mut block = [0u8; 16]; + let mut block = Block::::default(); block[12..16].copy_from_slice(&(i as u32).to_be_bytes()); - let mut blk = GenericArray::clone_from_slice(&block); - cipher.encrypt_block(&mut blk); - out[i * 16..(i + 1) * 16].copy_from_slice(blk.as_slice()); + cipher.encrypt_block(&mut block); + out[i * 16..(i + 1) * 16].copy_from_slice(block.as_slice()); } if tail > 0 { - let mut block = [0u8; 16]; + let mut block = Block::::default(); block[12..16].copy_from_slice(&(n_full as u32).to_be_bytes()); - let mut blk = GenericArray::clone_from_slice(&block); - cipher.encrypt_block(&mut blk); - out[n_full * 16..n_full * 16 + tail].copy_from_slice(&blk.as_slice()[..tail]); + cipher.encrypt_block(&mut block); + out[n_full * 16..n_full * 16 + tail].copy_from_slice(&block.as_slice()[..tail]); } out }