We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
问题1 密钥是用的对称密钥吗?我看加密和解密都是同一个密钥。 问题2 乘法同态计算错误,代码如下:
int precision_bits = 30; auto params = ckks::create_params(4096, precision_bits); std::cout << "(params:" << params << std::endl; CkksSk sk(params); auto relin_key = get_relin_key(sk, params.additional_mod); auto text11 = ckks::encode(text1 , params); auto textC1 = ckks::encrypt(text11, sk); auto text22 = ckks::encode(text2 , params); auto textC2 = ckks::encrypt(text22, sk); auto text2_sub_c = ckks::sub(textC1, textC2); double text2_sub = ckks::decode(ckks::decrypt(text2_sub_c, sk)); std::cout << "text1 - text2:" << text2_sub << std::endl; CkksCt text_sum_c = ckks::add(textC1,textC2); double text_sum = ckks::decode(ckks::decrypt(text_sum_c, sk)); std::cout << "text1 + text2:" << text_sum << std::endl; CkksCt text_mult_c = ckks::mult_plain(textC1,text22); double text_mult = ckks::decode(ckks::decrypt(text_mult_c, sk)); std::cout << "text1 * text2:" << text_mult << std::endl;
入参: text1 = 100,text2=300 结果: text1 - text2:-200 text1 + text2:400 text1 * text2:-200.531
The text was updated successfully, but these errors were encountered:
@zlzhao998 对于第一个问题,是的,目前仅实现了对称加密,暂时没有实现公钥加密的功能。 对于第二个问题,请使用如下的代码逻辑完成上述的功能。
std::vector<double> text1(1); std::vector<double> text2(1); text1[0] = 100.0; text2[0] = 300.0; auto text11 = ckks::simd_encode(text1 , params); auto textC1 = ckks::encrypt(text11, sk); auto text22 = ckks::simd_encode(text2 , params); auto textC2 = ckks::encrypt(text22, sk); CkksCt text_mult_c = ckks::mult_plain(textC1,text22); auto text_mult = ckks::simd_decode(ckks::decrypt(text_mult_c, sk)); std::cout << "text1 * text2:" << text_mult[0] << std::endl;
使用encode和decode,对于一些稍大一些的数值,容易造成溢出。
Sorry, something went wrong.
No branches or pull requests
问题1 密钥是用的对称密钥吗?我看加密和解密都是同一个密钥。
问题2 乘法同态计算错误,代码如下:
入参:
text1 = 100,text2=300
结果:
text1 - text2:-200
text1 + text2:400
text1 * text2:-200.531
The text was updated successfully, but these errors were encountered: