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

Optimizations for Shamir-based Protocol #880

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

f7ed
Copy link

@f7ed f7ed commented Oct 11, 2024

Pull Request

What problem does this PR solve?

主要修改&优化:

libspu/mpc/utils/gfmp_ops.cc

  •        修改gfmp_reconstruct_shamir_shares中的公式
  •        增加batch_inversion操作,以及相应的gtest
    libspu/mpc/shamir/arithmetic.cc
  •        增加MulAAP接口(即合并MulAA + A2P运算),以及相应的gtest;
  •        增加PRZS(随机零分享)接口;
  •        修改P2A协议:random shamir sharing -> public values as sharing;
    libspu/mpc/shamir/boolean.cc
  •        修改B2P协议:-> B2A + A2P
  •        修改B2V协议:-> B2A + A2V
    libspu/mpc/shamir/conversion.cc
  •        用batch_inversion优化rand_bits
  •        利用梅森素数的性质优化rand_bits协议
  •        删除rand_bits_pair协议
  •        利用梅森素数的性质优化solved_bits
  •        新增gen_prefix_mul_share接口,生成用于计算prefix_mult所需的random pairs
  •        利用gen_prefix_mul重新实现prefix_mul协议,测试MsbA接口
  •        利用重新实现的prefix_mul接口优化bit_it_ap协议
  •        优化unbounded_carries协议
  •        优化A2B协议
  •        新增MultAATrunc协议,即定点小数乘法协议

Issue Number: Fixed #

Possible side effects?

  • Performance:

  • Backward compatibility:

tpppppub and others added 9 commits August 23, 2024 10:21
# Pull Request

## What problem does this PR solve?

Issue Number: Fixed #

## Possible side effects?

- Performance:

- Backward compatibility:
Copy link

github-actions bot commented Oct 11, 2024

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@f7ed
Copy link
Author

f7ed commented Oct 11, 2024

I have read the CLA Document and I hereby sign the CLA

@f7ed
Copy link
Author

f7ed commented Oct 11, 2024

recheck

@@ -623,12 +625,10 @@ Value xor_pp(SPUContext* ctx, const Value& x, const Value& y) {
Value lshift_s(SPUContext* ctx, const Value& x, const Sizes& bits) {
SPU_TRACE_MPC_DISP(ctx, x, bits);
TRY_DISPATCH(ctx, x, bits);
if (IsA(x)) {
if (IsA(x) && ctx->hasKernel("lshift_a")) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

若是ArithShare,但有没有lshift_a,也走lshift_b吗?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

若是ArithShare,但有没有lshift_a,也走lshift_b吗?

是的

@@ -25,6 +25,7 @@ namespace spu::mpc::test {
namespace {

Shape kShape = {20, 30};
// Shape kShape = {3};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean pls.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please delete this file

@@ -623,12 +625,10 @@ Value xor_pp(SPUContext* ctx, const Value& x, const Value& y) {
Value lshift_s(SPUContext* ctx, const Value& x, const Sizes& bits) {
SPU_TRACE_MPC_DISP(ctx, x, bits);
TRY_DISPATCH(ctx, x, bits);
if (IsA(x)) {
if (IsA(x) && ctx->hasKernel("lshift_a")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

若是ArithShare,但有没有lshift_a,也走lshift_b吗?

是的

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please delete this file

public:
static constexpr const char* kBindName() {return "rand_a"; }

Kind kind() const override { return Kind::Dynamic; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add the communication complexity

@@ -0,0 +1,16 @@
{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个文件不需要进主线吧?


ce::CExpr comm() const override { return ce::Const(0); }

NdArrayRef proc(KernelEvalContext* ctx, const NdArrayRef& in) const override;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NotA::proc 的实现在哪呢?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove class NotA if not need.

@w-gc w-gc requested review from tpppppub and w-gc November 5, 2024 06:46
_prefix_prod[i] = mul_mod(_prefix_prod[i - 1], _x[i]);
}

ring2k_t pprod_inverse = mul_inv(_prefix_prod[numel - 1]);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused-variable


ce::CExpr comm() const override { return ce::Const(0); }

NdArrayRef proc(KernelEvalContext* ctx, const NdArrayRef& in) const override;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove class NotA if not need.

@w-gc w-gc self-requested a review November 8, 2024 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants