Skip to content

Commit

Permalink
hax-compatibility: cast match scrutinees
Browse files Browse the repository at this point in the history
  • Loading branch information
jschneider-bensch committed Sep 10, 2024
1 parent df48c90 commit 9bdda4c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion libcrux-ml-dsa/src/simd/avx2/encoding/commitment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use libcrux_intrinsics::avx2::*;
pub fn serialize<const OUTPUT_SIZE: usize>(simd_unit: Vec256) -> [u8; OUTPUT_SIZE] {
let mut serialized = [0u8; 19];

match OUTPUT_SIZE {
match OUTPUT_SIZE as u8 {
4 => {
let adjacent_2_combined =
mm256_sllv_epi32(simd_unit, mm256_set_epi32(0, 28, 0, 28, 0, 28, 0, 28));
Expand Down
4 changes: 2 additions & 2 deletions libcrux-ml-dsa/src/simd/avx2/encoding/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn serialize_when_eta_is_4<const OUTPUT_SIZE: usize>(simd_unit: Vec256) -> [u8;
}
#[inline(always)]
pub fn serialize<const OUTPUT_SIZE: usize>(simd_unit: Vec256) -> [u8; OUTPUT_SIZE] {
match OUTPUT_SIZE {
match OUTPUT_SIZE as u8 {
3 => serialize_when_eta_is_2::<OUTPUT_SIZE>(simd_unit),
4 => serialize_when_eta_is_4::<OUTPUT_SIZE>(simd_unit),
_ => unreachable!(),
Expand Down Expand Up @@ -118,7 +118,7 @@ fn deserialize_to_unsigned_when_eta_is_4(bytes: &[u8]) -> Vec256 {
}
#[inline(always)]
pub(crate) fn deserialize_to_unsigned<const ETA: usize>(serialized: &[u8]) -> Vec256 {
match ETA {
match ETA as u8 {
2 => deserialize_to_unsigned_when_eta_is_2(serialized),
4 => deserialize_to_unsigned_when_eta_is_4(serialized),
_ => unreachable!(),
Expand Down
4 changes: 2 additions & 2 deletions libcrux-ml-dsa/src/simd/avx2/encoding/gamma1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn serialize_when_gamma1_is_2_pow_19<const OUTPUT_SIZE: usize>(

#[inline(always)]
pub(crate) fn serialize<const OUTPUT_SIZE: usize>(simd_unit: Vec256) -> [u8; OUTPUT_SIZE] {
match OUTPUT_SIZE {
match OUTPUT_SIZE as u8 {
18 => serialize_when_gamma1_is_2_pow_17::<OUTPUT_SIZE>(simd_unit),
20 => serialize_when_gamma1_is_2_pow_19::<OUTPUT_SIZE>(simd_unit),
_ => unreachable!(),
Expand Down Expand Up @@ -130,7 +130,7 @@ fn deserialize_when_gamma1_is_2_pow_19(serialized: &[u8]) -> Vec256 {

#[inline(always)]
pub(crate) fn deserialize<const GAMMA1_EXPONENT: usize>(serialized: &[u8]) -> Vec256 {
match GAMMA1_EXPONENT {
match GAMMA1_EXPONENT as u8 {
17 => deserialize_when_gamma1_is_2_pow_17(serialized),
19 => deserialize_when_gamma1_is_2_pow_19(serialized),
_ => unreachable!(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use libcrux_intrinsics::avx2::*;

#[inline(always)]
fn shift_interval<const ETA: usize>(coefficients: Vec256) -> Vec256 {
match ETA {
match ETA as u8 {
2 => {
let quotient = mm256_mullo_epi32(coefficients, mm256_set1_epi32(26));
let quotient = mm256_srai_epi32::<7>(quotient);
Expand All @@ -29,7 +29,7 @@ pub(crate) fn sample<const ETA: usize>(input: &[u8], output: &mut [i32]) -> usiz
// values that are 4-bits wide.
let potential_coefficients = encoding::error::deserialize_to_unsigned::<4>(input);

let interval_boundary: i32 = match ETA {
let interval_boundary: i32 = match ETA as u8 {
2 => 15,
4 => 9,
_ => unreachable!(),
Expand Down

0 comments on commit 9bdda4c

Please sign in to comment.