plonky2-crypto-gadgets/src/lib.rs
src/lib.rsRaw
1//! For LICENSE check out https://github.com/0xPARC/plonky2-aes/blob/main/LICENSE
2#![allow(incomplete_features)]
3#![feature(generic_const_exprs)]
4#![allow(dead_code)] // TMP
5
6pub mod circuit_aes;
7pub mod circuit_gcm;
8pub mod constants;
9pub mod native_aes;
10pub mod native_gcm;
11
12/// D defines the extension degree of the field used in the Plonky2 proofs (quadratic extension).
13pub const D: usize = 2;
14
15pub use circuit_aes::{ByteTarget, PartialWitnessByteArray};
16
17use circuit_gcm::AesGcmTarget;
18// use native_gcm::TAG_LEN;
19// use plonky2::{
20// field::goldilocks_field::GoldilocksField as F, plonk::circuit_builder::CircuitBuilder,
21// };
22
23pub type AesGcm128Target<const L: usize> = AesGcmTarget<4, 4, 10, L, false>;
24pub const KEY_LEN_128: usize = 4 * 4;
25// pub fn aes128_encrypt_target<const L: usize>(
26// builder: &mut CircuitBuilder<F, D>,
27// key: [ByteTarget; 4 * 4],
28// nonce: &[ByteTarget; 12],
29// pt: &[ByteTarget; L],
30// ) -> ([ByteTarget; L], [ByteTarget; TAG_LEN / 8]) {
31// encrypt_target::<4, 4, 10, L, false>(builder, key, &nonce, &pt)
32// }
33
34pub type AesGcm192Target<const L: usize> = AesGcmTarget<6, 4, 12, L, false>;
35// pub const KEY_LEN_192: usize = 6 * 4;
36// pub fn aes192_encrypt_target<const L: usize>(
37// builder: &mut CircuitBuilder<F, D>,
38// key: [ByteTarget; 6 * 4],
39// nonce: &[ByteTarget; 12],
40// pt: &[ByteTarget; L],
41// ) -> ([ByteTarget; L], [ByteTarget; TAG_LEN / 8]) {
42// encrypt_target::<6, 4, 12, L, false>(builder, key, &nonce, &pt)
43// }
44
45pub type AesGcm256Target<const L: usize> = AesGcmTarget<8, 4, 14, L, false>;
46// pub const KEY_LEN_256: usize = 8 * 4;
47// pub fn aes256_encrypt_target<const L: usize>(
48// builder: &mut CircuitBuilder<F, D>,
49// key: [ByteTarget; 8 * 4],
50// nonce: &[ByteTarget; 12],
51// pt: &[ByteTarget; L],
52// ) -> ([ByteTarget; L], [ByteTarget; TAG_LEN / 8]) {
53// encrypt_target::<8, 4, 14, L, false>(builder, key, &nonce, &pt)
54// }