예제 #1
0
 def test_multiple_data(self):
     ct_1 = BV.ciphertext([1, 2, 3, 4, 5], self.keys.pk)
     ct_2 = BV.ciphertext([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], self.keys.pk)
     pt = BV.pari_GEN(
         [1, 4, 10, 20, 35, 50, 65, 80, 95, 110, 114, 106, 85, 50])
     ct = ct_1 * ct_2
     self.assertEqual(ct.decrypt(self.keys.sk).sub_array(0, 14), pt)
예제 #2
0
 def test_multiple_data_plaintext(self):
     ct = BV.ciphertext([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], self.keys.pk)
     pt = BV.pari_GEN([4, 8, 12, 16, 20, 24, 28, 32, 36, 40])
     ct_1 = ct * 4
     ct_2 = 4 * ct
     self.assertEqual(ct_1.decrypt(self.keys.sk).sub_array(0, 10), pt)
     self.assertEqual(ct_2.decrypt(self.keys.sk).sub_array(0, 10), pt)
예제 #3
0
 def test_single_data_plaintext(self):
     ct = BV.ciphertext(10, self.keys.pk)
     pt = BV.pari_GEN(40)
     ct_1 = ct * 4
     ct_2 = 4 * ct
     self.assertEqual(ct_1.decrypt(self.keys.sk)[0], pt)
     self.assertEqual(ct_1.decrypt(self.keys.sk)[0], pt)
예제 #4
0
파일: basic.py 프로젝트: powderluv/PyBV
    def __init__(self, public_key, data=None, input_is_decrypted=True, secret_key=None):
        self.encrypted = True

        self.public_key = public_key
        self.secret_key = secret_key

        if(type(data) == np.ndarray and input_is_decrypted):
            self.data = BV.ciphertext(data.tolist(), self.public_key.pk)
        else:
            self.data = data
예제 #5
0
파일: basic.py 프로젝트: gaceladri/PyBV
    def reencrypt(self, op):
        '''
        Successive multiplications lead to growing errors.  Reencryption "cleans" - stops the growth of the errors.
        Current implementation is just a placeholder
        :return:
        '''
        if self.encrypted is False:
            return

        # TODO Remove this stop-gap!  There will in future be a HE re-encryption! deevashwer has a cunning plan!
        plaintext = op.decrypt(self.private_key)
        result = BV.ciphertext(plaintext, self.private_key)

        return (result)
예제 #6
0
 def test_single_data(self):
     ct_1 = BV.ciphertext(10, self.keys.pk)
     ct_2 = BV.ciphertext(5, self.keys.pk)
     pt = BV.pari_GEN(50)
     ct = ct_1 * ct_2
     self.assertEqual(ct.decrypt(self.keys.sk)[0], pt)
예제 #7
0
 def test_multiple_data(self):
     ct_1 = BV.ciphertext([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], self.keys.pk)
     ct_2 = BV.ciphertext([1, 2, 3, 4, 5], self.keys.pk)
     pt = BV.pari_GEN([0, 0, 0, 0, 0, 6, 7, 8, 9, 10])
     ct = ct_1 - ct_2
     self.assertEqual(ct.decrypt(self.keys.sk).sub_array(0, 10), pt)
예제 #8
0
 def test_nested_operations(self):
     ct_1 = BV.ciphertext(5, self.keys.pk)
     ct_2 = BV.ciphertext(10, self.keys.pk)
     pt = BV.pari_GEN(130)
     ct = 2 * ((ct_1 * ct_2) + (ct_1 + ct_2))
     self.assertEqual(ct.decrypt(self.keys.sk)[0], pt)
예제 #9
0
 def test_ciphertext_array(self):
     ciphertext_array = []
     for i in range(1, 10):
         ciphertext_array.append(BV.ciphertext(i, self.keys.pk))
     pt = BV.pari_GEN(5)
     self.assertEqual(ciphertext_array[4].decrypt(self.keys.sk)[0], pt)
예제 #10
0
 def test_single_data(self):
     ct = BV.ciphertext(5, self.keys.pk)
     pt = BV.pari_GEN(5)
     self.assertEqual(ct.decrypt(self.keys.sk)[0], pt)