# Matrix encryption

**URL:** <https://openfhe.discourse.group/t/matrix-encryption/1310>\
**Category:** FHE Questions\
**Created:** [May 30, 2024, 2:12pm UTC](https://openfhe.discourse.group/t/matrix-encryption/1310 "2024-05-30T14:12:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Salay1](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@Salay1](https://openfhe.discourse.group/u/Salay1)\
**Post date:** [May 30, 2024, 2:12pm UTC](https://openfhe.discourse.group/t/matrix-encryption/1310/1 "2024-05-30T14:12:41Z")

</div>

In this paper [Secure Transformer Inference Made Non-interactive](https://eprint.iacr.org/2024/136) I have seen an equation like Enc(x)=E(pi(x)) who pi code this a vector x into a polynome p, E encrypt this polynome p, and Enc denote the SIMD encryption of a vector.  
I don’t know how return Enc? It is vector of polynôme if E is the CKKS encryption ?

---

<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:** [June 6, 2024, 1:40am UTC](https://openfhe.discourse.group/t/matrix-encryption/1310/2 "2024-06-06T01:40:45Z")

</div>

@Salay1 Could you rewrite the question more clearly? I was trying to understand the question but there are too many grammatical errors and non-English words. So it is hard to understand what you are asking.

---

<div class="post-metadata">

**Author:** ![Salay1](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@Salay1](https://openfhe.discourse.group/u/Salay1)\
**Post date:** [June 6, 2024, 7:05pm UTC](https://openfhe.discourse.group/t/matrix-encryption/1310/3 "2024-06-06T19:05:58Z")

</div>

In the paper ([Secure Transformer Inference Made Non-interactive](https://eprint.iacr.org/2024/136)) I don’t understand this SIMD encryption function Enc(). It says that this function takes a vector x and return a SIMD cyphertex Enc(x)=E(pi(x)), pi take a vector x and return a polynom p. I don’t know a SIMD cyphertex. It is a vector or a polynom? If E() is the RNS-CKKS E(pi(x)) a couple of polynomial.  
I don’t also understand the RNS-CKKS.

---

<div class="post-metadata">

**Author:** ![Caesar](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/caesar/32/63_2.png) [@Caesar](https://openfhe.discourse.group/u/Caesar)\
**Post date:** [June 7, 2024, 2:30pm UTC](https://openfhe.discourse.group/t/matrix-encryption/1310/4 "2024-06-07T14:30:28Z")

</div>

1. The user provides input as a vector of double data, say \mathbf{x}=\{x\_0, x\_1, x\_2, \ldots\}
2. Before encryption, the user has to encode \mathbf{x} into an internal representation that is compatible with how CKKS machinery manipulates data. This internal representation, which the unsophisticated user does not need to know about, is actually a polynomial. Out of this step, you get: p(x)=\text{Encode}(\mathbf{x}), and p(x) is the polynomial encoding the input vector data \mathbf{x}, also known as plaintext.
3. Lastly, you can encrypt p(x) to generate a ciphertext that encrypts the polynomial encoding of the input vector \mathbf{x}. This step gives you: c=\text{Encrypt}(p(x)), where c is a ciphertext.

To understand the SIMD aspect of CKKS, think of both p(x) and c as vectors. CKKS operations on plaintexts and ciphertexts will be invoked coefficient-wise.  
Eg:  
c\_1 = \text{Encrypt}(\text{Encode}(\mathbf{a}=\{a\_0, a\_1, \ldots\})), and  
c\_2 = \text{Encrypt}(\text{Encode}(\mathbf{b}=\{b\_0, b\_1, \ldots\})), then say  
c\_3=\text{EvalAdd}(c\_1,c\_2), will include an encryption of \{a\_0+b\_0, a\_1+b\_1, \ldots\}, and the same applies for \text{EvalMult}.

Finally, RNS-CKKS is a specific implementation of CKKS that uses a residual number system (RNS). Roughly speaking, think of it as an equivalent to CKKS.

I think it would be helpful for you to study some online tutorials on CKKS.  
Please refer to the series below which describes the CKKS scheme.

> **[CKKS explained: Part 1, Vanilla Encoding and Decoding](https://blog.openmined.org/ckks-explained-part-1-simple-encoding-and-decoding/)**
>
> First part of the series CKKS explained where we see how to implement a vanilla encoder and decoder.
