forked from nankaicyber/NKDBsec
74 lines
1.3 KiB
Python
74 lines
1.3 KiB
Python
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 main(parid):
|
|
np.random.seed(199)
|
|
colnum, rownum = 2, 100000
|
|
lefttable = np.random.rand(colnum * rownum)*(2**10)
|
|
lefttable.shape = (colnum, rownum)
|
|
confbuf = json.dumps(conf)
|
|
|
|
dbsecmpc.init(parid, confbuf)
|
|
s_lefttable = dbsecmpc.privateinput(["P0"], lefttable)
|
|
res = dbsecmpc.opvector(s_lefttable[0], s_lefttable[1], dbsecmpc.OP_GREATER)
|
|
res = dbsecmpc.reveal(["P0"], res)
|
|
print(res)
|
|
|
|
|
|
|
|
pc1 = Process(target=main, args=(0,))
|
|
pc2 = Process(target=main, args=(1,))
|
|
pc3 = Process(target=main, args=(2,))
|
|
|
|
|
|
st = time.time()
|
|
pc1.start()
|
|
pc2.start()
|
|
pc3.start()
|
|
|
|
pc1.join()
|
|
pc2.join()
|
|
pc3.join()
|
|
print(time.time() - st)
|