From 22d2c8f62ca6ba4076f8a67eb3975da8d7e356c7 Mon Sep 17 00:00:00 2001 From: p87059431 Date: Sat, 20 Jan 2024 14:41:42 +0800 Subject: [PATCH] ADD file via upload --- example/dbtest1.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 example/dbtest1.py diff --git a/example/dbtest1.py b/example/dbtest1.py new file mode 100644 index 0000000..ac36d1f --- /dev/null +++ b/example/dbtest1.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(0)