CPU Parallel Homomorphic Machine Learning Framework for C++
Learnoran is a Machine Learning platform capable of working with homomorphically encrypted data. The framework currently enables the user to perform training, and prediction on the linear regression model (which will be expanded to polynomial regressors soon). The ultimate aim is to have neural networks to operate on ciphertexts as well. Learnoran currently implements fully connected neural networks with sigmoidal transfer functions; however homomorphic capabilities haven't been implemented for ANNs yet.
Learnoran uses Microsoft SEAL v3 under the hood.
Examples are provided below.
#include <iostream>
#include "encryption_manager.hpp"
#include "decryption_manager.hpp"
#include "linear_model.hpp"
#include "dataframe.hpp"
using namespace Learnoran;
using namespace std;
EncryptedNumber encrypted_linear_regression(const Dataframe<EncryptedNumber> & df,
const unordered_map<string, EncryptedNumber> test_features,
shared_ptr<EncryptionManager> enc_manager) {
LinearModel regressor(enc_manager);
regressor.fit(df, 3, 0.00001);
return regressor.predict(test_features);
}
int main() {
// ...
// read a dataset as std::pair<std::vector<std::vector<double>>, std::vector<double>>
// (training data, training labels), and construct a Learnoran::Dataframe object,
// Initialize EncryptionManager and DecryptionManager objects
Dataframe<EncryptedNumber> encrypted_dataframe = new Dataframe<EncryptedNumber>(encryption_manager->encrypt_dataframe(df));
EncryptedNumber linear_reg_enc_pred = encrypted_linear_regressor_test(encrypted_dataframe, encrypted_features, enc_manager);
cout << "encrypted linear regressor prediction result: " << dec_manager.decrypt(linear_reg_enc_pred) << endl;
return 0;
}