From e6d52d2b7763b9a49e139ac50826447dda1a8da2 Mon Sep 17 00:00:00 2001 From: p87059431 Date: Sat, 20 Jan 2024 14:42:06 +0800 Subject: [PATCH] ADD file via upload --- example/dbtest2.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 example/dbtest2.py diff --git a/example/dbtest2.py b/example/dbtest2.py new file mode 100644 index 0000000..2baec92 --- /dev/null +++ b/example/dbtest2.py @@ -0,0 +1,59 @@ +import time +curt = time.time() +import json +import numpy as np + +import dbsecmpc + + +# conf写法参考Rosetta的CONFIG.json文件 +conf = { + "NODE_INFO": [ + { + "HOST": "10.10.160.2", + "PORT": 44122, + "NODE_ID": "P0" + }, + { + "HOST": "10.10.160.3", + "PORT": 42143, + "NODE_ID": "P1" + }, + { + "HOST": "10.10.160.4", + "PORT": 53169, + "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_ADD) + res = dbsecmpc.reveal(["P0"], res) + print(res) + + +if __name__ == '__main__': + main(1)