Skip to content

Commit e3cf8a8

Browse files
committed
add aes example transactions
1 parent beb02ef commit e3cf8a8

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

tests/aes128.prot

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// src: https://github.com/ekiwi/paso/blob/ad2bf83f420ca704ff0e76e7a583791a0e80a545/benchmarks/src/benchmarks/aes/TinyAESSpec.scala#L220
2+
3+
struct TinyAES128 {
4+
in key: u128,
5+
in state: u128,
6+
out output: u128,
7+
}
8+
9+
fn aes128<dut : TinyAES128>(in key: u128, in state: u128, out output: u128) {
10+
dut.state := state;
11+
dut.key := key;
12+
step();
13+
fork();
14+
dut.state := X;
15+
dut.key := X;
16+
// twenty cycles to complete
17+
step(20);
18+
assert_eq(dut.output, output);
19+
}

tests/aes128_expand_key.prot

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// src: https://github.com/ekiwi/paso/blob/ad2bf83f420ca704ff0e76e7a583791a0e80a545/benchmarks/src/benchmarks/aes/TinyAESSpec.scala#L179
2+
3+
struct ExpandKey128 {
4+
in input: u128,
5+
out output: u128,
6+
out output_delayed: u128,
7+
}
8+
9+
fn aes128<dut : ExpandKey128>(in input: u128, out output: u128) {
10+
dut.input := input;
11+
step();
12+
fork();
13+
dut.input := X;
14+
assert_eq(dut.output, output);
15+
step();
16+
assert_eq(dut.output_delayed, output);
17+
}

tests/aes128_round.prot

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// src: https://github.com/ekiwi/paso/blob/ad2bf83f420ca704ff0e76e7a583791a0e80a545/benchmarks/src/benchmarks/aes/TinyAESSpec.scala#L164
2+
3+
struct RoundIO {
4+
in state: u128,
5+
in key: u128,
6+
out state_next: u128,
7+
}
8+
9+
fn aes128<dut : RoundIO>(in key: u128, in state: u128, out output: u128) {
10+
dut.state := state;
11+
step();
12+
fork();
13+
dut.state := X;
14+
dut.key := key;
15+
step();
16+
dut.key := X;
17+
assert_eq(dut.state_next, output);
18+
}

0 commit comments

Comments
 (0)