Esempio n. 1
0
    def setUp(self):
        initialize('float')
        pub, priv, relin = generate_keypair()
        set_public_key(pub)
        set_private_key(priv)
        set_relin_keys(relin)

        display_config()
Esempio n. 2
0
from pathlib import Path
from simplefhe import initialize, generate_keypair

# All subsequent processing must be done with the same initialization
initialize('float')

# Generate keypair
public_key, private_key, relin_keys = generate_keypair()

# Save keys
Path('keys').mkdir(exist_ok=True)
public_key.save('keys/public.key')
private_key.save('keys/private.key')
relin_keys.save('keys/relin.key')

print('Keys saved to keys/ directory')
Esempio n. 3
0
 def setUp(self):
     initialize('int')
     pub, priv, relin = generate_keypair()
     set_public_key(pub)
     set_private_key(priv)
     set_relin_keys(relin)
Esempio n. 4
0
from simplefhe import (encrypt, decrypt, generate_keypair, set_public_key,
                       set_private_key, set_relin_keys, initialize,
                       display_config)

initialize('int')

public_key, private_key, relin_key = generate_keypair()
set_private_key(private_key)
set_public_key(public_key)
set_relin_keys(relin_key)

display_config()


# The server
def process(x):
    return x**21


# The client
sensitive_data = [-3, 1, 3, 10]
for entry in sensitive_data:
    insecure_result = process(entry)
    secure_result = decrypt(process(encrypt(entry)))
    print(entry, insecure_result, secure_result)