Skip to content

Commit

Permalink
Import instead of using path
Browse files Browse the repository at this point in the history
  • Loading branch information
jschneider-bensch committed Sep 25, 2024
1 parent bef5651 commit 83fe42e
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions libcrux-ml-dsa/src/simd/portable/ntt.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::arithmetic;
use super::arithmetic::{self, montgomery_multiply_fe_by_fer};
use crate::simd::{
portable::PortableSIMDUnit,
traits::{
Expand All @@ -15,19 +15,19 @@ pub fn simd_unit_ntt_at_layer_0(
zeta2: i32,
zeta3: i32,
) -> PortableSIMDUnit {
let t = arithmetic::montgomery_multiply_fe_by_fer(simd_unit.coefficients[1], zeta0);
let t = montgomery_multiply_fe_by_fer(simd_unit.coefficients[1], zeta0);
simd_unit.coefficients[1] = simd_unit.coefficients[0] - t;
simd_unit.coefficients[0] = simd_unit.coefficients[0] + t;

let t = arithmetic::montgomery_multiply_fe_by_fer(simd_unit.coefficients[3], zeta1);
let t = montgomery_multiply_fe_by_fer(simd_unit.coefficients[3], zeta1);
simd_unit.coefficients[3] = simd_unit.coefficients[2] - t;
simd_unit.coefficients[2] = simd_unit.coefficients[2] + t;

let t = arithmetic::montgomery_multiply_fe_by_fer(simd_unit.coefficients[5], zeta2);
let t = montgomery_multiply_fe_by_fer(simd_unit.coefficients[5], zeta2);
simd_unit.coefficients[5] = simd_unit.coefficients[4] - t;
simd_unit.coefficients[4] = simd_unit.coefficients[4] + t;

let t = arithmetic::montgomery_multiply_fe_by_fer(simd_unit.coefficients[7], zeta3);
let t = montgomery_multiply_fe_by_fer(simd_unit.coefficients[7], zeta3);
simd_unit.coefficients[7] = simd_unit.coefficients[6] - t;
simd_unit.coefficients[6] = simd_unit.coefficients[6] + t;

Expand All @@ -39,39 +39,39 @@ pub fn simd_unit_ntt_at_layer_1(
zeta1: i32,
zeta2: i32,
) -> PortableSIMDUnit {
let t = arithmetic::montgomery_multiply_fe_by_fer(simd_unit.coefficients[2], zeta1);
let t = montgomery_multiply_fe_by_fer(simd_unit.coefficients[2], zeta1);
simd_unit.coefficients[2] = simd_unit.coefficients[0] - t;
simd_unit.coefficients[0] = simd_unit.coefficients[0] + t;

let t = arithmetic::montgomery_multiply_fe_by_fer(simd_unit.coefficients[3], zeta1);
let t = montgomery_multiply_fe_by_fer(simd_unit.coefficients[3], zeta1);
simd_unit.coefficients[3] = simd_unit.coefficients[1] - t;
simd_unit.coefficients[1] = simd_unit.coefficients[1] + t;

let t = arithmetic::montgomery_multiply_fe_by_fer(simd_unit.coefficients[6], zeta2);
let t = montgomery_multiply_fe_by_fer(simd_unit.coefficients[6], zeta2);
simd_unit.coefficients[6] = simd_unit.coefficients[4] - t;
simd_unit.coefficients[4] = simd_unit.coefficients[4] + t;

let t = arithmetic::montgomery_multiply_fe_by_fer(simd_unit.coefficients[7], zeta2);
let t = montgomery_multiply_fe_by_fer(simd_unit.coefficients[7], zeta2);
simd_unit.coefficients[7] = simd_unit.coefficients[5] - t;
simd_unit.coefficients[5] = simd_unit.coefficients[5] + t;

simd_unit
}
#[inline(always)]
pub fn simd_unit_ntt_at_layer_2(mut simd_unit: PortableSIMDUnit, zeta: i32) -> PortableSIMDUnit {
let t = arithmetic::montgomery_multiply_fe_by_fer(simd_unit.coefficients[4], zeta);
let t = montgomery_multiply_fe_by_fer(simd_unit.coefficients[4], zeta);
simd_unit.coefficients[4] = simd_unit.coefficients[0] - t;
simd_unit.coefficients[0] = simd_unit.coefficients[0] + t;

let t = arithmetic::montgomery_multiply_fe_by_fer(simd_unit.coefficients[5], zeta);
let t = montgomery_multiply_fe_by_fer(simd_unit.coefficients[5], zeta);
simd_unit.coefficients[5] = simd_unit.coefficients[1] - t;
simd_unit.coefficients[1] = simd_unit.coefficients[1] + t;

let t = arithmetic::montgomery_multiply_fe_by_fer(simd_unit.coefficients[6], zeta);
let t = montgomery_multiply_fe_by_fer(simd_unit.coefficients[6], zeta);
simd_unit.coefficients[6] = simd_unit.coefficients[2] - t;
simd_unit.coefficients[2] = simd_unit.coefficients[2] + t;

let t = arithmetic::montgomery_multiply_fe_by_fer(simd_unit.coefficients[7], zeta);
let t = montgomery_multiply_fe_by_fer(simd_unit.coefficients[7], zeta);
simd_unit.coefficients[7] = simd_unit.coefficients[3] - t;
simd_unit.coefficients[3] = simd_unit.coefficients[3] + t;

Expand All @@ -88,19 +88,19 @@ pub fn invert_ntt_at_layer_0(
) -> PortableSIMDUnit {
let a_minus_b = simd_unit.coefficients[1] - simd_unit.coefficients[0];
simd_unit.coefficients[0] = simd_unit.coefficients[0] + simd_unit.coefficients[1];
simd_unit.coefficients[1] = arithmetic::montgomery_multiply_fe_by_fer(a_minus_b, zeta0);
simd_unit.coefficients[1] = montgomery_multiply_fe_by_fer(a_minus_b, zeta0);

let a_minus_b = simd_unit.coefficients[3] - simd_unit.coefficients[2];
simd_unit.coefficients[2] = simd_unit.coefficients[2] + simd_unit.coefficients[3];
simd_unit.coefficients[3] = arithmetic::montgomery_multiply_fe_by_fer(a_minus_b, zeta1);
simd_unit.coefficients[3] = montgomery_multiply_fe_by_fer(a_minus_b, zeta1);

let a_minus_b = simd_unit.coefficients[5] - simd_unit.coefficients[4];
simd_unit.coefficients[4] = simd_unit.coefficients[4] + simd_unit.coefficients[5];
simd_unit.coefficients[5] = arithmetic::montgomery_multiply_fe_by_fer(a_minus_b, zeta2);
simd_unit.coefficients[5] = montgomery_multiply_fe_by_fer(a_minus_b, zeta2);

let a_minus_b = simd_unit.coefficients[7] - simd_unit.coefficients[6];
simd_unit.coefficients[6] = simd_unit.coefficients[6] + simd_unit.coefficients[7];
simd_unit.coefficients[7] = arithmetic::montgomery_multiply_fe_by_fer(a_minus_b, zeta3);
simd_unit.coefficients[7] = montgomery_multiply_fe_by_fer(a_minus_b, zeta3);

simd_unit
}
Expand All @@ -112,39 +112,39 @@ pub fn invert_ntt_at_layer_1(
) -> PortableSIMDUnit {
let a_minus_b = simd_unit.coefficients[2] - simd_unit.coefficients[0];
simd_unit.coefficients[0] = simd_unit.coefficients[0] + simd_unit.coefficients[2];
simd_unit.coefficients[2] = arithmetic::montgomery_multiply_fe_by_fer(a_minus_b, zeta0);
simd_unit.coefficients[2] = montgomery_multiply_fe_by_fer(a_minus_b, zeta0);

let a_minus_b = simd_unit.coefficients[3] - simd_unit.coefficients[1];
simd_unit.coefficients[1] = simd_unit.coefficients[1] + simd_unit.coefficients[3];
simd_unit.coefficients[3] = arithmetic::montgomery_multiply_fe_by_fer(a_minus_b, zeta0);
simd_unit.coefficients[3] = montgomery_multiply_fe_by_fer(a_minus_b, zeta0);

let a_minus_b = simd_unit.coefficients[6] - simd_unit.coefficients[4];
simd_unit.coefficients[4] = simd_unit.coefficients[4] + simd_unit.coefficients[6];
simd_unit.coefficients[6] = arithmetic::montgomery_multiply_fe_by_fer(a_minus_b, zeta1);
simd_unit.coefficients[6] = montgomery_multiply_fe_by_fer(a_minus_b, zeta1);

let a_minus_b = simd_unit.coefficients[7] - simd_unit.coefficients[5];
simd_unit.coefficients[5] = simd_unit.coefficients[5] + simd_unit.coefficients[7];
simd_unit.coefficients[7] = arithmetic::montgomery_multiply_fe_by_fer(a_minus_b, zeta1);
simd_unit.coefficients[7] = montgomery_multiply_fe_by_fer(a_minus_b, zeta1);

simd_unit
}
#[inline(always)]
pub fn invert_ntt_at_layer_2(mut simd_unit: PortableSIMDUnit, zeta: i32) -> PortableSIMDUnit {
let a_minus_b = simd_unit.coefficients[4] - simd_unit.coefficients[0];
simd_unit.coefficients[0] = simd_unit.coefficients[0] + simd_unit.coefficients[4];
simd_unit.coefficients[4] = arithmetic::montgomery_multiply_fe_by_fer(a_minus_b, zeta);
simd_unit.coefficients[4] = montgomery_multiply_fe_by_fer(a_minus_b, zeta);

let a_minus_b = simd_unit.coefficients[5] - simd_unit.coefficients[1];
simd_unit.coefficients[1] = simd_unit.coefficients[1] + simd_unit.coefficients[5];
simd_unit.coefficients[5] = arithmetic::montgomery_multiply_fe_by_fer(a_minus_b, zeta);
simd_unit.coefficients[5] = montgomery_multiply_fe_by_fer(a_minus_b, zeta);

let a_minus_b = simd_unit.coefficients[6] - simd_unit.coefficients[2];
simd_unit.coefficients[2] = simd_unit.coefficients[2] + simd_unit.coefficients[6];
simd_unit.coefficients[6] = arithmetic::montgomery_multiply_fe_by_fer(a_minus_b, zeta);
simd_unit.coefficients[6] = montgomery_multiply_fe_by_fer(a_minus_b, zeta);

let a_minus_b = simd_unit.coefficients[7] - simd_unit.coefficients[3];
simd_unit.coefficients[3] = simd_unit.coefficients[3] + simd_unit.coefficients[7];
simd_unit.coefficients[7] = arithmetic::montgomery_multiply_fe_by_fer(a_minus_b, zeta);
simd_unit.coefficients[7] = montgomery_multiply_fe_by_fer(a_minus_b, zeta);

simd_unit
}
Expand Down

0 comments on commit 83fe42e

Please sign in to comment.