static void pk_nybble(int x) { if (bitweight == 16) { bitweight = 1; pk_output_byte = x*16; } else { bitweight = 16; pk1(pk_output_byte + x); } }
int main() { string * tmp_ptr; long LLL, DDD, KKK ; long m; long ccc; FHEcontext * context_ptr; FHESecKey * fhekey_ptr; EncryptedArray * ea_ptr; LLL = 682; DDD=12; KKK=80; /* pair<long, long> m_c = get_m_c(LLL, DDD, KKK); m = m_c.first; ccc = m_c.second; */ m = 15709; ccc = 3; context_ptr = new FHEcontext(m, 2, 1); buildModChain(*context_ptr, DDD, ccc); fhekey_ptr = new FHESecKey(*context_ptr); fhekey_ptr->clear(); fhekey_ptr->GenSecKey(64,2); addSome1DMatrices(*fhekey_ptr); const FHEPubKey & pub_key = *fhekey_ptr; ZZX G; G = ZZX(1,1); ea_ptr = new EncryptedArray(*context_ptr, G); // Test I/O, write context and public key, then try to read them back cout << "KEY\n"; cout <<"L= " <<LLL<< " D= " << DDD<< " K= " << KKK << endl<< flush; { stringstream s1; writeContextBase(s1, *context_ptr); s1 << *context_ptr; string s2 = s1.str(); cout << s2 << endl; // output context also to external cout // Read back context from input stream (s3) unsigned long m1, p1, r1; stringstream s3(s2); readContextBase(s3, m1, p1, r1); FHEcontext c1(m1, p1, r1); s3 >> c1; assert(c1 == *context_ptr); } { stringstream s1; s1 << pub_key; string s2 = s1.str(); cout << s2 <<"\nENDKEY" << endl; // output public key also to external cout // Read back cpublic key from input stream (s3) stringstream s3(s2); FHEPubKey pk1(*context_ptr); s3 >> pk1; assert(pk1 == pub_key); } }
static void pk2(int x) { if (x < 0) x += 65536; pk1((x & 0x00ff00) >> 8); pk1(x & 0x0000ff); }