homenc / HElib

HElib is an open-source software library that implements homomorphic encryption. It supports the BGV scheme with bootstrapping and the Approximate Number CKKS scheme. HElib also includes optimizations for efficient homomorphic evaluation, focusing on effective use of ciphertext packing techniques and on the Gentry-Halevi-Smart optimizations.
https://homenc.github.io/HElib
Other
3.14k stars 765 forks source link

Can Helib has can implement a Ctxt divided by two? #299

Closed Ldisi closed 5 years ago

Ldisi commented 5 years ago

Your Contact: Your environment (OS/HW): Detailed Description: Such as, m1 = [2], implement m1/2 = [1], Is there such function?

ssmiler commented 5 years ago

You can do it by changing plaintext space from 2^r to 2^(r-1), look https://github.com/homenc/HElib/blob/master/src/Test_extractDigits.cpp

Ldisi commented 5 years ago

thanks, but the operation "dividend by two" is not easy to realize,am i right?

ssmiler commented 5 years ago

You are right for plaintext spaces mod p where p>2. In the binary case it's easy.

Le mer. 22 mai 2019 à 14:27, Ldisi notifications@github.com a écrit :

thanks, but the operation "dividend by two" is not easy to realize,am i right?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/homenc/HElib/issues/299?email_source=notifications&email_token=ABRE3FVCP7FMZF2Z5XDO6V3PWU3Z5A5CNFSM4HOTVAV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODV64BRA#issuecomment-494780612, or mute the thread https://github.com/notifications/unsubscribe-auth/ABRE3FWVSJYHZPGRM6CPTIDPWU3Z5ANCNFSM4HOTVAVQ .

Ldisi commented 5 years ago

Yes! My work is in plaintext spaces mod p where p >> 2, is there method to do that?

ssmiler commented 5 years ago

No efficient one as I know. You can express the div by 2 function as a polynomial of degree log(p) evaluation. Usually it's costly

Le mer. 22 mai 2019 à 15:54, Ldisi notifications@github.com a écrit :

Yes! My work is in plaintext spaces mod p where p >> 2, is there method to do that?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/homenc/HElib/issues/299?email_source=notifications&email_token=ABRE3FRHSSXMMP4JREF6MTTPWVGAJA5CNFSM4HOTVAV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODV7D36A#issuecomment-494812664, or mute the thread https://github.com/notifications/unsubscribe-auth/ABRE3FXEKGMIHQUDJTYVJ7TPWVGAJANCNFSM4HOTVAVQ .

Ldisi commented 5 years ago

THX ^-^

shaih commented 5 years ago

If your plaintext space is an odd number p, then divide-by-two is the same as multiplying by (p+1)/2.

Ldisi commented 5 years ago

Thanks,you are right.But it still seems difficult to implement (p+1)/2.

shaih commented 5 years ago

it's not difficult, just use ctxt.multByConstant(to_ZZ((p+1)/2))

Ldisi commented 5 years ago

THX!I will try it later

------------------ Original ------------------ From: Shai Halevi notifications@github.com Date: Thu,May 23,2019 11:49 AM To: homenc/HElib HElib@noreply.github.com Cc: Ldisi 1725983010@qq.com, Author author@noreply.github.com Subject: Re: [homenc/HElib] Can Helib has can implement a Ctxt divided by two? (#299)

Ldisi commented 5 years ago

You are right,I have tried it!

------------------ Original ------------------ From: Shai Halevi notifications@github.com Date: Thu,May 23,2019 11:49 AM To: homenc/HElib HElib@noreply.github.com Cc: Ldisi 1725983010@qq.com, Author author@noreply.github.com Subject: Re: [homenc/HElib] Can Helib has can implement a Ctxt divided by two? (#299)

it's not difficult, just use ctxt.multByConstant(to_ZZ((p+1)/2))

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.