Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
xvzcf committed Aug 28, 2023
1 parent 777d04f commit 71a5e9f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/kem/kyber768.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ pub fn decapsulate(
implicit_rejection_value.as_array()
};

let mut to_hash: [u8; SHARED_SECRET_SIZE + H_DIGEST_SIZE] =
to_hash.as_ref().to_padded_array();
let mut to_hash: [u8; SHARED_SECRET_SIZE + H_DIGEST_SIZE] = to_hash.as_ref().to_padded_array();
to_hash[SHARED_SECRET_SIZE..].copy_from_slice(&H(&ciphertext));

KDF(&to_hash)
Expand Down
17 changes: 6 additions & 11 deletions src/kem/kyber768/ntt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ pub(crate) mod kyber_polynomial_ring_element_mod {
zeta_i += 1;

for j in offset..offset + layer {
let t = montgomery_reduce(
re[j + layer] * ZETAS_MONTGOMERY_DOMAIN[zeta_i],
);
let t = montgomery_reduce(re[j + layer] * ZETAS_MONTGOMERY_DOMAIN[zeta_i]);
re[j + layer] = re[j] - t;
re[j] += t;
}
Expand Down Expand Up @@ -79,8 +77,7 @@ pub(crate) mod kyber_polynomial_ring_element_mod {
zeta: i32,
) -> (KyberFieldElement, KyberFieldElement) {
(
montgomery_reduce(a0 * b0)
+ montgomery_reduce(montgomery_reduce(a1 * b1) * zeta),
montgomery_reduce(a0 * b0) + montgomery_reduce(montgomery_reduce(a1 * b1) * zeta),
montgomery_reduce(a0 * b1) + montgomery_reduce(a1 * b0),
)
}
Expand Down Expand Up @@ -165,12 +162,10 @@ pub(crate) fn multiply_matrix_by_column(

// The coefficients of the form aR^{-1} mod q, which means
// calling to_montgomery_domain() on them should return a mod q.
result[i].coefficients = result[i]
.coefficients
.map(|coefficient| {
let coefficient_montgomery = to_montgomery_domain(coefficient);
barrett_reduce(coefficient_montgomery)
});
result[i].coefficients = result[i].coefficients.map(|coefficient| {
let coefficient_montgomery = to_montgomery_domain(coefficient);
barrett_reduce(coefficient_montgomery)
});
}

result
Expand Down

0 comments on commit 71a5e9f

Please sign in to comment.