Skip to content

Instantly share code, notes, and snippets.

@pathaine

pathaine/p1.cpp Secret

Last active December 26, 2018 20:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pathaine/5c64769455c0d9d5dd3bf49850293ae0 to your computer and use it in GitHub Desktop.
Save pathaine/5c64769455c0d9d5dd3bf49850293ae0 to your computer and use it in GitHub Desktop.
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