How can I generate the data of each step in binfhe?

Hi, there. Does anyone know the relation between directed output data and the serialized output data (in binary or json format)?

For example, in “boolean-serial-json.cpp”, the output ciphertext I had is

  1. directed output data
// Encryption for a ciphertext that will be serialized
    auto ct1 = cc1.Encrypt(sk1, 1);
    std::cout << "ct1: " << ct1 << std::endl;

pic1: directed output data

and 2. serialized output data in json

// Encryption for a ciphertext that will be serialized
    auto ct1 = cc1.Encrypt(sk1, 1);

    if (!Serial::SerializeToFile(DATAFOLDER + "/ct1.txt", ct1, SerType::JSON)) {
        std::cerr << "Error serializing ct1" << std::endl;
        return 1;
    }
    std::cout << "A ciphertext has been serialized." << std::endl;

pic2: serialized output data in json

,but I cannot find out the relation between them.

Besides, because lack of the information of parameters (I’m still not figure out how to output the dimension, modulus… in this toy example), so I’m not sure why the LWECiphertext output would be like pic1. Does it be the concatenated number in the LWECiphertext (I supposed it to be a length n vector)?

I had seen the discussion on RNS-CKKS in the previous discuss(ex. the GetElements method), but it seems that there are some differences when using the library.

Looking forward to pointing me out and thanks for your reading.

How familiar are you with C++? Because ct1 is a pointer, not actual data (as is in JSON). Meaning you’re “printing” an address in memory there.

At a higher level, what exactly are you trying to do?

Hi @iquah ,
Thanks for the reply and sorry for didn’t realize this is a basic question of C++…(I’m not so familiar with it.)

At a high level, I would like to generate the intermediate result ciphertext in each step of TFHE bootstrapping (for example the ciphertext after modulus switching, blind rotation, key switching, etc.) and the params it had.

Thanks for the reading.

Absolutely no worries! It’s basic, but we all start somewhere.

At a high level, I would like to generate the intermediate result ciphertext in each step of TFHE bootstrapping (for example the ciphertext after modulus switching, blind rotation, key switching, etc.) and the params it had.

Okay, but why? Because, at the end of the day, you can expect to see a vector of encrypted values (akin to what you’re seeing in the JSON version. Are you trying to see if there’s a difference in representation?

1 Like

Thanks for your warm reply. :slightly_smiling_face:

My goal is to implement a hardware accelerator of TFHE bootstrapping, and that’s why I need to generate the intermediate ciphertext as golden pattern to check the correctness between HW and SW in each step.

Besides, I would like to know are there any dft used in your binfhe? I saw it in src/core/extras but not sure if it is used in the TFHE.