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

Tm/fix signed decomposer #2133

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Tm/fix signed decomposer #2133

wants to merge 1 commit into from

Conversation

tmontaigu
Copy link
Contributor

Some parts of the code did not use the correct way to
decompose a clear integer into blocks which could be encrypted
or used in scalar ops.

The sign extension was not always properly done, leading for example
in the encryption of a negative integer stored on a i8 to a
SignedRadixCiphertext with a num_blocks greater than i8 to be incorrect:

let ct = cks.encrypt_signed(-1i8, 16) // 2_2 parameters
let d: i32 = cks.decrypt_signed(&ct);
assert_eq!(d, i32::from(-1i8)); // Fails

To fix, a BlockDecomposer::with_block_count function is added and used
This function will properly do the sign extension when needed

@cla-bot cla-bot bot added the cla-signed label Feb 28, 2025
@tmontaigu tmontaigu force-pushed the tm/fix-signed-decomposer branch from 55a4d18 to f985a6d Compare February 28, 2025 13:17
@tmontaigu tmontaigu mentioned this pull request Mar 3, 2025
Some parts of the code did not use the correct way to
decompose a clear integer into blocks which could be encrypted
or used in scalar ops.

The sign extension was not always properly done, leading for example
in the encryption of a negative integer stored on a i8 to a
SignedRadixCiphertext with a num_blocks greater than i8 to be incorrect:

```
let ct = cks.encrypt_signed(-1i8, 16) // 2_2 parameters
let d: i32 = cks.decrypt_signed(&ct);
assert_eq!(d, i32::from(-1i8)); // Fails
```

To fix, a BlockDecomposer::with_block_count function is added and used
This function will properly do the sign extension when needed
@tmontaigu tmontaigu force-pushed the tm/fix-signed-decomposer branch from f985a6d to 0f1b77e Compare March 5, 2025 14:31
@tmontaigu tmontaigu marked this pull request as ready for review March 6, 2025 13:23
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.

1 participant