IBM / fhe-toolkit-linux

IBM Fully Homomorphic Encryption Toolkit For Linux. This toolkit is a Linux based Docker container that demonstrates computing on encrypted data without decrypting it! The toolkit ships with two demos including a fully encrypted Machine Learning inference with a Neural Network and a Privacy-Preserving key-value search.
MIT License
1.43k stars 158 forks source link

Question about the built libraries libhelib.so and libmlhelib.a #169

Closed DylanWangWQF closed 3 years ago

DylanWangWQF commented 3 years ago

Question In the built Alpine Docker container, I found the static library libmlhelib.a and dynamic library libhelib.so.

So we didn't build the static library libhelib.a in this example? (I need this library built on Alpine Linux for my experiment)

github-actions[bot] commented 3 years ago

Thank you very much for helping us to improve the quality of our software. The FHE Toolkit develiopment team want to sincerely thank you for submitting your first issue and joining our technical community! We will get started on your issue immediately.

DylanWangWQF commented 3 years ago

Sry about the wrong label bug.

dubek commented 3 years ago

Hi @DylanWangWQF, thank you for your interest in IBM's FHE toolkit.

Indeed by default we build only the shared library of HElib, as seen in Dockerfile.ALPINE.HElib:

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED=ON -DENABLE_THREADS=ON ..

if you'll change that to -DBUILD_SHARED=OFF it should build the libhelib.a file. I expect the rest of the setup to keep working even with the static library (.a) but I haven't tried that.

DylanWangWQF commented 3 years ago

Hi, @dubek .Thanks for your help!

After I change that to-DBUILD_SHARED=OFF, it still returns the libhelib.so shared library. I don't know why it doesn't work. So I manually rebuild it in the Alpine container and finally get the libhelib.a.

BTW, once I manually rebuild HElib to get libhelib.a, I found it does require the NTL and GMP to be the shared libraries .so. Here, I have a question. When I use libhelib.a in my own project, it's not available to work on libntl.a and libgmp.a?

dubek commented 3 years ago

BTW, once I manually rebuild HElib to get libhelib.a, I found it does require the NTL and GMP to be the shared libraries .so. Here, I have a question. When I use libhelib.a in my own project, it's not available to work on libntl.a and libgmp.a?

I think this might be related to different licenses of GMP, NTL, and HElib and their ability to (legally) link together.

boland25 commented 3 years ago

@DylanWangWQF @dubek is correct in saying that if you build HElib as a static library it requires NTL and GMP to also be built as static. It may be a situation that if you turn off SHARED in the HElib, it will expect that you are feeding it NTL and GMP libraries that are also .a and it isn't there so it doesn't build.

You can look at the macOS repo to see how we build everything statically and run it there. The flags would generally be the same for your alpine build.

Also NTL and GMP are different licenses than HElib so if you are planning on packaging and using this commercially it would require you to use shared libraries (.so)

DylanWangWQF commented 3 years ago

Hi, @boland25 @dubek . I see. Many thanks for your help!

DylanWangWQF commented 3 years ago

Sry for reopening this issue again. @dubek @boland25 I want to install GMP by myself inside the alpine container. But it doesn't work after I modify the dockerfile.alpine (as well as alpine.HElib).

And I don't have permission to ./configure inside the container to install the GMP and build other packages.

dubek commented 3 years ago

@DylanWangWQF You can always start you own Dockerfile from scratch to install whatever you need in it. Not sure this is related to fhe-toolkit-linux.

DylanWangWQF commented 3 years ago

@dubek Thank you for your help! This has been solved.