The Next Great Thing(s) In Cybersecurity: Post Quantum Cryptography and Homomorphic Encryption

--

[After a day of compiling C++ code into a useable library, and then getting it integrate with Microsoft Code, here’s a code example]

We have four highly successful spin-out companies under our belts and another two on the way. So we never just sit around and wait for the next big thing. And, for us, there are two disruptive changes on the way: Post Quantum Cryptography and Homomorphic Encryption. In order for us not to be left behind, we are ramping up our research to integrate both of these methods.

For Homomorphic Encryption, we have been evaluating the Microsoft SEAL library, and have working code:

Now, we aim to also integrate with OpenFHE [here], as this gives us many new areas of development, including for the usage of distributed signature using homomorphic encryption.

We initially need to compile the OpenFHE code into a library. The Windows build is [here]. Then we create our cpp file, and build with:

g++.exe *.cpp lib.a -o openfhe_01  -I../../openfhe_main/src/pke/include -I../../openfhe_main/src/binfhe/include -I../../openfhe_main/src/core/include -I../../openfhe_main/src/core -I../../openfhe_main/build/src/core -I../../openfhe_main/src/binfhe -I../../openfhe_main/third-party/cereal/include

Coding

Overall, for BFV and BGV, we convert our integers into plaintext, and then covert into ciphertext. We can then add the ciphertext values with:

auto ciphertextAdd     = cryptoContext->EvalAdd(ciphertext1, ciphertext2);

The code is [here]:

#include <openfhe.h>
using namespace lbcrypto;
using namespace std;
#include <iostream>
#include <sstream>
#include <cstdint>
int main(int argc, char *argv[]) {
int64_t x=0;
int64_t y=0;
string type="BFV";
uint64_t mod = 65537;

if (argc>1) {
std::istringstream iss(argv[1]);
iss >> x;
}
if (argc>2) {
std::istringstream iss(argv[2]);
iss >> y;
}
if (argc>3) {
type=argv[3];
}
if (argc>4) {
std::istringstream iss(argv[4]);
iss >> mod;
}

CCParams<CryptoContextBFVRNS> parameters;
if (type=="BGV") CCParams<CryptoContextBFVRNS> parameters;

parameters.SetPlaintextModulus(mod);
parameters.SetMultiplicativeDepth(2);
CryptoContext<DCRTPoly> cryptoContext = GenCryptoContext(parameters);
cryptoContext->Enable(PKE);
cryptoContext->Enable(KEYSWITCH);
cryptoContext->Enable(LEVELEDSHE);

KeyPair<DCRTPoly> keyPair;
// Generate key pair
keyPair = cryptoContext->KeyGen();
// Generate the relinearization key
cryptoContext->EvalMultKeyGen(keyPair.secretKey);
// Generate the rotation evaluation keys
cryptoContext->EvalRotateKeyGen(keyPair.secretKey, {1, 2, -1, -2});

std::vector<int64_t>xval = {1};
xval[0]=x;
Plaintext xplaintext = cryptoContext->MakePackedPlaintext(xval);
std::vector<int64_t> yval = {1};
yval[0]=y;
Plaintext yplaintext = cryptoContext->MakePackedPlaintext(yval);

// Encrypt values
auto ciphertext1 = cryptoContext->Encrypt(keyPair.publicKey, xplaintext);
auto ciphertext2 = cryptoContext->Encrypt(keyPair.publicKey, yplaintext);

// Add ciphertext
auto ciphertextAdd = cryptoContext->EvalAdd(ciphertext1, ciphertext2);

// Decrypt result
Plaintext plaintextAddRes;
cryptoContext->Decrypt(keyPair.secretKey, ciphertextAdd, &plaintextAddRes);
std::cout << "Method: : " << type << std::endl;
std::cout << "Modulus: : " << mod<< std::endl;
std::cout << "\nx: " << xplaintext << std::endl;
std::cout << "y: " << yplaintext << std::endl;

// Output results
std::cout << "\nResults" << std::endl;
std::cout << "x+y= " << plaintextAddRes << std::endl;

return 0;
}

A sample run is [here]:

Method: : BFV
Modulus: : 65537
x: ( 220 ... )
y: ( 23 ... )
Results
x+y= ( 243 ... )

I will be adding more examples here:

--

--

Prof Bill Buchanan OBE FRSE
ASecuritySite: When Bob Met Alice

Professor of Cryptography. Serial innovator. Believer in fairness, justice & freedom. Based in Edinburgh. Old World Breaker. New World Creator. Building trust.