Open siaaron045 opened 4 years ago
I just do one encryption and one decryption.And I know this case usually does not happen, I want to know why and how to fix it.Thank you.
`#include
//#include "ArgMap.h"
//#include "sf-moremat.h"
using namespace std;
int main() { / BEGIN INITIALIZATION / long m = 0; // Specific modulus long p = 257; // Plaintext base [default=2], should be a prime number long r = 1;//1 // Lifting [default=1] long L = 6;//10 // Number of levels in the modulus chain [default=heuristic] long c = 5; // Number of columns in key-switching matrix [default=2] long w = 64; // Hamming weight of secret key long d = 1; // Degree of the field extension [default=1] long k = 80; // Security parameter [default=80] long s = 0; // Minimum number of slots [default=0]
cout<<"L= "<<L<<endl;
clock_t start,finish;
start = clock();
std::cout << "Finding m... " << std::flush;
//m = FindM(k, L, c, p, d, s, 0); // Find a value for m given the specified values
m = 42181;
std::cout << "m = " << m << std::endl;
std::cout << "Initializing context... " << std::flush;
FHEcontext context(m, p, r); // Initialize context
buildModChain(context, L, c); // Modify the context, adding primes to the modulus chain
std::cout << "OK!" << std::endl;
std::cout << "Generating keys... " << std::flush;
FHESecKey sk(context); // Construct a secret key structure
const FHEPubKey& pk = sk; // An "upcast": FHESecKey is a subclass of FHEPubKey
sk.GenSecKey(w); // Actually generate a secret key with Hamming weight
addSome1DMatrices(sk); // Extra information for relinearization
std::cout << "OK!" << std::endl;
finish = clock();
cout<<"Time taken for the initialization:"<<(finish-start)/CLOCKS_PER_MSE<<"ms"<<endl;
EncryptedArray ea(context, context.alMod.getFactorsOverZZ()[0]);
Ctxt temp(pk);
NewPlaintextArray p0(ea);
random(ea,p0);
//clock_t start,finish;
start = clock();
ea.encrypt(temp,pk,p0);
finish = clock();
cout<<"enc run time:"<<(finish-start)/CLOCKS_PER_MSE<<"ms"<<endl;
start = clock();
vector<long> result;
start = clock();
ea.decrypt(temp,sk,result);
finish = clock();
cout<<"dec run time:"<<(finish-start)/CLOCKS_PER_MSE<<"ms"<<endl;
return 0;
} `
When I was running my own program which m=52609,the enc time is 0.33s while the dec time is 16.47s.why? Thank you.