Skip to content

Commit

Permalink
Added: new python functions for multibit operations
Browse files Browse the repository at this point in the history
  • Loading branch information
gizemscetin committed Aug 23, 2018
1 parent ebf9d57 commit ecd9027
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion cufhe/python/lib/fhe_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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

0 comments on commit ecd9027

Please sign in to comment.