Skip to content

Commit 14d5b6d

Browse files
committed
ga update
1 parent 346b6f8 commit 14d5b6d

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

.github/workflows/test.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ jobs:
5353

5454

5555
# TODO: Temp 'fix' for Rust 1.80/1.81 problem involving 'time'; to be unwound...
56-
# cargo_outdated:
57-
# runs-on: ubuntu-latest
58-
# steps:
59-
# - uses: actions/checkout@v4
60-
# - uses: dtolnay/rust-toolchain@stable
61-
# - name: Install cargo outdated
62-
# run: cargo install --locked cargo-outdated
63-
# - name: Run cargo outdated
64-
# run: cargo outdated -R
56+
cargo_outdated:
57+
runs-on: ubuntu-latest
58+
steps:
59+
- uses: actions/checkout@v4
60+
- uses: dtolnay/rust-toolchain@stable
61+
- name: Install cargo outdated
62+
run: cargo install --locked cargo-outdated
63+
- name: Run cargo outdated
64+
run: cargo outdated -R
6565

6666

6767
clippy:

src/helpers.rs

+15-4
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,17 @@ pub(crate) fn mat_vec_mul<const K: usize, const L: usize>(
117117
w_hat
118118
}
119119

120-
// Algorithm 44: `AddNTT()` and Algorithm 46 `AddVectorNTT()`
121-
/// Vector addition; e.g., fips 203 bottom of page 9, second row: `z_hat` = `u_hat` + `v_hat`
120+
121+
// Note Algorithm 44 has been dissolved into its place of use(s)
122+
123+
/// Algorithm 46: `AddVectorNTT(v_hat, w_hat)` on page 45.
124+
/// Computes the sum `v_hat + w_hat` of two vectors `v_hat`, `w_hat` over `𝑇_𝑞`.
125+
///
126+
/// **Input**: `ℓ ∈ ℕ, v_hat ∈ 𝑇_𝑞^ℓ , w_hat ∈ 𝑇_𝑞^ℓ`. <br>
127+
/// **Output**: `u_hat ∈ 𝑇_𝑞^ℓ`.
122128
#[must_use]
123-
pub(crate) fn add_vector_ntt<const K: usize>(vec_a: &[R; K], vec_b: &[R; K]) -> [R; K] {
124-
core::array::from_fn(|k| R(core::array::from_fn(|n| vec_a[k].0[n] + vec_b[k].0[n])))
129+
pub(crate) fn add_vector_ntt<const K: usize>(v_hat: &[R; K], w_hat: &[R; K]) -> [R; K] {
130+
core::array::from_fn(|k| R(core::array::from_fn(|n| v_hat[k].0[n] + w_hat[k].0[n])))
125131
}
126132

127133

@@ -145,6 +151,11 @@ pub(crate) fn infinity_norm<const ROW: usize>(w: &[R; ROW]) -> i32 {
145151
}
146152

147153

154+
/// Algorithm 49: MontgomeryReduce(𝑎) on page 50.
155+
/// Computes 𝑎 ⋅ 2−32 mod 𝑞.
156+
///
157+
/// **Input**: Integer 𝑎 with −231 𝑞 ≤ 𝑎 ≤ 231 𝑞.
158+
/// **Output**: 𝑟 ≡ 𝑎 ⋅ 2−32 mod 𝑞.
148159
#[allow(clippy::cast_possible_truncation)] // a as i32, res as i32
149160
pub(crate) const fn mont_reduce(a: i64) -> i32 {
150161
const QINV: i32 = 58_728_449; // (Q * QINV) % 2**32 = 1

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
// Algorithm 40 UseHint(h,r) on page 41 --> high_low.rs
6868
// Algorithm 41 NTT(w) on page 43 --> ntt.rs
6969
// Algorithm 42 NTT−1(wˆ) on page 44 --> ntt.rs
70-
// Algorithm 43 BitRev8(m) on page 44 --> helpers.rs
70+
// Algorithm 43 BitRev8(m) on page 44 --> not needed to to zeta table
7171
// Algorithm 44 AddNTT(a,b)̂ on page 45 --> helpers.rs
7272
// Algorithm 45 MultiplyNTT(a,b)̂ on page 45 --> helpers.rs
7373
// Algorithm 46 AddVectorNTT(v,w) on page 45 --> helpers.rs

0 commit comments

Comments
 (0)