Open siaaron045 opened 5 years ago
Hi siaaron045
I tested as the following command.
// Encrypt mvec
Ciphertext cipher = scheme.encrypt(mvec, slots, L);
// Multiple negative value (= -0.1)
Ciphertext cmultCipher = scheme.multByConst(cipher, -0.1);
scheme.reScaleByAndEqual(cmultCipher, 1);
I checked the decrypted result. And It seems correct. It would be better if you can attach some part of your code.
Best, Kyoohyung Han
I test your code and the answer is right,
but when ''cipher'' is a negative number's ciphertext or make multiplication of two negative ciphertext,the answer is wrong.
like this:
//Encrypt mvec=-5 Ciphertext cipher1 = scheme.encrypt(mvec, slots, L); Ciphertext cipher2=cipher1; Ciphertext cmultCipher = scheme.multByConst(cipher1, -1); //or Ciphertext cmultCipher = scheme.mult(cipher1, cipher2); scheme.reScaleByAndEqual(cmultCipher, 1);
both of the answers are wrong.
So the encrypted number can't be negative?
Oh... when I put -1 instead of -5 it works.
This problem came from the negate function in Context.cpp. I will fix this problem soon.
Thanks for the report.
Yes,but it works only when mvec=-1, i put -2,-3,-4 the answers are wrong. And the function scheme.mult(cipher1, cipher2) does not work when make multiplication of two negative ciphertext expect -1. Thanks.
The error still exist. I hope you can take some time to fix it. Thank you.
@KyoohyungHan Looks like you found the error source. Can you be more specific where is it? I think I can submit a patch.
The error still exist. I hope you can take some time to fix it. Thank you.
Hi~ is this problem solved? I found the same error too,but i have no idea how to fix it?Where exactly does this problem occur?
This problem is not because of the negate function, but because of a problem with encode, where for copying simply adding the modulus leads to an encoding error. You can fix it by referring to the encoding functions of OPENFHE or Lattigo.
I am sorry to trouble you. When i use FullRNS-HEAAN to do a negative number multiplication, the answer is wrong. Can FullRNS-HEAAN do negative number multiplication?(negative number addition is right) Thanks a million.