Esempio n. 1
0
#!/usr/bin/env python3

# Import rosetta package
import latticex.rosetta as rtt
import tensorflow as tf

# You can activate a backend protocol, here use SecureNN
rtt.set_backend_loglevel(0)
rtt.activate("Helix")
#rtt.py_protocol_handler.set_loglevel(0)
print('node party', rtt.get_current_node_id(),
      rtt.node_id_to_party_id(rtt.get_current_node_id()))
print('party node', rtt.get_current_party_id(),
      rtt.party_id_to_node_id(rtt.get_current_party_id()))
print('data nodes', rtt.get_data_node_ids())
print('computation nodes', rtt.get_computation_node_ids())
print('result nodes', rtt.get_result_node_ids())
nodes = rtt.get_connected_node_ids()
node = rtt.get_current_node_id()
msgid = 'test'
for n in nodes:
    if n != node:
        rtt.send_msg(n, msgid, node + " to " + n)
for n in nodes:
    if n != node:
        msg = rtt.recv_msg(n, msgid, 2 * len(node) + 4)
        print('get msg from ', n, " msg:", msg)

# Get private data from Alice (input x), Bob (input y)
w = tf.Variable(rtt.private_input(0, [[1, 2], [2, 3]]))
x = tf.Variable(rtt.private_input(1, [[1, 2], [2, 3]]))
Esempio n. 2
0
#!/usr/bin/python

import latticex.rosetta as rst

import tensorflow as tf
import sys
import numpy as np
np.set_printoptions(suppress=True)

# rst.set_backend_loglevel(1)
# rst.backend_log_to_stdout(True)

rst.activate("SecureNN")
rst.set_backend_loglevel(1)
rst.backend_log_to_stdout(True)
# rst.set_backend_logfile("log/addn.{}".format(rst.get_party_id()))
xa = tf.Variable(
    rst.private_input(
        0, [[-102.12345678], [-0.12345678], [0.234567890], [0.34567890]]))
# xa = tf.Variable(0,
#     [
#         [-102.12345678],
#         [-0.12345678],
#         [0.234567890],
#         [0.34567890]
#     ]
# )
# xb = tf.Variable([[1],[2],[2],[1]])

# print("xa:\n", xa)