# Use openfhe python after tenseal library

**URL:** <https://openfhe.discourse.group/t/use-openfhe-python-after-tenseal-library/1956>\
**Category:** Library Questions\
**Created:** [March 25, 2025, 10:57am UTC](https://openfhe.discourse.group/t/use-openfhe-python-after-tenseal-library/1956 "2025-03-25T10:57:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![daria](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@daria](https://openfhe.discourse.group/u/daria)\
**Post date:** [March 25, 2025, 10:57am UTC](https://openfhe.discourse.group/t/use-openfhe-python-after-tenseal-library/1956/1 "2025-03-25T10:57:31Z")

</div>

Hi! I am new in cryptography. I used the library TenSeal to encrypt data for linear regression training and evaluating. I want to switch libraries, but i find it hard to see which functions are equivalent. Can someone help me, please?

Those are the functions used in TenSeal:

```auto
# parameters
poly_mod_degree = 4096
coeff_mod_bit_sizes = [40, 20, 40]
# create TenSEALContext
ctx_eval = ts.context(ts.SCHEME_TYPE.CKKS, poly_mod_degree, -1, coeff_mod_bit_sizes)
# scale of ciphertext to use
ctx_eval.global_scale = 2 ** 20
# this key is needed for doing dot-product operations
ctx_eval.generate_galois_keys()

 enc_x_test = [ts.ckks_vector(ctx_eval, x.tolist()) for x in x_test[:700]]

#prediction function for my model
def forward_on_encrypted_data(self,enc_x):
        enc_pred = enc_x.dot(self.lr.weight.data.tolist()[0])+self.lr.bias.data.tolist()
        return enc_pred

```

Thank you!  
@ypolyakov  
@andreea.alexandru

---

<div class="post-metadata">

**Author:** ![andreea.alexandru](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/andreea.alexandru/32/378_2.png) [@andreea.alexandru](https://openfhe.discourse.group/u/andreea.alexandru)\
**Post date:** [March 26, 2025, 1:55pm UTC](https://openfhe.discourse.group/t/use-openfhe-python-after-tenseal-library/1956/2 "2025-03-26T13:55:37Z")

</div>

Please look at the examples provided here [openfhe-development/src/pke/examples at main · openfheorg/openfhe-development · GitHub](https://github.com/openfheorg/openfhe-development/tree/main/src/pke/examples), they are designed to provide a starting point for users of the library. Each of them shows how to generate the criptocontext, set the ring dimension (poly\_mod\_degree), generate the rotation keys for the inner product (generate\_galois\_keys), etc. For your application, take a look specifically at [openfhe-development/src/pke/examples/inner-product.cpp at main · openfheorg/openfhe-development · GitHub](https://github.com/openfheorg/openfhe-development/blob/main/src/pke/examples/inner-product.cpp#L89).

---

<div class="post-metadata">

**Author:** ![daria](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@daria](https://openfhe.discourse.group/u/daria)\
**Post date:** [March 26, 2025, 4:00pm UTC](https://openfhe.discourse.group/t/use-openfhe-python-after-tenseal-library/1956/3 "2025-03-26T16:00:28Z")

</div>

Thank you for your suggestions! I will take a look and get back to you if i have any more questions.  
Thanks for replaying!
