From f8ee0b36492fff2c3a64cb51deab845a901e6321 Mon Sep 17 00:00:00 2001 From: Arthur Meyre Date: Wed, 3 Dec 2025 17:59:35 +0100 Subject: [PATCH] chore: add comment on the value causing issues in 64 bits decomp tests --- tfhe/src/core_crypto/commons/math/decomposition/tests.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tfhe/src/core_crypto/commons/math/decomposition/tests.rs b/tfhe/src/core_crypto/commons/math/decomposition/tests.rs index 8612e0b8a..600e623ec 100644 --- a/tfhe/src/core_crypto/commons/math/decomposition/tests.rs +++ b/tfhe/src/core_crypto/commons/math/decomposition/tests.rs @@ -228,6 +228,10 @@ fn test_single_level_decompose_balanced() { #[test] fn test_decomposition_edge_case_sign_handling() { let decomposer = SignedDecomposer::new(DecompositionBaseLog(17), DecompositionLevelCount(3)); + // This value triggers a negative state at the start of the decomposition, invalid code using + // logic shift will wrongly compute an intermediate value by not keeping the sign of the + // state on the last level if base_log * (level_count + 1) > Scalar::BITS, the logic shift will + // shift in 0s instead of the 1s to keep the sign information let val: u64 = 0x8000_00e3_55b0_c827; let rounded = decomposer.closest_representable(val);