forked from nankaicyber/NKDBsec
Delete 'example/inttest.py'
This commit is contained in:
parent
c4a4bf8ee4
commit
4054350b00
|
@ -1,85 +0,0 @@
|
||||||
import time
|
|
||||||
curt = time.time()
|
|
||||||
import json
|
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
import dbsecmpc
|
|
||||||
from multiprocessing import Process
|
|
||||||
|
|
||||||
|
|
||||||
conf = {
|
|
||||||
"NODE_INFO": [
|
|
||||||
{
|
|
||||||
"HOST": "127.0.0.1",
|
|
||||||
"PORT": 25500,
|
|
||||||
"NODE_ID": "P0"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"HOST": "127.0.0.1",
|
|
||||||
"PORT": 25700,
|
|
||||||
"NODE_ID": "P1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"HOST": "127.0.0.1",
|
|
||||||
"PORT": 25900,
|
|
||||||
"NODE_ID": "P2"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"DATA_NODES": [
|
|
||||||
"P0",
|
|
||||||
"P1",
|
|
||||||
"P2"
|
|
||||||
],
|
|
||||||
"COMPUTATION_NODES": {
|
|
||||||
"P0": 0,
|
|
||||||
"P1": 1,
|
|
||||||
"P2": 2
|
|
||||||
},
|
|
||||||
"RESULT_NODES": [
|
|
||||||
"P0",
|
|
||||||
"P1",
|
|
||||||
"P2"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
def test(id):
|
|
||||||
'''
|
|
||||||
This module aimed to test the secret share I/O
|
|
||||||
'''
|
|
||||||
confbuf = json.dumps(conf)
|
|
||||||
dbsecmpc.init(id, confbuf)
|
|
||||||
|
|
||||||
np.random.seed(199)
|
|
||||||
colnum, rownum = 2, 10
|
|
||||||
|
|
||||||
xplaintable = np.random.randint(100, size = colnum * rownum)
|
|
||||||
xplaintable.shape = (colnum, rownum)
|
|
||||||
print("P0 input: ", xplaintable)
|
|
||||||
rtx = dbsecmpc.privateinput(["P0"], xplaintable)
|
|
||||||
|
|
||||||
np.random.seed(307)
|
|
||||||
yplaintable = np.random.randint(100, size = colnum * rownum)
|
|
||||||
yplaintable.shape = (colnum, rownum)
|
|
||||||
print("P1 input: ", yplaintable)
|
|
||||||
rty = dbsecmpc.privateinput(["P1"], yplaintable)
|
|
||||||
|
|
||||||
res = dbsecmpc.opvector(rtx, rty, dbsecmpc.OP_GREATER)
|
|
||||||
print("P{} secret share: ".format(id), res)
|
|
||||||
|
|
||||||
res = dbsecmpc.reveal(["P2"], res)
|
|
||||||
print("P{} output: ".format(id), res)
|
|
||||||
|
|
||||||
pc1 = Process(target = test, args=(0,))
|
|
||||||
pc2 = Process(target = test, args=(1,))
|
|
||||||
pc3 = Process(target = test, args=(2,))
|
|
||||||
|
|
||||||
|
|
||||||
st = time.time()
|
|
||||||
pc1.start()
|
|
||||||
pc2.start()
|
|
||||||
pc3.start()
|
|
||||||
|
|
||||||
pc1.join()
|
|
||||||
pc2.join()
|
|
||||||
pc3.join()
|
|
||||||
print(time.time() - st)
|
|
Loading…
Reference in New Issue