Skip to content

Commit 71707d2

Browse files
committed
Add public private and evalkey serialization tests
1 parent d5fab42 commit 71707d2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/test_serial_cc.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,26 @@ def test_serial_cryptocontext_str(mode):
4848

4949
cryptoContext = fhe.GenCryptoContext(parameters)
5050
cryptoContext.Enable(fhe.PKESchemeFeature.PKE)
51+
cryptoContext.Enable(fhe.PKESchemeFeature.PRE)
5152

5253
keypair = cryptoContext.KeyGen()
5354
vectorOfInts = list(range(12))
5455
plaintext = cryptoContext.MakePackedPlaintext(vectorOfInts)
5556
ciphertext = cryptoContext.Encrypt(keypair.publicKey, plaintext)
57+
evalKey = cryptoContext.ReKeyGen(keypair.secretKey, keypair.publicKey)
58+
5659

5760
cryptoContext_ser = fhe.Serialize(cryptoContext, mode)
5861
LOGGER.debug("The cryptocontext has been serialized.")
62+
publickey_ser = fhe.Serialize(keypair.publicKey, mode)
63+
LOGGER.debug("The public key has been serialized.")
64+
secretkey_ser = fhe.Serialize(keypair.secretKey, mode)
65+
LOGGER.debug("The private key has been serialized.")
5966
ciphertext_ser = fhe.Serialize(ciphertext, mode)
6067
LOGGER.debug("The ciphertext has been serialized.")
68+
evalKey_ser = fhe.Serialize(evalKey, mode)
69+
LOGGER.debug("The evaluation key has been serialized.")
70+
6171

6272
cryptoContext.ClearEvalMultKeys()
6373
cryptoContext.ClearEvalAutomorphismKeys()
@@ -67,6 +77,18 @@ def test_serial_cryptocontext_str(mode):
6777
assert isinstance(cc, fhe.CryptoContext)
6878
LOGGER.debug("The cryptocontext has been deserialized.")
6979

80+
pk = fhe.DeserializePublicKeyString(publickey_ser, mode)
81+
assert isinstance(pk, fhe.PublicKey)
82+
LOGGER.debug("The public key has been deserialized.")
83+
84+
sk = fhe.DeserializePrivateKeyString(secretkey_ser, mode)
85+
assert isinstance(sk, fhe.PrivateKey)
86+
LOGGER.debug("The private key has been deserialized.")
87+
7088
ct = fhe.DeserializeCiphertextString(ciphertext_ser, mode)
7189
assert isinstance(ct, fhe.Ciphertext)
7290
LOGGER.debug("The ciphertext has been reserialized.")
91+
92+
ek = fhe.DeserializeEvalKeyString(evalKey_ser, mode)
93+
assert isinstance(ek, fhe.EvalKey)
94+
LOGGER.debug("The evaluation key has been deserialized.")

0 commit comments

Comments
 (0)