From 6f2129778b49be8ef362d9f29973dbbb85eb8b80 Mon Sep 17 00:00:00 2001 From: Arthur Meyre Date: Wed, 11 Mar 2026 16:25:58 +0100 Subject: [PATCH] chore: fix comment in generate lookup table - at some point the code likely took the padding bit into account, the corresponding comment was left unchanged which was an error - propagate everywhere this comment was copy/pasted --- .../tfhe-cuda-backend/cuda/tests_and_benchmarks/utils.cpp | 2 +- .../algorithms/lwe_programmable_bootstrapping/mod.rs | 4 +++- .../algorithms/test/lwe_programmable_bootstrapping.rs | 4 +++- tfhe/src/core_crypto/hpu/entities/glwe_lookuptable.rs | 2 +- tfhe/src/shortint/engine/mod.rs | 4 ++-- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/backends/tfhe-cuda-backend/cuda/tests_and_benchmarks/utils.cpp b/backends/tfhe-cuda-backend/cuda/tests_and_benchmarks/utils.cpp index 3bb78d3c1e..53ac25d982 100644 --- a/backends/tfhe-cuda-backend/cuda/tests_and_benchmarks/utils.cpp +++ b/backends/tfhe-cuda-backend/cuda/tests_and_benchmarks/utils.cpp @@ -63,7 +63,7 @@ uint64_t *generate_identity_lut_pbs(int polynomial_size, int glwe_dimension, // Modulus of the msg contained in the msg bits and operations buffer uint64_t modulus_sup = message_modulus * carry_modulus; - // N/(p/2) = size of each block + // N/p = size of each box uint64_t box_size = polynomial_size / modulus_sup; // Value of the shift we multiply our messages by diff --git a/tfhe/src/core_crypto/algorithms/lwe_programmable_bootstrapping/mod.rs b/tfhe/src/core_crypto/algorithms/lwe_programmable_bootstrapping/mod.rs index 261370aafc..5954a0467c 100644 --- a/tfhe/src/core_crypto/algorithms/lwe_programmable_bootstrapping/mod.rs +++ b/tfhe/src/core_crypto/algorithms/lwe_programmable_bootstrapping/mod.rs @@ -34,7 +34,9 @@ pub fn generate_programmable_bootstrap_glwe_lut Scalar, { - // N/(p/2) = size of each block, to correct noise from the input we introduce the + // N = polynomial_size + // p = message_modulus + // N/p = size of each box, to correct noise from the input we introduce the // notion of box, which manages redundancy to yield a denoised value // for several noisy values around a true input value. let box_size = polynomial_size.0 / message_modulus; diff --git a/tfhe/src/core_crypto/algorithms/test/lwe_programmable_bootstrapping.rs b/tfhe/src/core_crypto/algorithms/test/lwe_programmable_bootstrapping.rs index a68154111c..54921aa3e5 100644 --- a/tfhe/src/core_crypto/algorithms/test/lwe_programmable_bootstrapping.rs +++ b/tfhe/src/core_crypto/algorithms/test/lwe_programmable_bootstrapping.rs @@ -315,7 +315,9 @@ fn generate_accumulator_many_lut>( delta: Scalar, funcs: &[&dyn Fn(Scalar) -> Scalar], ) -> (GlweCiphertextOwned, usize) { - // N/(p/2) = size of each block, to correct noise from the input we introduce the + // N = polynomial_size + // p = message_modulus + // N/p = size of each box, to correct noise from the input we introduce the // notion of box, which manages redundancy to yield a denoised value // for several noisy values around a true input value. let box_size = polynomial_size.0 / message_modulus; diff --git a/tfhe/src/core_crypto/hpu/entities/glwe_lookuptable.rs b/tfhe/src/core_crypto/hpu/entities/glwe_lookuptable.rs index ced40559e9..306a1ccb82 100644 --- a/tfhe/src/core_crypto/hpu/entities/glwe_lookuptable.rs +++ b/tfhe/src/core_crypto/hpu/entities/glwe_lookuptable.rs @@ -85,7 +85,7 @@ pub fn create_hpu_lookuptable( // Modulus of the msg contained in the msg bits and operations buffer let modulus_sup = 1 << (pbs_p.message_width + pbs_p.carry_width); - // N/(p/2) = size of each block + // N/p = size of each box let box_size = pbs_p.polynomial_size / modulus_sup; // Value of the shift we multiply our messages by diff --git a/tfhe/src/shortint/engine/mod.rs b/tfhe/src/shortint/engine/mod.rs index ee3c87a7b0..e341c86a3e 100644 --- a/tfhe/src/shortint/engine/mod.rs +++ b/tfhe/src/shortint/engine/mod.rs @@ -111,7 +111,7 @@ where // Modulus of the msg contained in the msg bits and operations buffer let input_modulus_sup = (input_message_modulus.0 * input_carry_modulus.0) as usize; - // N/(p/2) = size of each block + // N/p = size of each box let box_size = polynomial_size.0 / input_modulus_sup; let mut body = accumulator_view.get_mut_body(); @@ -193,7 +193,7 @@ where // Modulus of the msg contained in the msg bits and operations buffer let modulus_sup = (message_modulus.0 * carry_modulus.0) as usize; - // N/(p/2) = size of each block + // N/p = size of each box let box_size = polynomial_size.0 / modulus_sup; let mut body = accumulator_view.get_mut_body();