Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleFL
提交
e1123103
P
PaddleFL
项目概览
PaddlePaddle
/
PaddleFL
通知
35
Star
5
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
6
列表
看板
标记
里程碑
合并请求
4
Wiki
3
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleFL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
6
Issue
6
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
3
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e1123103
编写于
8月 26, 2020
作者:
Y
yangqingyou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed abstract_context bug
上级
b8d8ee2b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
20 addition
and
17 deletion
+20
-17
core/paddlefl_mpc/mpc_protocol/abstract_context.h
core/paddlefl_mpc/mpc_protocol/abstract_context.h
+20
-17
未找到文件。
core/paddlefl_mpc/mpc_protocol/abstract_context.h
浏览文件 @
e1123103
...
...
@@ -65,9 +65,17 @@ public:
size_t
party
()
const
{
return
_party
;
}
size_t
pre_party
()
const
{
return
(
_party
+
_num_party
-
1
)
%
_num_party
;
}
size_t
pre_party
()
const
{
PADDLE_ENFORCE_EQ
(
_num_party
==
2
||
_num_party
==
3
,
true
,
"number of party is not set."
);
return
(
_party
+
_num_party
-
1
)
%
_num_party
;
}
size_t
next_party
()
const
{
return
(
_party
+
1
)
%
_num_party
;
}
size_t
next_party
()
const
{
PADDLE_ENFORCE_EQ
(
_num_party
==
2
||
_num_party
==
3
,
true
,
"number of party is not set."
);
return
(
_party
+
1
)
%
_num_party
;
}
template
<
typename
T
>
T
gen_random
(
bool
next
)
{
return
_prng
[
next
].
get
<
T
>
();
}
...
...
@@ -120,13 +128,11 @@ public:
[
this
](
T
&
val
)
{
val
=
this
->
template
gen_zero_sharing_boolean
<
T
>();
});
}
template
<
typename
T
,
template
<
typename
>
class
Tensor
>
template
<
typename
T
,
template
<
typename
>
class
Tensor
>
void
ot
(
size_t
sender
,
size_t
receiver
,
size_t
helper
,
const
Tensor
<
T
>
*
choice
,
const
Tensor
<
T
>
*
m
[
2
],
Tensor
<
T
>
*
buffer
[
2
],
Tensor
<
T
>
*
ret
)
{
const
Tensor
<
T
>
*
choice
,
const
Tensor
<
T
>*
m
[
2
],
Tensor
<
T
>
*
buffer
[
2
],
Tensor
<
T
>*
ret
)
{
// TODO: check tensor shape equals
PADDLE_ENFORCE_EQ
(
_num_party
,
3
,
"`ot` API is for 3 party protocol."
);
const
size_t
numel
=
buffer
[
0
]
->
numel
();
if
(
party
()
==
sender
)
{
bool
common
=
helper
==
next_party
();
...
...
@@ -146,9 +152,8 @@ public:
this
->
template
gen_random
(
*
buffer
[
1
],
common
);
for
(
size_t
i
=
0
;
i
<
numel
;
++
i
)
{
// TODO: check if choice is one bit
buffer
[
0
]
->
data
()[
i
]
=
choice
->
data
()[
i
]
?
buffer
[
1
]
->
data
()[
i
]
:
buffer
[
0
]
->
data
()[
i
];
buffer
[
0
]
->
data
()[
i
]
=
choice
->
data
()[
i
]
&
1
?
buffer
[
1
]
->
data
()[
i
]
:
buffer
[
0
]
->
data
()[
i
];
}
network
()
->
template
send
(
receiver
,
*
buffer
[
0
]);
}
else
if
(
party
()
==
receiver
)
{
...
...
@@ -156,13 +161,11 @@ public:
network
()
->
template
recv
(
sender
,
*
buffer
[
1
]);
network
()
->
template
recv
(
helper
,
*
ret
);
size_t
i
=
0
;
std
::
for_each
(
ret
->
data
(),
ret
->
data
()
+
numel
,
[
&
buffer
,
&
i
,
choice
,
ret
](
T
&
in
)
{
// TODO: check if choice is one bit
bool
c
=
choice
->
data
()[
i
];
in
^=
buffer
[
c
]
->
data
()[
i
];
++
i
;
});
std
::
for_each
(
ret
->
data
(),
ret
->
data
()
+
numel
,
[
&
buffer
,
&
i
,
choice
,
ret
](
T
&
in
)
{
bool
c
=
choice
->
data
()[
i
]
&
1
;
in
^=
buffer
[
c
]
->
data
()[
i
];
++
i
;}
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录