binius_field/arch/portable/
packed_aes_16.rs

1// Copyright 2024-2025 Irreducible Inc.
2
3use super::{
4	packed::{impl_broadcast, PackedPrimitiveType},
5	packed_arithmetic::impl_tower_constants,
6};
7use crate::{
8	arch::{PackedStrategy, PairwiseRecursiveStrategy, PairwiseStrategy, PairwiseTableStrategy},
9	arithmetic_traits::{
10		impl_invert_with, impl_mul_alpha_with, impl_mul_with, impl_square_with,
11		impl_transformation_with_strategy,
12	},
13	AESTowerField16b, AESTowerField8b,
14};
15
16// Define 16 bit packed field types
17pub type PackedAESBinaryField2x8b = PackedPrimitiveType<u16, AESTowerField8b>;
18pub type PackedAESBinaryField1x16b = PackedPrimitiveType<u16, AESTowerField16b>;
19
20// Define broadcast
21impl_broadcast!(u16, AESTowerField8b);
22impl_broadcast!(u16, AESTowerField16b);
23
24// Define constants
25impl_tower_constants!(AESTowerField8b, u16, 0x00d3);
26
27// Define multiplication
28impl_mul_with!(PackedAESBinaryField2x8b @ PairwiseTableStrategy);
29impl_mul_with!(PackedAESBinaryField1x16b @ PairwiseRecursiveStrategy);
30
31// Define square
32impl_square_with!(PackedAESBinaryField2x8b @ PairwiseTableStrategy);
33impl_square_with!(PackedAESBinaryField1x16b @ PairwiseRecursiveStrategy);
34
35// Define invert
36impl_invert_with!(PackedAESBinaryField2x8b @ PairwiseTableStrategy);
37impl_invert_with!(PackedAESBinaryField1x16b @ PairwiseRecursiveStrategy);
38
39// Define multiply by alpha
40impl_mul_alpha_with!(PackedAESBinaryField2x8b @ PairwiseTableStrategy);
41impl_mul_alpha_with!(PackedAESBinaryField1x16b @ PackedStrategy);
42
43// Define linear transformations
44impl_transformation_with_strategy!(PackedAESBinaryField2x8b, PackedStrategy);
45impl_transformation_with_strategy!(PackedAESBinaryField1x16b, PairwiseStrategy);