Basic Integer Circuits for FHEW/TFHE

Hi there,

so I’ve implemented a simple scoring algorithm that works with Integers >= 10 using BGV. Because the scoring uses a couple of comparisons, I wanted to experiment with FHEW/TFHE to see which scheme can compute the score faster. Now I’m looking for basic integer circuits implemented in OpenFHE like an adder circuit. Is there a library implementing such circuits for OpenFHE?

you can look at examples/simple_ckts/adder_2bit to see how to implement an adder using the circuit evaluator, but that is just an adder,

alternatively you can use the google transpiler with the openfhe backend, see GitHub - openfheorg/openfhe-transpiler-examples: Examples of using openfhe and the Google transpiler taken from various research projects (though we do not have a simple ADDER example). That technology would let you simply code the problem in C++, encrypting the function you want to remain secret.

I tried to build the docker container for the transpiler, but the Bazel build fails at some point. Guess it’s a problem that I’m trying to build it on MacOs.

Hmm. sorry I never ran the tranpiler on anything other than Ubuntu. I would suggest starting here: GitHub - google/fully-homomorphic-encryption: An FHE compiler for C++ and seeing if the Google team can answer if it works on a Mac.

Were you successful in compiling any of the transpiler/examples provided in the google repo?

Hi, so I finally managed to build the docker image of the transpiler and was able to run some of the examples of the Google team. I run into some issues with the aes example from the openfhe-transpiler-examples.

I can successfully run:

bazel build //transpiler/examples/aes:ecb_enc_cleartext_testbench

But when I try to compile everything using “compile_openfhe_all.sh”, some of the steps fail. For example:

ecb_enc_openfhe_testbench
INFO: Analyzed target //transpiler/examples/aes:ecb_enc_openfhe_testbench (3 packages loaded, 7796 targets configured).
INFO: Found 1 target...
INFO: From Action transpiler/examples/aes/ShiftRows_openfhe.ir:
Parsing file 'transpiler/examples/aes/ShiftRows.cc' with clang...
Generating IR...
INFO: From Action transpiler/examples/aes/MixColumns_openfhe.ir:
Parsing file 'transpiler/examples/aes/MixColumns.cc' with clang...
Generating IR...
INFO: From Action transpiler/examples/aes/AddRoundKey_openfhe.ir:
Parsing file 'transpiler/examples/aes/AddRoundKey.cc' with clang...
Generating IR...
INFO: From Action transpiler/examples/aes/SubBytes_openfhe.ir:
Parsing file 'transpiler/examples/aes/SubBytes.cc' with clang...
Generating IR...
INFO: From Action transpiler/examples/aes/AES_init_ctx_openfhe.ir:
Parsing file 'transpiler/examples/aes/AES_init_ctx.cc' with clang...
Generating IR...
ERROR: /usr/src/fhe/transpiler/examples/aes/BUILD:70:10: Compiling transpiler/examples/aes/ecb_enc_openfhe_testbench.cc failed: (Exit 1): gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 52 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
transpiler/examples/aes/ecb_enc_openfhe_testbench.cc: In function 'void test_encrypt_ecb()':
transpiler/examples/aes/ecb_enc_openfhe_testbench.cc:205:13: warning: unused variable 'i' [-Wunused-variable]
  205 |     uint8_t i;
      |             ^
transpiler/examples/aes/ecb_enc_openfhe_testbench.cc: In function 'int main(int, char**)':
transpiler/examples/aes/ecb_enc_openfhe_testbench.cc:364:29: error: 'STD128_LMKCDEY' was not declared in this scope
  364 |    cc.GenerateBinFHEContext(STD128_LMKCDEY);
      |                             ^~~~~~~~~~~~~~
transpiler/examples/aes/ecb_enc_openfhe_testbench.cc:369:29: error: 'STD128Q_LMKCDEY' was not declared in this scope
  369 |    cc.GenerateBinFHEContext(STD128Q_LMKCDEY); //may need 64 bit arch.
      |                             ^~~~~~~~~~~~~~~
Target //transpiler/examples/aes:ecb_enc_openfhe_testbench failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 96.327s, Critical Path: 95.50s
INFO: 55 processes: 7 internal, 48 processwrapper-sandbox.
FAILED: Build did NOT complete successfully
cp: cannot stat '../../bazel-bin/transpiler/examples/aes/ecb_enc_openfhe_testbench': No such file or directory