-
Notifications
You must be signed in to change notification settings - Fork 39
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 support of encrypt and decrypt with denglin gpu card #74
Conversation
CLA Assistant Lite bot: I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request |
@@ -0,0 +1,25 @@ | |||
// Copyright 2022 Ant Group Co., Ltd. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
年份改成2023; 版权允许声明为 denglin,不一定必须ant group
|
||
// DJ paillier scheme, reference: https://www.brics.dk/DS/03/9/BRICS-DS-03-9.pdf | ||
|
||
#include "heu/library/algorithms/paillier_zahlen/ciphertext.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
所有的头文件路径都不对啊
@@ -0,0 +1,413 @@ | |||
#include <gmp.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GPL 与隐语的 Apache 2.0 协议冲突,需要重新看一下怎么规避
|
||
#define DEBUG | ||
|
||
namespace heu::lib::algorithms::paillier_z { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ns 名称 paillier_z 需要改
#include <gmp.h> | ||
#include "cgbn/cgbn.h" | ||
// #include "cgbn_wrapper_defs.h" | ||
#include "cgbn_wrapper.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include 都使用全路径
Encryptor::Encryptor(PublicKey pk) : pk_(std::move(pk)) {} | ||
Encryptor::Encryptor(const Encryptor &from) : Encryptor(from.pk_) {} | ||
|
||
MPInt Encryptor::GetRn() const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetRn 是内部函数,可以直接删掉
HE_ASSERT(!(ct).c_.IsNegative() && (ct).c_ < pk_.n_square_, \ | ||
"Decryptor: Invalid ciphertext") | ||
|
||
void Decryptor::Decrypt(const Ciphertext& ct, MPInt* out) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scalar 版本和 Vectorized 版本的函数是二选一的,没必要都实现。 encryptor和 evaluator 中的函数同理
CUDA_CHECK(cudaMalloc((void **)&dev_ciphers, sizeof(cgbn_mem_t<BITS>) * count)); | ||
CUDA_CHECK(cudaMalloc((void **)&dev_pub_key, sizeof(pk))); | ||
for (int i=0; i<count; i++) { | ||
CUDA_CHECK(cudaMemcpy(dev_plains[i]._limbs, handled_pts[i].n_.dp, handled_pts[i].SizeUsed(), cudaMemcpyHostToDevice)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不同的大整数库内存格式不通用的,不能直接 copy,请用 MPInt 的接口把数值导出成 bytes
特别是MPInt,每一个int64 只用其中的 60bits,最高4bit 是不同的。
No description provided.