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

refactor(all): refactor oprf integer and hl APIs #1448

Merged
merged 1 commit into from
Sep 11, 2024
Merged

Conversation

mayeul-zama
Copy link
Contributor

No description provided.

@cla-bot cla-bot bot added the cla-signed label Aug 1, 2024
@mayeul-zama mayeul-zama requested a review from jborfila August 1, 2024 16:20
@mayeul-zama mayeul-zama force-pushed the mz/doc_prf branch 2 times, most recently from 49f19ed to b6edb08 Compare August 2, 2024 16:21
@mayeul-zama mayeul-zama changed the title doc(hlapi): improve PRF documentation refactor(all): refactor oprf integer and hl APIs Aug 2, 2024
Comment on lines 7 to 10
In *TFHE-rs*, this is possible through the method `generate_oblivious_pseudo_random` of `FheUint` and `FheInt`.
It relies on the use of the usual server keys.
The method takes two inputs: a seed `Seed`, which could be any `u128` value and an upper bound on the range of the random values `random_bits_count`.
It outputs a `FheIntN` or `FheUintN`, where `N` is the number of bits of the homomorphic integer.
Copy link
Member

Choose a reason for hiding this comment

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

this is not accurate anymore, the bounded method takes the random_bit_count

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Comment on lines 7 to 10
/// Generates an encrypted `num_block` blocks unsigned integer
/// taken uniformly in `[0, 2^random_bits_count[` using the given seed
/// The encryted value is oblivious to the server
/// It can be useful to make server random generation deterministic
Copy link
Member

Choose a reason for hiding this comment

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

docstring does not match the implem, to check all API levels

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

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.

Still some discrepancy between doc and code as fat as I can see


In *TFHE-rs*, this is possible through the function `generate_oblivious_pseudo_random` of `FheUint` and `FheInt`.
It relies on the use of the usual server keys.
The function takes two inputs: a seed `Seed`, which could be any `u128` value and an upper bound on the range of the random values `random_bits_count`.
Copy link
Member

Choose a reason for hiding this comment

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

this is not right, generate_oblivious_pseudo_random does not take a bit count :/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

This document gives an example of generating pseudo random values in FHE that are not known by the server.
This document explains the mechanism and steps to generate an oblivious encrypted random value using only server keys.

The goal is to give to the server the possibility to generate a random value, which will be obtained in a encrypted format and will remain unknown to the server. The implementation is based on [this article](https://eprint.iacr.org/2024/665).
Copy link
Member

Choose a reason for hiding this comment

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

in a encrypted format -> in an encrypted format

The goal is to give to the server the possibility to generate a random value, which will be obtained in a encrypted format and will remain unknown to the server. The implementation is based on [this article](https://eprint.iacr.org/2024/665).

This is possible through two methods on `FheUint` and `FheInt`:
- `generate_oblivious_pseudo_random` which return an integer taken uniformly in the full integer range (`[0; 2^N[` for a `FheUint_N` and `[-2^(N-1); 2^(N-1)[` for a `FheInt_N`).
Copy link
Member

Choose a reason for hiding this comment

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

FheUintN and FheIntN (no underscores)

// The server cannot know what value was generated
let ct_res = FheUint8::generate_oblivious_pseudo_random(Seed(0), random_bits_count);
let ct_res = FheUint8::generate_oblivious_pseudo_random(Seed(0));

Copy link
Member

Choose a reason for hiding this comment

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

decryption of ct_res ?

@mayeul-zama mayeul-zama merged commit 93ff699 into main Sep 11, 2024
85 of 88 checks passed
@mayeul-zama mayeul-zama deleted the mz/doc_prf branch September 11, 2024 08:49
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.

3 participants