Skip to content

Commit

Permalink
Removed one TODO in NTT.
Browse files Browse the repository at this point in the history
  • Loading branch information
xvzcf committed Oct 27, 2023
1 parent 8aa11d2 commit 9287a20
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
22 changes: 22 additions & 0 deletions proofs/fstar/extraction/Libcrux.Kem.Kyber.Compress.fst
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,28 @@ let decompress_q (#v_COEFFICIENT_BITS: usize) (fe: i32) : i32 =
in
let decompressed:u32 = (decompressed <<! 1l <: u32) +! (1ul <<! v_COEFFICIENT_BITS <: u32) in
let decompressed:u32 = decompressed >>! (v_COEFFICIENT_BITS +! sz 1 <: usize) in
let _:Prims.unit =
if true
then
let _:Prims.unit =
if
~.(decompressed <.
(Core.Result.impl__unwrap (Core.Convert.f_try_from Libcrux.Kem.Kyber.Constants.v_FIELD_MODULUS

<:
Core.Result.t_Result u32 Core.Num.Error.t_TryFromIntError)
<:
u32)
<:
bool)
then
Rust_primitives.Hax.never_to_any (Core.Panicking.panic "assertion failed: decompressed < u32::try_from(FIELD_MODULUS).unwrap()"

<:
Rust_primitives.Hax.t_Never)
in
()
in
cast decompressed <: i32

let decompress
Expand Down
2 changes: 1 addition & 1 deletion proofs/fstar/extraction/Libcrux.Kem.Kyber.Ntt.fst
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ let ntt_vector_u
(#v_VECTOR_U_COMPRESSION_FACTOR: usize)
(re: Libcrux.Kem.Kyber.Arithmetic.t_KyberPolynomialRingElement)
: Libcrux.Kem.Kyber.Arithmetic.t_KyberPolynomialRingElement =
let initial_coefficient_bound:i32 = 3329l in
let initial_coefficient_bound:i32 = 3328l in
let _:Prims.unit =
if true
then
Expand Down
2 changes: 2 additions & 0 deletions src/kem/kyber/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ pub(super) fn decompress_q<const COEFFICIENT_BITS: usize>(
decompressed = (decompressed << 1) + (1 << COEFFICIENT_BITS);
decompressed >>= COEFFICIENT_BITS + 1;

debug_assert!(decompressed < u32::try_from(FIELD_MODULUS).unwrap());

decompressed as KyberFieldElement
}
pub fn decompress<const COEFFICIENT_BITS: usize>(
Expand Down
4 changes: 1 addition & 3 deletions src/kem/kyber/ntt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ pub(in crate::kem::kyber) fn ntt_binomially_sampled_ring_element(
pub(in crate::kem::kyber) fn ntt_vector_u<const VECTOR_U_COMPRESSION_FACTOR: usize>(
mut re: KyberPolynomialRingElement,
) -> KyberPolynomialRingElement {
// TODO: This could be tighter, but we have to analyze other functions
// first before we can say for sure here.
let initial_coefficient_bound = 3329;
let initial_coefficient_bound = 3328;
debug_assert!(re
.coefficients
.into_iter()
Expand Down

0 comments on commit 9287a20

Please sign in to comment.