95 KeySwitch(
long sPow=0,
long xPow=0,
long fromID=0,
long toID=0,
long p=0):
96 fromKey(sPow,xPow,fromID),toKeyID(toID),ptxtSpace(p) {}
99 fromKey(_fromKey),toKeyID(toID),ptxtSpace(p) {}
101 bool operator==(
const KeySwitch& other)
const;
102 bool operator!=(
const KeySwitch& other)
const {
return !(*
this==other);}
104 unsigned NumCols()
const {
return b.size(); }
115 ostream& operator<<(ostream& str,
const KeySwitch& matrix);
133 vector<KeySwitch> keySwitching;
139 vector< vector<long> > keySwitchMap;
143 context(*activeContext), pubEncrKey(*
this) {}
147 context(_context), pubEncrKey(*
this) {}
150 pubEncrKey.clear(); skHwts.clear();
151 keySwitching.clear(); keySwitchMap.clear();
154 bool operator==(
const FHEPubKey& other)
const;
155 bool operator!=(
const FHEPubKey& other)
const {
return !(*
this==other);}
158 const FHEcontext& getContext()
const {
return context;}
171 bool haveKeySWmatrix(
const SKHandle& from,
long toID=0)
const
174 bool haveKeySWmatrix(
long fromSPower,
long fromXPower,
long fromID=0,
long toID=0)
const
175 {
return haveKeySWmatrix(
SKHandle(fromSPower,fromXPower,fromID), toID); }
179 bool haveAnyKeySWmatrix(
const SKHandle& from)
const
185 {
long matIdx = keySwitchMap.at(fromID).at(fromXPower);
193 {
return keySwitchMap.at(keyID).at(k)>=0; }
201 long Encrypt(
Ctxt &ciphertxt,
const ZZX& plaintxt,
long ptxtSpace=0)
const;
204 friend ostream& operator << (ostream& str,
const FHEPubKey& pk);
205 friend istream& operator >> (istream& str,
FHEPubKey& pk);
214 vector<DoubleCRT> sKeys;
224 bool operator==(
const FHESecKey& other)
const;
225 bool operator!=(
const FHESecKey& other)
const {
return !(*
this==other);}
228 { FHEPubKey::clear(); sKeys.clear(); }
252 void GenKeySWmatrix(
long fromSPower,
long fromXPower,
long fromKeyIdx=0,
253 long toKeyIdx=0,
long ptxtSpace=0);
256 void Decrypt(ZZX& plaintxt,
const Ctxt &ciphertxt)
const;
260 void Decrypt(ZZX& plaintxt,
const Ctxt &ciphertxt, ZZX& f)
const;
264 long ptxtSpace=0,
long skIdx=0)
const;
266 friend ostream& operator << (ostream& str,
const FHESecKey& sk);
267 friend istream& operator >> (istream& str,
FHESecKey& sk);
294 #endif // ifndef _FHE_H_