Skip to content

Commit

Permalink
Add test of representations of multi-node ciphertexts.
Browse files Browse the repository at this point in the history
  • Loading branch information
lapets committed Jan 8, 2025
1 parent ece6790 commit d20ce24
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/test_nilql.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,30 @@ def test_secret_key_creation_errors(self):
operations = {}
nilql.secret_key(cluster, operations)

def test_ciphertext_representation_for_store_multinode(self):
"""
Test that ciphertext representation when storing in a multiple-node cluster.
"""
cluster = {'nodes': [{}, {}, {}]}
operations = {'store': True}
sk = nilql.secret_key(cluster, operations)
plaintext = 'abc'
ciphertext = ['Ifkz2Q==', '8nqHOQ==', '0uLWgw==']
decrypted = nilql.decrypt(sk, ciphertext)
self.assertTrue(plaintext == decrypted)

def test_ciphertext_representation_for_sum_multinode(self):
"""
Test that ciphertext representation when storing in a multiple-node cluster.
"""
cluster = {'nodes': [{}, {}, {}]}
operations = {'sum': True}
sk = nilql.secret_key(cluster, operations)
plaintext = 123
ciphertext = [456, 246, 4294967296 - 123 - 456]
decrypted = nilql.decrypt(sk, ciphertext)
self.assertTrue(plaintext == decrypted)

def test_encrypt_of_int_for_match(self):
"""
Test encryption of integer for matching.
Expand Down

0 comments on commit d20ce24

Please sign in to comment.