Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 116 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ rand = "0.8.5"
log = "0.4"
env_logger = "0.10.0"

dusk-plonk = "0.13"

[profile.bench]
opt-level = 3
debug = false
Expand Down
16 changes: 8 additions & 8 deletions src/aes_circuit.rs → src/aes_circuit/marlin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ pub fn lookup_table(cs: ConstraintSystemRef) -> Result<Vec<UInt8Gadget>> {

#[cfg(test)]
mod tests {
use crate::aes_circuit;
use crate::marlin;
use ark_r1cs_std::{prelude::AllocVar, R1CSVar};
use ark_relations::r1cs::ConstraintSystem;
use simpleworks::gadgets::{ConstraintF, UInt8Gadget};
Expand Down Expand Up @@ -723,7 +723,7 @@ mod tests {
0x48, 0x08,
];

let after_add_round_key = aes_circuit::add_round_key(&plaintext, &secret_key).unwrap();
let after_add_round_key = marlin::add_round_key(&plaintext, &secret_key).unwrap();

assert_eq!(
after_add_round_key.value().unwrap(),
Expand All @@ -748,7 +748,7 @@ mod tests {
0x26, 0x4c,
];

let mixed_column_vector = aes_circuit::mix_columns(&value_to_mix, cs.clone()).unwrap();
let mixed_column_vector = marlin::mix_columns(&value_to_mix, cs.clone()).unwrap();

assert_eq!(
mixed_column_vector.value().unwrap(),
Expand Down Expand Up @@ -787,7 +787,7 @@ mod tests {
value_to_shift.get(11).unwrap(),
];

let res = aes_circuit::shift_rows(&value_to_shift, cs.clone());
let res = marlin::shift_rows(&value_to_shift, cs.clone());
for (index, byte) in res.unwrap().iter().enumerate() {
assert_eq!(byte.value(), expected.get(index).unwrap().value());
}
Expand All @@ -797,7 +797,7 @@ mod tests {
#[test]
fn test_one_round_sub_bytes_circuit() {
let cs = ConstraintSystem::<ConstraintF>::new_ref();
let lookup_table = aes_circuit::lookup_table(cs.clone()).unwrap();
let lookup_table = marlin::lookup_table(cs.clone()).unwrap();
let value_to_substitute = UInt8Gadget::new_witness_vec(
ark_relations::ns!(cs, "value_to_mix"),
&[
Expand All @@ -813,7 +813,7 @@ mod tests {
];

let substituted_value =
aes_circuit::substitute_bytes(&value_to_substitute, &lookup_table).unwrap();
marlin::substitute_bytes(&value_to_substitute, &lookup_table).unwrap();

assert_eq!(
substituted_value.value().unwrap(),
Expand All @@ -824,7 +824,7 @@ mod tests {
#[test]
fn key_expansion_circuit() {
let cs = ConstraintSystem::<ConstraintF>::new_ref();
let lookup_table = aes_circuit::lookup_table(cs.clone()).unwrap();
let lookup_table = marlin::lookup_table(cs.clone()).unwrap();
let secret_key = UInt8Gadget::new_witness_vec(
cs.clone(),
&[
Expand All @@ -833,7 +833,7 @@ mod tests {
],
)
.unwrap();
let result = aes_circuit::derive_keys(&secret_key, &lookup_table, cs).unwrap();
let result = marlin::derive_keys(&secret_key, &lookup_table, cs).unwrap();

assert_eq!(
result.get(10).unwrap().value().unwrap(),
Expand Down
2 changes: 2 additions & 0 deletions src/aes_circuit/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod marlin;
pub mod plonk;
Loading