Convert shortint to FheUint8

Hello, is there a function to convert a shortint to an FheUint8, that is basically changing the delta, and vice versa?

hello @Norrin_Radix

you want to use a single shortint ciphertext and use an encoding of 8 bits to use it in the High Level API as an FheUin8, am I understanding this correctly ?

1 Like

Hello, not exactly, I have “short” shortints with 1 bit of message and 1 bit of carry and I want to put the message bit 7 bits lower. So say I have a 1 in a short int, I want a 1 in a FheUint8. And conversely say I have an FhEUint8, I want to be able to spread each message bit over 8 shortint. I guess at low level it’s doable at least with a PBS, but I am searching for functions that achieve that in the API. I know I saw a “changing delta” function somewhere but I don’t remember exactly where. If i can do the first conversion, I can do the second one tediously.

1 Like

so we don’t support this in the HL API (the delta change) so here you are in uncharted territory, also another issue potentially is you won’t have the same carry space as your message space and that is not something the High Level API supports eitner.

Having said that shortint has a private function that does what you want : generate_lookup_table_with_output_encoding the reason we don’t expose it AFAIR is that you need to make sure that the compute parameters will ensure correctness, which means doing noise analysis on the rescaled ciphertexts, which is not something easy to do.

Cheers

ok, not sure I will be able to access that private function then, I need to modify tfhe-rs to make a public one I guess. Related question, you said to compute the multiplication between two shortint, you put the message bit of one ciphertext into the carry of another ciphertext. Did you think about doing it for 3 ciphertexts all at once, using 2 bits of carry? The LUT would still be as short as previously except it would accept 8 entries (000), (001), (010) … instead of 4. Not sure it would represent any advantage though because of the multiple entries.

worst case for the function you should be able to write your own on the model of the existing one (not ideal but we did not plan for people having such needs at the moment)

I think the construction can be generalized as long as the total number of input bits is below the carry + msg capacity of a ciphertext

Cheers

1 Like