google / fully-homomorphic-encryption

An FHE compiler for C++
Apache License 2.0
3.53k stars 256 forks source link

Expected Performance #8

Closed lewisxy closed 3 years ago

lewisxy commented 3 years ago

I managed to build this project in docker on Linux, and run the example code. However, the computation takes a quite long to complete.

Specifically, I run

bazel run //transpiler/examples/calculator:calculator_tfhe_testbench

and the first computation (10 * 20) takes around 460 seconds with 100% CPU on single core to compute. My computer has a 4th gen i7 CPU.

I am quite new to homomorphic encryption. So I am not sure how long should it take. Is my result similar to the expected performance?

lupascucristian commented 3 years ago

It's somehow normal with the homomorphic encryption to have higher timings / required resources. However, it shouldn't be so high for a simple multiplication (unless the implementation encrypts every bit instead of using a higher space for plaintext-which may be the case since TFHE is oriented to boolean circuits). You should check the parameters of the TFHE so you can reduce your timings (ps. check the security level as well).

dibakch commented 3 years ago

Yes, depending on the application, FHE is not super fast. Did you try running the transpiler with multi-core enabled:

bazel run //transpiler/examples/calculator:calculator_interpreted_tfhe_testbench

Depending on the number of cores, this should be significantly faster. For instance, on my workstation (12 cores) the calculator takes 322 seconds using a single core and 50 seconds using multi-core.

Note that the calculator example does more than just a single multiplication. It also parses the operation (see calculator.cc).

zjwangmin commented 3 years ago

It has same issue for me. First time, I can't believe it's true.