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 support of encrypt and decrypt with denglin gpu card #74

Closed
wants to merge 4 commits into from
Closed

Add support of encrypt and decrypt with denglin gpu card #74

wants to merge 4 commits into from

Conversation

shengweigit
Copy link

No description provided.

@github-actions
Copy link

CLA Assistant Lite bot:
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


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.
Copy link
Member

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"
Copy link
Member

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>
Copy link
Member

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 {
Copy link
Member

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"
Copy link
Member

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 {
Copy link
Member

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 {
Copy link
Member

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));
Copy link
Member

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 是不同的。

@shengweigit shengweigit closed this by deleting the head repository Nov 23, 2023
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

Successfully merging this pull request may close these issues.

2 participants