<jupyter_start><jupyter_text>Testing Individual components of the FV HE scheme<jupyter_code>import random

from syft.frameworks.torch.he.fv.modulus import CoeffModulus
from syft.frameworks.torch.he.fv.encryption_params import EncryptionParams
from syft.frameworks.torch.he.fv.context import Context
from syft.frameworks.torch.he.fv.integer_encoder import IntegerEncoder
from syft.frameworks.torch.he.fv.key_generator import KeyGenerator
from syft.frameworks.torch.he.fv.encryptor import Encryptor
from syft.frameworks.torch.he.fv.decryptor import Decryptor
from syft.frameworks.torch.he.fv.integer_encoder import IntegerEncoder
from syft.frameworks.torch.he.fv.modulus import SeqLevelType
from syft.frameworks.torch.he.fv.evaluator import Evaluator<jupyter_output>Falling back to insecure randomness since the required custom op could not be found for the installed version of TensorFlow. Fix this by compiling custom ops. Missing file was '/usr/local/lib/python3.7/site-packages/tf_encrypted/operations/secure_random/secure_random_module_tf_1.15.3.so'
WARNING:tensorflow:From /usr/local/lib/python3.7/site-packages/tf_encrypted/session.py:24: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.<jupyter_text>Keygeneration<jupyter_code>ctx = Context(EncryptionParams(128, CoeffModulus().create(128, [30]), 128 ))
keygenerator = KeyGenerator(ctx)
sk, pk = keygenerator.keygen()
print(ctx.param.coeff_modulus)
# print(len(sk.data))
# print('secret key values : ', sk.data)
# print(pk.data)
# print('public key values : ', pk.data)<jupyter_output><empty_output><jupyter_text>Integer EncoderEncodes Integer values to Plaintext object<jupyter_code>int_encoder = IntegerEncoder(ctx)
ri1 = random.randint(0,1000)
ri2 = random.randint(0,1000)
ri3 = random.randint(0,1000)
pt1 = int_encoder.encode(ri1)
pt2 = int_encoder.encode(ri2)
pt3 = int_encoder.encode(ri3)
print(pt1.data,"   ", pt2.data, "   ", pt3.data)
# print('plaintext data',plaintext.data)<jupyter_output>[1, 0, 0, 1, 1, 1, 0, 0, 1, 1]     [1, 1, 0, 1, 0, 0, 1, 0, 1]     [1, 1, 1, 0, 1, 1, 0, 1, 1]<jupyter_text>Decodes back to Integer<jupyter_code>print(int_encoder.decode(pt1))
print(int_encoder.decode(pt2))
print(int_encoder.decode(pt3))<jupyter_output>825
331
439<jupyter_text>EncrypterEncrypt Plaintext to ciphertext using public_key<jupyter_code>encrypter = Encryptor(ctx, pk)
ct1 = encrypter.encrypt(pt1)
ct2 = encrypter.encrypt(pt2)
ct3 = encrypter.encrypt(pt3)<jupyter_output><empty_output><jupyter_text>Encrypt Plaintext to ciphertext using secret_key  DecryptorDecrypt Ciphertext to Plaintext using secret_key<jupyter_code>decrypter = Decryptor(ctx, sk)
dec1 = decrypter.decrypt(ct1)
dec2 = decrypter.decrypt(ct2)
dec3 = decrypter.decrypt(ct3)
print(int_encoder.decode(dec1), "   ", int_encoder.decode(dec2), "   ", int_encoder.decode(dec3))<jupyter_output>825     331     439<jupyter_text>Evaluator<jupyter_code>eval = Evaluator(ctx)
cc12 = eval.add(ct1, ct2)
cc12 = decrypter.decrypt(cc12)
print(int_encoder.decode(cc12))
pc12 = eval.add(pt1, ct2)
pc12 = decrypter.decrypt(pc12)
print(int_encoder.decode(pc12))
pp12 = eval.add(pt1, pt2)
print(int_encoder.decode(pp12))<jupyter_output>1156<jupyter_text>Verify result<jupyter_code>assert int_encoder.decode(cc12) == int_encoder.decode(pc12) == int_encoder.decode(pp12) == ri1+ri2<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11970149253731344, 'fraction_numerical': 0.045074626865671645, 'mean_word_length': 6.997613365155131, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '522972', 'license': 'Apache-2.0', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1265, 'n_words': 226, 'path': 'examples/experimental/FV HE Experimentation.ipynb', 'repo_name': 'BenjaminDev/PySyft', 'size': '3350'}