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

Fhebool boolean block #681

Merged
merged 2 commits into from
Nov 15, 2023
Merged

Fhebool boolean block #681

merged 2 commits into from
Nov 15, 2023

Conversation

tmontaigu
Copy link
Contributor

  • This makes FheBool use integer::BooleanBlock internally.
  • It makes comparisons (eq, ne, le, etc) return a FheBool instead of
    FheUint/FheInt.
  • It also moves the if_then_else and cmux methods to FheBool.
  • Adds casting from FheBool to FheUint/FheInt (but not from
    FheUint/FheInt to FheBool as we expect users to do a.ne(0)
    as its matches Rust)

BREAKING CHANGE:
- Comparisons now return FheBool
- if_then_else/cmux are now methods of FheBool.

And add the trait to the prelude so that users can use
it.
@cla-bot cla-bot bot added the cla-signed label Nov 10, 2023
Copy link

@slab-ci cpu_fast_test

@tmontaigu tmontaigu force-pushed the fhebool-boolean-block branch from 6beae51 to 53f72ed Compare November 10, 2023 15:48
Copy link

@slab-ci cpu_fast_test

@@ -159,7 +195,7 @@ impl FheTryEncrypt<bool, CompressedPublicKey> for crate::FheBool {
fn try_encrypt(value: bool, key: &CompressedPublicKey) -> Result<Self, Self::Error> {
let key = &key.key;
let ciphertext = key.key.encrypt(u64::from(value));
Ok(Self::new(ciphertext))
Ok(Self::new(BooleanBlock::new_unchecked(ciphertext)))
Copy link
Member

Choose a reason for hiding this comment

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

internally those ops still return a shortint ciphertext ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hum, Yeah I haven't added encryt_bool for the different PublicKey types of integer. Should I add them in this PR ?

Copy link
Member

Choose a reason for hiding this comment

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

is it a large change ? otherwise it's fine to put it in a separate PR I would say

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the 2 missing functions

- This makes FheBool use integer::BooleanBlock internally.
- It makes comparisons (eq, ne, le, etc) return a FheBool instead of
  FheUint/FheInt.
- It also moves the if_then_else and cmux methods to FheBool.
- Adds casting from FheBool to FheUint/FheInt (but not from
  FheUint/FheInt to FheBool as we expect users to do `a.ne(0)`
  as its matches Rust)

BREAKING CHANGE:
    - Comparisons now return FheBool
    - if_then_else/cmux are now methods of FheBool.
@tmontaigu tmontaigu force-pushed the fhebool-boolean-block branch from 53f72ed to ac17660 Compare November 14, 2023 14:01
Copy link

@slab-ci cpu_fast_test

Copy link
Member

@IceTDrinker IceTDrinker left a comment

Choose a reason for hiding this comment

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

Thanks a lot !

Copy link

Pull Request has been approved 🎉
Launching full test suite...
@slab-ci cpu_test
@slab-ci cpu_integer_test
@slab-ci cpu_multi_bit_test
@slab-ci cpu_wasm_test
@slab-ci csprng_randomness_testing

@tmontaigu tmontaigu merged commit 916bd8a into main Nov 15, 2023
19 checks passed
@tmontaigu tmontaigu deleted the fhebool-boolean-block branch November 15, 2023 22:22
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.

2 participants