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(2)