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

Compressing Radix Ciphertext #497

Closed
On0n0k1 opened this issue Aug 24, 2023 · 5 comments
Closed

Compressing Radix Ciphertext #497

On0n0k1 opened this issue Aug 24, 2023 · 5 comments

Comments

@On0n0k1
Copy link

On0n0k1 commented Aug 24, 2023

First. Good work in the latest updates. I'm really enjoying each new feature you include in this library.

What is the problem you want to solve and can not with the current version?
While reading the documentation, I found that we can encrypt ciphertexts using CompressedFheUint64. For that, we need to use the high level client keys and server keys. Which doesn't have the same features as the keys from tfhe::integer module.

Describe the solution you'd like

Here is what I want to do: I want to be able to compress ciphers like we can do with CompressedFHEUint64, and be able to use the ServerKey method create_trivial_zero_radix, which is not available in the high level ServerKey API. Can I simply compress the standard RadixCipherText? Couldn't find documentation for it. Encrypting with the client key is slower than creating a zero with the server key.

Describe alternatives you've considered
The high level ServerKey doesn't seem to be as useful as the tfhe::integer::ServerKey type. Using methods from tfhe::integer::ServerKey feel more practical than calling set_server_key and using the standard cypher + 10 calculations.

I just want to be able to call ServerKey::create_trivial_zero_radix then compress the cypher afterward. Is that possible?

Additional context
Maybe the problem is already solved and I just didn't find the type to use in the source. Could you explain to me about it?

@tmontaigu
Copy link
Contributor

tmontaigu commented Aug 24, 2023

Here is what I want to do: I want to be able to compress ciphers like we can do with CompressedFHEUint64, and be able to use the ServerKey method create_trivial_zero_radix, which is not available in the high level ServerKey API. Can I simply compress the standard RadixCipherText? Couldn't find documentation for it. Encrypting with the client key is slower than creating a zero with the server key.

In the higly level API to create a trivial ciphertext you do let a = FheUint8::try_encrypt_trivial(0u8).unwrap();
see https://docs.zama.ai/tfhe-rs/how-to/trivial_ciphertext.

Compressing Ciphertext is only possible as encryption time, so its done using the ClientKey.
So if you prefer the tfhe::integer API then use https://docs.rs/tfhe/0.3.1/tfhe/integer/client_key/struct.ClientKey.html#method.encrypt_radix_compressed

The high level ServerKey doesn't seem to be as useful as the tfhe::integer::ServerKey type. Using methods from tfhe::integer::ServerKey feel more practical than calling set_server_key and using the standard cypher + 10 calculations.

What are you missing exactly ? the HLAPI is just a wrapping of the tfhe::integer::ServerKey so almost everything you can do with a integer::ServerKey you can do with the HLAPI.

I just want to be able to call ServerKey::create_trivial_zero_radix then compress the cypher afterward. Is that possible?

No that is not possible, compressed ciphertext are real encryptions. trivial ciphertext are not real encryptions.

Why do you need to create a trivial zero and compress it ? Do you want to send it ? In that case you are probably doing something not optimal, trivial ciphertext are meant to be created server side, and not be transferred as they are not encryptions anyone can see the value 'encrypted' in a trivial ciphertext.

And note that compressing ciphertext only works when encrypting, once some computations have been done, you cannot recompress the resulting ciphertext

@On0n0k1
Copy link
Author

On0n0k1 commented Aug 24, 2023

Thank you for clearing it up for me. It was my mistake for considering using trivial ciphertexts. Also thanks for the suggestions.

encrypt_radix_compressed was exactly what I was looking for. Thanks for it. I can't tell exactly what I am doing. But when implementing tfhe, we sometimes have to send encrypted data to another for computation, etc. What would you suggest in that case?

@On0n0k1
Copy link
Author

On0n0k1 commented Aug 24, 2023

Also, I didn't know the cargo docs were available with the link you sent: https://docs.rs/tfhe/0.3.1/tfhe/integer/client_key/struct.ClientKey.html#method.encrypt_radix_compressed

I favorited the link so I can use it for quickly searching other details. I recommend including the link on crates.io for other developers.

@tmontaigu
Copy link
Contributor

tmontaigu commented Aug 24, 2023

fhe, we sometimes have to send encrypted data to another for computation, etc. What would you suggest in that case?

sending data to be computed on is what FheUintX::encrypt, CompressedFHEUint64::try_encrypt, tfhe::integer::ClientKey::encrypt/encrypt_radix/radix_compressed are for.

However ciphertext resulting from encrypt trivial should never be shared as they are not encryptions

I favorited the link so I can use it for quickly searching other details. I recommend including the link on crates.io for other developers.

In the docs at https://docs.zama.ai/tfhe-rs there is a link to the docs.rs docs (API References in the end of the sidebar)

@On0n0k1
Copy link
Author

On0n0k1 commented Aug 24, 2023

Thank you very much. I'm closing this issue then. This solved all my questions.

Have a nice day.

@On0n0k1 On0n0k1 closed this as completed Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants