diff --git a/cufhe/python/lib/fhe_gpu.py b/cufhe/python/lib/fhe_gpu.py index af60594..c31ec87 100644 --- a/cufhe/python/lib/fhe_gpu.py +++ b/cufhe/python/lib/fhe_gpu.py @@ -124,7 +124,7 @@ def __or__(self, other): fhe.Synchronize() return result - def __invert__(self, other): + def __invert__(self): result = Ctxt(self.pubkey_) st = fhe.Stream() st.Create() @@ -156,3 +156,39 @@ def __and__(self, other): fhe.AND(result.ctxts_[i].ctxt_, self.ctxts_[i].ctxt_, other.ctxts_[i].ctxt_, st[i]) fhe.Synchronize() return result + + def __xor__(self, other): + result = CtxtList(len(self.ctxts_), self.pubkey_) + st = [] + for i in range(len(self.ctxts_)): + st.append(fhe.Stream()) + st[i].Create() + fhe.Synchronize() + for i in range(len(self.ctxts_)): + fhe.XOR(result.ctxts_[i].ctxt_, self.ctxts_[i].ctxt_, other.ctxts_[i].ctxt_, st[i]) + fhe.Synchronize() + return result + + def __or__(self, other): + result = CtxtList(len(self.ctxts_), self.pubkey_) + st = [] + for i in range(len(self.ctxts_)): + st.append(fhe.Stream()) + st[i].Create() + fhe.Synchronize() + for i in range(len(self.ctxts_)): + fhe.OR(result.ctxts_[i].ctxt_, self.ctxts_[i].ctxt_, other.ctxts_[i].ctxt_, st[i]) + fhe.Synchronize() + return result + + def __invert__(self): + result = CtxtList(len(self.ctxts_), self.pubkey_) + st = [] + for i in range(len(self.ctxts_)): + st.append(fhe.Stream()) + st[i].Create() + fhe.Synchronize() + for i in range(len(self.ctxts_)): + fhe.AND(result.ctxts_[i].ctxt_, self.ctxts_[i].ctxt_, st[i]) + fhe.Synchronize() + return result