OpenFHE is a library for doing fully homomorphic encryption. There is a complicated definition, but what it means is this: You can get a server to compute a function on your data without compromising your data. You encrypt your data and send it to the server. The server does the computation and sends the value back. You decrypt the computed value, and you get back the value of the function on your data. Magic!
The API is surprisingly simple:
- Create a crypto context using a parameters object. Generate or load appropriate public/private keys.
- Create plaintext objects by encoding your data vectors, then encrypt them with the crypto context to get your ciphertexts.
- Do the operations you want on the ciphertexts.
- Decrypt the ciphertexts.
There are a few complications to this basic model (see the example code), but not many. The main one is multiplication depth.
Multiplication depth is strange, but here's the general idea as I understand it. Every ciphertext is created with a counter. Whenever you multiply two ciphertexts \(c_x\) and \(c_y\) with counters \(a\) and \(b\) respectively, the result's counter is \(\max(a, b) + 1\) — that is, one more than the larger of the two counters. If that counter ever exceeds the multiplication depth, Bad Things Happen.
I wonder what happens if you multiply again when one of the ciphertexts is already at the maximum multiplication depth. I assume either the library throws an exception or you get invalid results. It shouldn't expose the data. I guess you could be ejected from the face of the earth...