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

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

protocol = "Helix"
protocol = "SecureNN"
rtt.activate(protocol)
rtt.backend_log_to_stdout(True)
partyid = rtt.get_party_id()

# ##############################
"""
Normal tests (Usages && 28 Cases)
SampleAligned:   test cases (data owner) * (label owner)
     data owner: P0, P1, P2, P0/P1, P0/P2, P1/P2, P0/P1/P2
    label owner: P0, P1, P2
FeatureAligned:  test cases (data owner) == (label owner)
     data owner: P0, P1, P2, P0/P1, P0/P2, P1/P2, P0/P1/P2
    label owner: P0, P1, P2, P0/P1, P0/P2, P1/P2, P0/P1/P2
"""
# ##############################
"""
All normal case - SampleAligned
"""
print("All normal case - SampleAligned")

print("All normal case - SampleAligned - [construct data (X,Y)]")
Esempio n. 2
0
import tensorflow as tf
import sys, os
import numpy as np
np.set_printoptions(suppress=True)
tf.set_random_seed(0)

protocol = "SecureNN"
if "ROSETTA_TEST_PROTOCOL" in os.environ.keys():
    print("***** test_cases use ", os.environ["ROSETTA_TEST_PROTOCOL"])
    protocol = os.environ["ROSETTA_TEST_PROTOCOL"]
else:
    print("***** test_cases use default helix protocol ")
rtt.activate(protocol)

print("rtt.get_protocol_name():", rtt.get_protocol_name())
patyid = rtt.get_party_id("")

###############################
# 1-d
###############################
print('=================1-d=========================')
x = [1, 8, 3]
print(x)

a = tf.Variable(x, dtype=tf.float64)
aa = tf.reduce_mean(a)
a0 = tf.reduce_mean(a, axis=0)

aa_k = tf.reduce_mean(a, keepdims=True)
a0_k = tf.reduce_mean(a, axis=0, keepdims=True)
Esempio n. 3
0
import os
print("PWD:", os.getcwd())

#import unittest

import numpy as np
np.set_printoptions(suppress=True)

import tensorflow as tf

# our package
import latticex.rosetta as cb
#cb.activate("Helix")
cb.activate("SecureNN")

party_ID = cb.get_party_id()
# two initial values with double type.
num_a = np.array([[1, 2], [3, 4]], dtype=np.float_)
num_b = np.array([[10.1, 20.02], [30.003, 40.0004]], dtype=np.float_)

# the precision requirement of saving and restoring a float number
PRECISION = 1.0 / 1000

xa = tf.Variable(num_a, dtype=tf.double)
xb = tf.Variable(num_b, dtype=tf.double)

init_op = tf.compat.v1.global_variables_initializer()

print("========Local init input values================")
with tf.compat.v1.Session() as pre_sess:
    pre_sess.run(init_op)
Esempio n. 4
0
#!/usr/bin/env python3

import latticex.rosetta as rtt
import tensorflow as tf
import sys
import numpy as np

np.set_printoptions(suppress=True)

protocol = "Helix"
rtt.activate(protocol)

patyid = str(rtt.get_party_id())
rtt.set_backend_loglevel(0)
rtt.set_backend_logfile("/tmp/wo-men-dou-shi-hao-hai-zi.log" + patyid)

print("rtt.get_protocol_name():", rtt.get_protocol_name())

X = tf.Variable([[1., 1.], [2., 1.]])
Y = tf.Variable([[1., 3.], [1., 1.]])
z = rtt.SecureMatMul(X, Y)
zr = rtt.SecureReveal(z)

init = tf.global_variables_initializer()
with tf.Session() as sess1:
    sess1.run(init)
    print('zzzzzr:', sess1.run(zr))

rtt.set_backend_loglevel(3)
rtt.set_backend_logfile("/tmp/wo-men-dou-shi-hao-hai-zi-ma.log" + patyid)
Esempio n. 5
0
import os
print("PWD:", os.getcwd())

#import unittest
import json
import numpy as np
np.set_printoptions(suppress=True)

import tensorflow as tf

# our package
import latticex.rosetta as rtt
#rtt.activate("Helix")
rtt.activate("SecureNN")

party_ID = rtt.get_party_id()
# two initial values with double type.
num_a = np.array([[1, 2], [3, 4]], dtype=np.float_)
num_b = np.array([[10.1, 20.02], [30.003, 40.0004]], dtype=np.float_)

# the precision requirement of saving and restoring a float number
PRECISION = 1.0 / 1000

xa = tf.Variable(num_a, dtype=tf.double)
xb = tf.Variable(num_b, dtype=tf.double)

init_op = tf.compat.v1.global_variables_initializer()

print("========Local init input values================")
with tf.compat.v1.Session() as pre_sess:
    pre_sess.run(init_op)