部署所有的protocol对应的.x文件
#MP目录下
make all
要等一会儿,执行完成后查看一下目录下的文件
ls|grep .x
atlas-party.x
bankers-bonus-client.x
bmr-program-party.x
bmr-program-tparty.x
brain-party.x
ccd-party.x
chaigear-party.x
Check-Offline.x
Check-Offline-Z2k.x
cnc-offline.x
cowgear-offline.x
cowgear-party.x
dealer-ring-party.x
emulate.x
ExternalIO
Fake-ECDSA.x
Fake-Offline.x
fake-spdz-ecdsa-party.x
galois-degree.x
gen_input_f2n.x
gen_input_fp.x
hemi-party.x
highgear-party.x
HOSTS.example
License.txt
lowgear-party.x
malicious-ccd-party.x
malicious-rep-bin-party.x
malicious-rep-field-party.x
malicious-rep-ring-party.x
malicious-shamir-party.x
mal-rep-bmr-party.x
mal-rep-ecdsa-party.x
mal-shamir-bmr-party.x
mal-shamir-ecdsa-party.x
mal-shamir-offline.x
mama-party.x
mascot-ecdsa-party.x
mascot-offline.x
mascot-party.x
ot-offline.x
ot.x
pairwise-offline.x
Player-Online.x
ps-rep-bin-party.x
ps-rep-field-party.x
ps-rep-ring-party.x
real-bmr-party.x
rep4-ring-party.x
rep-bmr-party.x
rep-ecdsa-party.x
replicated-bin-party.x
replicated-field-party.x
replicated-ring-party.x
semi2k-party.x
semi-bin-party.x
semi-bmr-party.x
semi-ecdsa-party.x
semi-party.x
Server.x
shamir-bmr-party.x
shamir-ecdsa-party.x
shamir-party.x
simple-offline.x
soho-party.x
spdz2k-party.x
spdz2-offline.x
sy-rep-field-party.x
sy-rep-ring-party.x
sy-shamir-party.x
temi-party.x
tinier-party.x
tiny-party.x
yao-party.x
手动创建脚本
vim Programs/Source/testgp.mpc
写入内容:
//c语言
a = sint.get_input_from(0)
b = sint.get_input_from(1)
c = sint.get_input_from(2)
sum = a + b + c
print_ln('Results =%s',sum.reveal())
编译脚本
./compile.py -B 32 testgp
Default bit length: 32
Default security parameter: 40
Compiling file /home/yevhen/下载/MP-SPDZ-v0.3.2/Programs/Source/testgp.mpc
Writing to /home/yevhen/下载/MP-SPDZ-v0.3.2/Programs/Schedules/testgp.sch
Writing to /home/yevhen/下载/MP-SPDZ-v0.3.2/Programs/Bytecode/testgp-0.bc
Program requires at most:
32 bit inputs from player 0
32 bit inputs from player 1
32 bit inputs from player 2
198 bit triples
78 virtual machine rounds
生成三方RSA私钥
因为要模拟三方,所以要生成证书
Scripts/setup-ssl.sh 3
Setting up SSL for 3 parties
.+......+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.+.......+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*...........+..+...+.+......+..............+.+............+..+.+..+..........+...+........+......+....+..+....+.....................+..+...+.......+.....+......+................+.....+...+...+.......+...+........+....+...+.....+.......+..+....+..+.......+...+..............+.........+.+........+...+..........+.........+...........+.......+.....+.......+...+.....+......+....+...........+..........+.....+.........+.+.....+....+..+.........+......+......+...+....+..+.+..+..........+......+........................+......+......+...............+.....+......+.......+..+.............+...+...+..+..................+.+...+...+........+....+..+.........+......+.+..+......+.+...+...+..............+.+..............+.+...+..............+...+..........+..+.+..+...+....+............+........+.+.........+........+.........+.+...+..+.........+.+...+.........+...............+.....+.+......+......+...+...........+.+..+.+..+...+....+.....+..........+..+....+..............+...+....+..............+.........+.+......+......+...........................+..+.+..+..................+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
..+..+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*..+............+....+...+..+.............+............+......+..+.+...........+.+............+........+...+.....................+...............+....+......+......+..+.+..+...+....+......+.....+..........+...........+...+.............+........+....+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-----
..................+.+..+......+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*..+........+...+....+..+.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*...+...+.......+...........+.........+.+..+......+.......+..+...+..........+........+....+...........+....+......+..+.........+....+.....+.+........+...+...+.+....................+.+..+......+.+........+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
......+......+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*........+......+...............+.+..+.+..+...+....+........+.........+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.+...............+..+.......+...............+...+.....+.+..+.......+......+...........+.+..+...+...+....+..+......+.......+......+.................+....+...+..+..........+...+.....+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-----
.......+..+.+..+.+.........+..+.........+..........+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*...+...+.....+.............+..+.......+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*......................+...+............+.+.....+....+......+.........+..+.+...+..............+.+.....+....+..+.........+.+...........+..........+.....+............+...+.......+.....+.+..+....+...+..+...+.......+......+.....+....+...........+...+.+......+........+............+.............+..............+......+......+.+...+........................+.....+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
..+...+..+......+.......+......+......+...........+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.+...+.........+...........+......+...+.+..+.......+...+..+...+.........+.+.....+...+....+.....+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*......+......+............+.........+.........+...............+..+.......+.................+.+.....+.............+..+.........+....+.....+....+........+.......+..+.........+......+...+......+....+..+..........+.....................+..+.......+...+......+..+....+........+.+............+...............+..+......+.+......+............+..+....+...........+....+..............+......+....+.....+.+..+...+..........+......+......+..+.......+...........+...+.+...+..+....+............+..+.......+...........+...+.+...+......+............+.........+......+........+......+.+........+..........+..+...+.........+.......+........+..........+......+.....+.+......+..............+.+....................+....+.........+.....+......+.+...+..+....+..................+.................+....+............+.....+....+.....+..........+..............+......+....+..+.........+...+...+....+...+......+.....+...............+........................+............+.+...+.....+..........+..+.............+.........+...+..............+....+.....+......+....+.....+.+.....+......+.......+...+...+.....+.........+...+....+...+............+...+...........................+.........+..+....+...........+..........+...+..+.......+..+...+...+............+.......+...........+...+.+...+......+...............+.........+..+...............+....+..+...+....+......+......+...........+....+......+..+...+....+......+..+......+.+...........+.......+...+..+.......+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-----
Doing Player-Data
写入三方数据
echo 11 > Player-Data/Input-P0-0
echo 12 > Player-Data/Input-P1-0
echo 13 > Player-Data/Input-P2-0
执行模拟程序
使用同一台虚拟机,打开三个终端
分别模拟三个节点输入:
./shamir-bmr-party.x -N 3 0 testgp
./shamir-bmr-party.x -N 3 1 testgp
./shamir-bmr-party.x -N 3 2 testgp
三个节点同时输出
Using security parameter 40
Result = 36
Significant amount of unused bits of Shamir gf2n_long. For more accurate benchmarks, consider reducing the batch size with -b.
Data sent = 0.572128 MB
Time = 0.0160544 seconds