Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIMD operations Ring_Element and Rq_Element #1572

Open
sknc opened this issue Jan 9, 2025 · 9 comments
Open

SIMD operations Ring_Element and Rq_Element #1572

sknc opened this issue Jan 9, 2025 · 9 comments

Comments

@sknc
Copy link

sknc commented Jan 9, 2025

Hello Marcel,
How do you implement SIMD as proposed by Smart and Vercauteren: https://eprint.iacr.org/2011/133.pdf in MP-SPDZ on Ring_Elements and Rq_Elements?

@mkskeller
Copy link
Member

MP-SPDZ implements SIMD addition and multiplication as described in the documentation: https://mp-spdz.readthedocs.io/en/latest/homomorphic-encryption.html
The bit-slicing mentioned in the paper is not implemented.

@sknc
Copy link
Author

sknc commented Jan 10, 2025

Hello Marcel,

I am looking at he-example.cpp. I can see the multiple slots in the plaintext but I don't see where the encoding and decoding using the Chinese Remainder Theorem is occurring. I can see something that seems to be related to it in the void init(P2Data& P2D,const Ring& Rg) method NTL-Subs.cpp but am unsure how that relates.

@mkskeller
Copy link
Member

This happens in Plaintext_::to_poly() and Plaintext::from_poly(). For prime-modulus cleartexts, this calls Ring_Element::change_rep(), and for binary cleartexts, it calls P2Data::forward() and P2Data::backward().

@sknc
Copy link
Author

sknc commented Jan 10, 2025

Isn't that the method using Fast Fourier Transform to change between coefficient and evaluation representation of polynomials? How does that relate to using CRT to encode multiple polynomials into a single one?

@mkskeller
Copy link
Member

CRT is used in Rq_Element::to_vec_bigint.

@sknc
Copy link
Author

sknc commented Jan 13, 2025

I understand that but I don't see what that has to do with the FHE.

@mkskeller
Copy link
Member

Maybe I misunderstood the question. What do you mean by encoding multiple polynomials into a single one?

@sknc
Copy link
Author

sknc commented Jan 13, 2025

Using the Chinese remainder theorem, for integers $x \in Z_p$, $y \in Z_q$, and $z \in Z_r$, one can calculate $w \in Z_{xyz}$. One can then operate over $w$ in lieu of operating over $x$, $y$, and $z$ separately. A similar thing can be done with polynomials to my understanding.

@mkskeller
Copy link
Member

mkskeller commented Jan 13, 2025

And you're referring to the CRT mentioned in Section 2 of the above paper? I think this happens in P2Data::forward(), and the init() function you've identified computes the linear relation depending on the polynomial degrees.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants