Skip to content

Instantly share code, notes, and snippets.

@pathaine

pathaine/p1.cpp Secret

Last active Dec 26, 2018
Embed
What would you like to do?
BP3 P1
usint plaintextModulus = 536903681;
double sigma = 3.2;
size_t batchSize = 8;
SecurityLevel securityLevel = HEStd_128_classic;
////////////////////////////////////////////////////////////
// Parameter generation
////////////////////////////////////////////////////////////
EncodingParams encodingParams(new EncodingParamsImpl(plaintextModulus, batchSize));
//Set Crypto Parameters
// # of evalMults = 3 (first 3) is used to support the multiplication of 7 ciphertexts, i.e., ceiling{log2{7}}
// Max depth is set to 3 (second 3) to generate homomorphic evaluation multiplication keys for s^2 and s^3
CryptoContext<DCRTPoly> cc = CryptoContextFactory<DCRTPoly>::genCryptoContextBFVrns(encodingParams, securityLevel, sigma, 0, 3, 0, OPTIMIZED, 3);
// enable features that you wish to use
cc->Enable(ENCRYPTION);
cc->Enable(SHE);
// Generating a secret-public keypair
LPKeyPair<DCRTPoly> kp = cc->KeyGen();
if( !kp.good() ) {
std::cout << "Key generation failed!" << std::endl;
exit(1);
}
usint m = cc->GetCryptoParameters()->GetElementParams()->GetCyclotomicOrder();
PackedEncoding::SetParams(m, encodingParams);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment