# Proxy Re-encryption Using CKKS

**URL:** <https://openfhe.discourse.group/t/proxy-re-encryption-using-ckks/83>\
**Category:** Library Questions\
**Tags:** questions\
**Created:** [August 3, 2022, 2:54pm UTC](https://openfhe.discourse.group/t/proxy-re-encryption-using-ckks/83 "2022-08-03T14:54:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zerokerim](https://avatars.discourse-cdn.com/v4/letter/z/85e7bf/32.png) [@zerokerim](https://openfhe.discourse.group/u/zerokerim)\
**Post date:** [August 3, 2022, 2:54pm UTC](https://openfhe.discourse.group/t/proxy-re-encryption-using-ckks/83/1 "2022-08-03T14:54:29Z")

</div>

Hi,

I started experimenting with the PALISADE library for the project I’m working on, I would like to perform Proxy Re-encryption using CKKS ciphertexts of real values. I checked the example codes (in src/pke/examples) there is regarding Proxy Re-encryption (especially the pre.cpp one).

In this example we have access to two sets of parameters BFV-PRE and Null-PRE. I tested the code with the BFV-PRE parameters and it worked fine.

But I would like to perform the same tasks with CKKS and there are no parameter sets for this scheme. But it is written in the documentation that Proxy Re-encryption is supported for CKKS. So I guess I have to build my own CryptoContext with CKKS.

So here are my questions :

- First of all, do I have to build my own CryptoContext to use pre with CKKS ? and if yes is there any specific detail I have to pay attention to while doing it ?
- After building my own CryptoContext with CKKS will functions such as cryptoContext-\>ReKeyGen or , cryptoContext-\>ReEncrypt still can be used ?

Thank you in advance for your help !

---

<div class="post-metadata">

**Author:** ![ypolyakov](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/ypolyakov/32/47_2.png) [@ypolyakov](https://openfhe.discourse.group/u/ypolyakov)\
**Post date:** [August 7, 2022, 9:46pm UTC](https://openfhe.discourse.group/t/proxy-re-encryption-using-ckks/83/2 "2022-08-07T21:46:10Z")

</div>

At a high level, the logic for CKKS should be the same as shown in [openfhe-development/pre-buffer.cpp at main · openfheorg/openfhe-development · GitHub](https://github.com/openfheorg/openfhe-development/blob/main/src/pke/examples/pre-buffer.cpp) for BFV. The only difference is in the cryptocontext generation and encoding of vectors of real numbers rather than vectors of integers.

I also suggest looking at the unit tests for PRE using CKKS: [openfhe-development/UnitTestCKKSrns.cpp at main · openfheorg/openfhe-development · GitHub](https://github.com/openfheorg/openfhe-development/blob/main/src/pke/unittest/utckksrns/UnitTestCKKSrns.cpp) (Search for “UnitTest\_ReEncryption” there.)

For CKKS CryptoContext generation, you can use the code in [openfhe-development/simple-real-numbers.cpp at main · openfheorg/openfhe-development · GitHub](https://github.com/openfheorg/openfhe-development/blob/main/src/pke/examples/simple-real-numbers.cpp) You will only need to add one line to this code.

```auto
cc->Enable(PRE);

```

Note that in CKKS, PRE introduces approximation errors, just like it does in any CKKS computations. So I recommend using this approach only when you need to use CKKS for some FHE computations, i.e., the approximation error is not an issue. Otherwise, BGV or BFV should be a better option as no approximation error is introduced.
