(testcase)
| 21 | |
| 22 | @pytest.mark.parametrize("testcase", [[10, 20, 30], [1 / div for div in range(2, 10)]]) |
| 23 | def test_ckks_encoder(testcase): |
| 24 | ctx = helper_context_ckks() |
| 25 | encoder = sealapi.CKKSEncoder(ctx) |
| 26 | |
| 27 | plaintext = sealapi.Plaintext() |
| 28 | encoder.encode(testcase, 2**40, plaintext) |
| 29 | out = encoder.decode_double(plaintext) |
| 30 | |
| 31 | is_close_enough(out, testcase) |
| 32 | |
| 33 | keygen = sealapi.KeyGenerator(ctx) |
| 34 | pk = sealapi.PublicKey() |
| 35 | public_key = keygen.create_public_key(pk) |
| 36 | secret_key = keygen.secret_key() |
| 37 | |
| 38 | decryptor = sealapi.Decryptor(ctx, secret_key) |
| 39 | encryptor = sealapi.Encryptor(ctx, pk, secret_key) |
| 40 | |
| 41 | plaintext = sealapi.Plaintext() |
| 42 | ciphertext = sealapi.Ciphertext(ctx) |
| 43 | |
| 44 | encoder.encode(testcase, 2**40, plaintext) |
| 45 | encryptor.encrypt(plaintext, ciphertext) |
| 46 | |
| 47 | plaintext_out = sealapi.Plaintext() |
| 48 | |
| 49 | decryptor.decrypt(ciphertext, plaintext_out) |
| 50 | decrypted = encoder.decode_double(plaintext) |
| 51 | is_close_enough(decrypted, testcase) |
nothing calls this directly
no test coverage detected