def decrypt(self, encryptedMessage): tmp = self.reModulo(poly.multPoly(self.f, encryptedMessage), self.D, self.q) centered = poly.cenPoly(tmp, self.q) m1 = poly.multPoly(self.f_p, centered) tmp = self.reModulo(m1, self.D, self.p) return poly.trim(tmp)
def decryptSQ(self,encryptedMessage): F_p_sq=poly.multPoly(self.f_p,self.f_p) f_sq=poly.multPoly(self.f,self.f) tmp=self.reModulo(poly.multPoly(f_sq,encryptedMessage),self.D,self.q) centered=poly.cenPoly(tmp,self.q) m1=poly.multPoly(F_p_sq,centered) tmp=self.reModulo(m1,self.D,self.p) return poly.trim(tmp)
print "a",a print "b",b break # TESTING MULTIPLICATION FUNCTION a=P.polymul(c1,c2).tolist() b=q.multPoly(c1,c2) if(a!=b): print "Failed on Case:" print "a * b" print "a",a print "b",b break # TESINGING DIVISION FUNCTION if q.trim(c2)==[0]: continue try: [a1,a2]=P.polydiv(c1,c2) a1=q.trim(a1.tolist()) a2=q.trim(a2.tolist()) [b1,b2]=q.divPoly(c1,c2) b1=map(float,b1) b2=map(float,b2) a1=map(lambda x: round(x,5),a1) a2=map(lambda x: round(x,5),a2) b1=map(lambda x: round(x,5),b1) b2=map(lambda x: round(x,5),b2) except: print "BREAKING ON EXCEPTION" print "Failed on Case:"
print "a", a print "b", b break # TESTING MULTIPLICATION FUNCTION a = P.polymul(c1, c2).tolist() b = q.multPoly(c1, c2) if (a != b): print "Failed on Case:" print "a * b" print "a", a print "b", b break # TESINGING DIVISION FUNCTION if q.trim(c2) == [0]: continue try: [a1, a2] = P.polydiv(c1, c2) a1 = q.trim(a1.tolist()) a2 = q.trim(a2.tolist()) [b1, b2] = q.divPoly(c1, c2) b1 = map(float, b1) b2 = map(float, b2) a1 = map(lambda x: round(x, 5), a1) a2 = map(lambda x: round(x, 5), a2) b1 = map(lambda x: round(x, 5), b1) b2 = map(lambda x: round(x, 5), b2) except: print "BREAKING ON EXCEPTION" print "Failed on Case:"
def decrypt(self,encryptedMessage): tmp=self.reModulo(poly.multPoly(self.f,encryptedMessage),self.D,self.q) centered=poly.cenPoly(tmp,self.q) m1=poly.multPoly(self.f_p,centered) tmp=self.reModulo(m1,self.D,self.p) return poly.trim(tmp)