encryptorion-lab / phantom-fhe

PhantomFHE: A CUDA-Accelerated Homomorphic Encryption Library
https://encryptorion-lab.gitbook.io/phantom-fhe/
GNU General Public License v3.0
80 stars 9 forks source link

Incorrect decoding results for all schemes #9

Closed gogo9th closed 3 months ago

gogo9th commented 3 months ago

Hi,

I have been testing and trying to use your library. I am truly impressed to see that your library takes only around 100ms to do 850 rotation operations over polynomial degre 16384.

However, the problem I am facing is that the results are wrong. Especially, the encoded & decoded values for BFV are wrong. The followings are output comparisons of the first few slots in the 1_bfv.cu file (left is the decoded value; right is the expected value):

0 : 16609170735855201 vs 0 1 : 30449908613688664 vs 1 2 : 12234507488005803 vs 2 3 : 13513198740842984 vs 3 4 : 4910914022173717 vs 4 5 : 30330729204735839 vs 5 6 : 14480765275394597 vs 6

I am using RTX 4090, Driver Version 550.67, CUDA Version 12.4, and nvcc version 12.6.

If you don't mind, could you log into my VM and take a look what went wrong? You can log in by using the following command: ssh -p 57116 root@171.248.243.29 -L 8080:localhost:8080

I installed your source code directly in the home directory. You can reproduce my error as follows:

cd /root/phantom-fhe/build/bin
./example_context
1

When remotely logging in, you need to store the SSH public & private key pairs as follows in the following directory:

FILE ~/.ssh/id_rsa.pub: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC/NNB/zH50TeiqibwJsxYEZlU39kmYkLp8d1SbVM5K/3la33sxVJ72ywx3TIwpCbb2zqq52YGTc20zodP3fssuxXUxjqlkbluV3DgZVuvlxcKXNuH0IPNqf7MYpk8JQRwWogsjHaZJNpL1FDlmSRUkmnxaLuX9PTxVdtve/o7vEstib83RBOukDPkKHS05hcuGuNlkvSW0mfjX8s2iUe0optrn6GbuzhVrts6ooip0qWi30FOFbZ1EuQWOnhrkZpOMQ4oj1rOQA7htQgNWGgkQhqC870JmeWzQixBv/Kbgh5gfkHNQPLZymq8VtwoFLXmLEx2I9yKz22oS4p6OTxACrhBZe63DKx7jUQEQWdfxbu1rYQQfrAuMyIvWhYgeljNHELA2+umXJYu1gsLs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wDNpQ
cSQFONu5GhbotegfWgNe8Vd9hhdYX6y68V5YrWg93cgdcJj90r3xSddwaFHQnBREnrXf29
mWF6mOBuK8jDl2Ci1hYnAUTiG+jfiCcOxe/k2dZA7FsaA8UY/bOUTxqIR9jCdwH2RMphZ8
ZIxwL+EDlLT1jFBy0DX9c+CTZ9VB9x2/OXHVp3zkX1yOSU7V+u1mnT2W6Zx7YOiDocolCX
uO4sZLeN9K3l/4gyaUZrBmyEqiJPT9AAAAwQD6gVe1vw9Uwq26Mg7jgNHICFVOT4NEBlBm
rN22RHw4L7rkQu8euqSH+y+AO4djvaGN6h4DykpQDyiV/itZZLdl/jQu81i/iePHaKVN3l
AvCHFv+rId8sji+JXIpxCNoMK6Abfj7+fb0Bc3PxEy74KpAxiVHtt80MgnHVuqcEV/lsqO
5cBfFMycj72iG48ukqmAfjPziZemeNp1+YTFZGWBbFI/1VtuBpkvQvnPZe6bMkKC55d3vl
Kpc5u8SaBgkBUAAAAPc2t5ZXJAaGFqb29uLmtvAQIDBA==
-----END OPENSSH PRIVATE KEY-----

I would really appreciate your help!

D4rkCrypto commented 3 months ago

Thanks for your issue, let me take some time to reproduce and fix this.

gogo9th commented 3 months ago

p.s. Another question I have is, what is the easiest way to use your library? I saw that your example code compilation includes a lot of compilation options in Makefile. To port your library into my SEAL application, is the easiest way migrating my application's source code directory into where your example folder is located and making my own CMakeList.txt file similar to how you made it for your example program?

D4rkCrypto commented 3 months ago

Revealing SSH private key is very risky, you need to replace this keypair immediately. You can upload my SSH public key to your server's ~/.ssh/authorized_keys so that I can log into it. Here is my public key:

ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOhsvKbhBeTqtCniGJh4wi/qS0tTk9UsAO4XieMjlBFe
D4rkCrypto commented 3 months ago

p.s. Another question I have is, what is the easiest way to use your library? I saw that your example code compilation includes a lot of compilation options in Makefile. To port your library into my SEAL application, is the easiest way migrating my application's source code directory into where your example folder is located and making my own CMakeList.txt file similar to how you made it for your example program?

I have written documentation about building C++ applications here. You can review compiling options here to see if you need to manually change some of them.

gogo9th commented 3 months ago

Hi,

My apologize, it was my fault... I installed CUDA 12.4 and nvcc 12.6, but these two versions are supposed to match. I recreated a new VM and tested your example with nvcc 12.4 installed, and it works fine. Sorry again!

D4rkCrypto commented 3 months ago

Glad to hear that! If you come across any other bugs, feel free to let me know.