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

[Question]: SPDZ2k协议中实现两方乘积 #976

Open
c-doubley opened this issue Jan 18, 2025 · 3 comments
Open

[Question]: SPDZ2k协议中实现两方乘积 #976

c-doubley opened this issue Jan 18, 2025 · 3 comments

Comments

@c-doubley
Copy link

Feature Request Type

Build/Install

Have you searched existing issues?

Yes

Is your feature request related to a problem?

我尝试在SPDZ2k中新增子协议,其中需要执行一个操作:参与方P0拥有a,P1拥有b计算a*b。这里由于a b是指定的不是随机值,所以不直接使用beaver三元组来生成。注意,P0和P1拥有秘密本身而不是秘密份额。
这里a b都是环元素
我的思路是

  1. P0使用makeType<spu::mpc::spdz2k::AShrTy>(field)生成a的秘密份额a_shr[0]和a_shr[1],然后将a_shr[1]发送给P1
  2. P1使用makeType<spu::mpc::spdz2k::AShrTy>(field)生成b的秘密份额b_shr[0]和b_shr[1],然后将b_shr[0]发送给P0
  3. P0和P1分别计算c0=MulAA.proc(a_shr[0],b_shr[0])c1=MulAA.proc(a_shr[1],b_shr[1])
  4. 将c0 c1还原回环元素
    我的问题是这似乎比较麻烦,还有更简单直接的方法吗?

Describe features you want to add to SPU

A clear and concise description of what you want to happen.

Describe features you want to add to SPU

A clear and concise description of any alternative solutions or features you've considered.

@w-gc
Copy link
Collaborator

w-gc commented Jan 20, 2025

请教下,你的思路中,是如何计算a_0 * b_1a_1 * b_0的,不是很理解:

$$a * b = (a_0 + a_1) * (b_0 + b_1) = a_0 * b_0 + a_0 * b_1 + a_1 * b_0 + a_1 * b_1 = c_0 + a_0 * b_1 + a_1 * b_0 + c_1$$

@c-doubley
Copy link
Author

是我理解的不对吗
假设z_0+z_1 = x * y
对于P0来说 MulAA.proc(a_shr[0],b_shr[0]执行如下

  1. 打开(a-x)(b-y)
  2. c0 = (a-x)*(b-y) + a_0 * (b-y) + (a-x) * b_0 - z_0

对于P1来说 MulAA.proc(a_shr[1],b_shr[1])执行如下

  1. 打开(a-x)(b-y)
  2. c1 = a_1 * (b-y) + (a-x) * b_1 - z_1

最后有 c0+c1=a*b

@c-doubley
Copy link
Author

您好,我还想问一下,我发现似乎beaver的操作不会影响comm->getStats(),也就是说我没办法通过comm来记录beaver操作带来的通信量,这个也算合理,我想问的是我有其他方法可以得知beaver操作的通信量吗?

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

No branches or pull requests

2 participants