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

Add Karatsuba's trick for tensoring ciphertexts in mul #4

Open
Janmajayamall opened this issue Jul 15, 2023 · 5 comments
Open

Add Karatsuba's trick for tensoring ciphertexts in mul #4

Janmajayamall opened this issue Jul 15, 2023 · 5 comments

Comments

@Janmajayamall
Copy link
Owner

Janmajayamall commented Jul 15, 2023

Add Karatsuba's trick for ciphertext multiplication and benchmark it against normal tensoring for different polynomial degrees.

@ameya-deshmukh
Copy link

@Janmajayamall can I take this up ser

@Janmajayamall
Copy link
Owner Author

Yup!

@Janmajayamall
Copy link
Owner Author

Janmajayamall commented Jul 22, 2023

At present we tensor degree 1 ciphertexts ct0 = (c00, c01) and ct1 = (c10, c11) the usual way
r00 = c00 * c10
r01 = c00 * c11 + c01 * c10
r02 = c01 * c11

With Karatsuba's trick the calculation will change to
r00 = c00 * c10
r02 = c01 * c11
r01 = (c00 + c01) * (c10 + c11) - r00 - r02

This replaces 2 vector modulur multiplications with 2 vector modulur additions, 2 vector modulur subtrations, and 1 vector modulur multiplication.

So assuming 2 additions and 2 subtrations are cheaper than a single multiplication (which is the case if you bench modulus), this should speed up tensoring.

But we should run benchmarks for multiplications after adding Karatsurba's trick on mac and x86 (using hexl and for modulus bit size <= 50 and > 50).

Tensoring code lives here.

Thanks for looking into this :)

@nlok5923
Copy link

@Janmajayamall Is @ameya-deshmukh still working on this If not would love to take this up as this seems to be a good first issue to get started.

@Janmajayamall
Copy link
Owner Author

@nlok5923 I don't think Ameya is still working on it.

Please feel free to take this up. Thanks!

@github-staff github-staff deleted a comment Apr 26, 2024
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

4 participants
@Janmajayamall @nlok5923 @ameya-deshmukh and others