ADD file via upload

This commit is contained in:
p87059431 2024-01-20 14:41:42 +08:00
parent 4054350b00
commit 22d2c8f62c
1 changed files with 59 additions and 0 deletions

59
example/dbtest1.py Normal file
View File

@ -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)