def test_encrypt_decrypt(): from unittesting import test_symmetric_encrypt_decrypt test_symmetric_encrypt_decrypt("qtpie", generate_key, encrypt, decrypt, iterations=10000)
def unit_test(): from unittesting import test_symmetric_encrypt_decrypt test_symmetric_encrypt_decrypt("obviouslhe", generate_secret_key, encrypt, decrypt, iterations=10000)
def unit_test(): secret_key = generate_secret_key() c1 = encrypt(1, secret_key) p1 = decrypt(c1, secret_key) assert p1 == 1, (p1, 1) c2 = encrypt(2, secret_key) c3 = c1 + c2 p3 = decrypt(c3, secret_key) assert p3 == 1 + 2, (p3, 3) c6 = c2 * c3 p6 = decrypt(c6, secret_key, depth=2) assert p6 == 2 * 3, (p6, 6) from unittesting import test_symmetric_encrypt_decrypt test_symmetric_encrypt_decrypt("noiselessfhe", generate_secret_key, encrypt, decrypt, iterations=10000) from unittesting import test_key_exchange test_key_exchange("noiselessfhe_kex", generate_keypair, encapsulate_key, recover_key, iterations=10000)
def test_encrypt_decrypt(): from unittesting import test_symmetric_encrypt_decrypt test_symmetric_encrypt_decrypt("modular_inverse", generate_key, encrypt, decrypt, iterations=10000, plaintext_size=16)
def test_encrypt_decrypt(): from unittesting import test_symmetric_encrypt_decrypt test_symmetric_encrypt_decrypt("squaremod", generate_key, encrypt, decrypt) key = generate_key()#[10, 100, 1000] m1 = 12389124981 m2 = 1000129012 ciphertext1 = encrypt(m1, key) ciphertext2 = encrypt(m2, key) test_function = lambda a, b: (a * b) + (a * b) + (b * b) ciphertext3 = test_function(ciphertext1, ciphertext2) plaintext = decrypt(ciphertext3, key, 2) assert plaintext == test_function(m1, m2) % key[0], (plaintext, m1, m2, test_function(m1, m2))
def test_encrypt_decrypt(): from unittesting import test_symmetric_encrypt_decrypt test_symmetric_encrypt_decrypt("squaremod", generate_key, encrypt, decrypt) key = generate_key() #[10, 100, 1000] m1 = 12389124981 m2 = 1000129012 ciphertext1 = encrypt(m1, key) ciphertext2 = encrypt(m2, key) test_function = lambda a, b: (a * b) + (a * b) + (b * b) ciphertext3 = test_function(ciphertext1, ciphertext2) plaintext = decrypt(ciphertext3, key, 2) assert plaintext == test_function(m1, m2) % key[0], (plaintext, m1, m2, test_function(m1, m2))
def test_encrypt_decrypt(): from unittesting import test_symmetric_encrypt_decrypt secret_key = generate_secret_key() m0 = 0 m1 = 1 mr = random_integer(32) >> 1 c0 = encrypt(m0, secret_key) c1 = encrypt(m1, secret_key) cr = encrypt(mr, secret_key) p0 = decrypt(c0, secret_key) p1 = decrypt(c1, secret_key) pr = decrypt(cr, secret_key) assert p0 == m0, (p0, m0) assert p1 == m1, (p1, m1) assert pr == mr, (pr, mr) test_symmetric_encrypt_decrypt("axbyabe", generate_secret_key, encrypt, decrypt, iterations=10000)
def unit_test(): key = generate_secret_key() m1 = 2 m2 = 3 c1 = encrypt(m1, key) c2 = encrypt(m2, key) c3 = c1 + c2 c4 = c1 * c2 p1 = decrypt(c1, key) p2 = decrypt(c2, key) p3 = decrypt(c3, key, depth=2) p4 = decrypt(c4, key) assert p1 == m1, (p1, m1) assert p2 == m2, (p2, m2) assert p3 == (m1 + m2), (p3, m1, m2) assert p4 == (m1 * m2), (p4, m1, m2) from unittesting import test_symmetric_encrypt_decrypt test_symmetric_encrypt_decrypt("upperehomomorphic", generate_secret_key, encrypt, decrypt)
def test_encrypt_decrypt(): from unittesting import test_symmetric_encrypt_decrypt test_symmetric_encrypt_decrypt("squaremod2", generate_key, encrypt, decrypt) k = random_integer(64) p = random_integer(32) key = [[p, p ** 2, p ** 3], k, modular_inverse(k, N)]#generate_key()#[10, 100, 1000] m1 = 12389124981 m2 = 1000129012 ciphertext1 = encrypt(m1, key) _m1 = decrypt(ciphertext1, key) assert _m1 == m1 % key[0][0], (_m1, m1) ciphertext2 = encrypt(m2, key) test_function = lambda a, b: (a * b) #+ (a * b) + (b * b) ciphertext3 = test_function(ciphertext1, ciphertext2) plaintext = decrypt(ciphertext3, key, 2) assert plaintext == test_function(m1, m2) % key[0][0], (plaintext, m1, m2, test_function(m1, m2))
def unit_test(): key = generate_secret_key() m1 = 2 m2 = 3 c1 = encrypt(m1, key) c2 = encrypt(m2, key) c3 = c1 + c2 c4 = c1 * c2 p1 = decrypt(c1, key) p2 = decrypt(c2, key) p3 = decrypt(c3, key, depth=2) p4 = decrypt(c4, key) assert p1 == m1, (p1, m1) assert p2 == m2, (p2, m2) assert p3 == (m1 + m2), (p3, m1, m2) assert p4 == (m1 * m2), (p4, m1, m2) from unittesting import test_symmetric_encrypt_decrypt test_symmetric_encrypt_decrypt("upperehomomorphic", generate_secret_key, encrypt, decrypt)
def test_encrypt_decrypt(): from unittesting import test_symmetric_encrypt_decrypt secret_key = generate_secret_key() m0 = 0 m1 = 1 mr = random_integer(32) >> 1 c0 = encrypt(m0, secret_key) c1 = encrypt(m1, secret_key) cr = encrypt(mr, secret_key) p0 = decrypt(c0, secret_key) p1 = decrypt(c1, secret_key) pr = decrypt(cr, secret_key) assert p0 == m0, (p0, m0) assert p1 == m1, (p1, m1) assert pr == mr, (pr, mr) test_symmetric_encrypt_decrypt("axbyabe", generate_secret_key, encrypt, decrypt, iterations=10000)
def test_encrypt_decrypt(): key = generate_secret_key() m0 = 0 m1 = 1 mr = random_integer(SECURITY_LEVEL) c0 = encrypt(m0, key) c1 = encrypt(m1, key) cr = encrypt(mr, key) p0 = decrypt(c0, key) p1 = decrypt(c1, key) pr = decrypt(cr, key) assert (m0 == p0), (m0, p0) assert (m1 == p1), (m1, p1) assert (mr == pr), (mr, pr) from unittesting import test_symmetric_encrypt_decrypt test_symmetric_encrypt_decrypt("axby2", generate_secret_key, encrypt, decrypt, iterations=10000)
def test_encrypt_decrypt(): key = generate_secret_key() m0 = 0 m1 = 1 mr = random_integer(SECURITY_LEVEL) c0 = encrypt(m0, key) c1 = encrypt(m1, key) cr = encrypt(mr, key) p0 = decrypt(c0, key) p1 = decrypt(c1, key) pr = decrypt(cr, key) assert (m0 == p0), (m0, p0) assert (m1 == p1), (m1, p1) assert (mr == pr), (mr, pr) from unittesting import test_symmetric_encrypt_decrypt test_symmetric_encrypt_decrypt("axby2", generate_secret_key, encrypt, decrypt, iterations=10000)
def test_encrypt_decrypt(): from unittesting import test_symmetric_encrypt_decrypt test_symmetric_encrypt_decrypt("modular", generate_key, encrypt, decrypt)
def unit_test(): from unittesting import test_symmetric_encrypt_decrypt test_symmetric_encrypt_decrypt("obviouslhe", generate_secret_key, encrypt, decrypt, iterations=10000)
def test_encrypt_decrypt(): from unittesting import test_symmetric_encrypt_decrypt test_symmetric_encrypt_decrypt("modular3", generate_key, encrypt, decrypt, iterations=10000)
def test_encrypt_decrypt(): from unittesting import test_symmetric_encrypt_decrypt test_symmetric_encrypt_decrypt("secretkey", generate_secret_key, encrypt, decrypt, iterations=10000)
def test_encrypt_decrypt(): from unittesting import test_symmetric_encrypt_decrypt test_symmetric_encrypt_decrypt("modular", generate_key, encrypt, decrypt)
def test_encrypt_decrypt(): from unittesting import test_symmetric_encrypt_decrypt test_symmetric_encrypt_decrypt("modular", generate_key, encrypt, decrypt, plaintext_size=32, iterations=10000)