Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(integer): do sum by safe chunk sizes #1512

Merged
merged 1 commit into from
Sep 13, 2024
Merged

fix(integer): do sum by safe chunk sizes #1512

merged 1 commit into from
Sep 13, 2024

Conversation

tmontaigu
Copy link
Contributor

Parameters are made with with assumptions on the number of leveled add/sub/scalar_mul operations are made, so that the noise level before doing a PBS has a correct level and everything is safe, secure and correct.

So the lib implementation has to uphold these assumptions in order to keep the error probability failure correct.

In the comparisons, at some point we had a vector of ciphertexts with a degree == 1, so we greedily summed them (e.g with 2_2 params we summed them by chunks of 15), while it is correct with regards to the carry and message space it is however less correct with regards to the noise level.

Noise wise, doing this huge sum is correct as long as the noise of each ciphertext is independent from the others in the same chunk.

While it may generally be the case we are in, its not guaranteed, and since we do not track that information we have to take the safer approach of assuming the worst case: all noise are dependent.

So to fix the issue we compute the correct size of sum chunk by also taking into account the max noise level.

@cla-bot cla-bot bot added the cla-signed label Sep 4, 2024
@tmontaigu tmontaigu force-pushed the tm/safer-eq-ne branch 3 times, most recently from 96d9842 to 1644cad Compare September 5, 2024 14:11
@tmontaigu tmontaigu force-pushed the tm/safer-eq-ne branch 3 times, most recently from 9f109de to 3e72c87 Compare September 11, 2024 09:36
Comment on lines -2090 to +2091
uint32_t max_value = total_modulus - 1;
uint32_t max_value = (total_modulus - 1) / (params.message_modulus - 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agnesLeroy this is fine as is for our set of parameters dedicated to the blockchain but ideally we need to take the min with the noise level see the tfhe/src/integer/server_key/mod.rs file for the final min with noise level

@IceTDrinker
Copy link
Member

Parameters are made with with assumptions on the number of leveled
add/sub/scalar_mul operations are made, so that the
noise level before doing a PBS has a correct level and everything is
safe, secure and correct.

So the lib implementation has to uphold these assumptions in order to
keep the error probability failure correct.

In the comparisons, at some point we had a vector of ciphertexts with a
degree == 1, so we greedily summed them (e.g with 2_2 params we summed
them by chunks of 15), while it is correct with regards to the carry and
message space it is however less correct with regards to the noise
level.

Noise wise, doing this huge sum is correct as long as the noise of each ciphertext
is independent from the others in the same chunk.

While it may generally be the case we are in, its not guaranteed, and
since we do not track that information we have to take the safer
approach of assuming the worst case: all noise are dependent.

So to fix the issue we compute the correct size of sum chunk by also
taking into account the max noise level.
@zama-bot zama-bot removed the approved label Sep 12, 2024
@tmontaigu tmontaigu merged commit 72ad76b into main Sep 13, 2024
88 checks passed
@tmontaigu tmontaigu deleted the tm/safer-eq-ne branch September 13, 2024 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants