项目作者: tf-encrypted

项目描述 :
Bridge between TensorFlow and Google's Private Join and Compute library
高级语言: Python
项目地址: git://github.com/tf-encrypted/tf-pjc.git
创建时间: 2019-08-08T16:07:35Z
项目社区:https://github.com/tf-encrypted/tf-pjc

开源协议:Apache License 2.0

下载


TF PJC

TF PJC provides a bridge between TensorFlow and Google’s Private Join and Compute library. This allows two parties to privately compute the intersection of two sets and the sum of associated values as described in IKNP+’19.

Usage

The library may be used as shown in the following example:

  1. import tensorflow as tf
  2. import tf_pjc
  3. # device strings of the two players involved
  4. client_device = "/job:localhost/task:0/device:CPU:0"
  5. server_device = "/job:localhost/task:1/device:CPU:0"
  6. # construct private input of server
  7. with tf.device(server_device):
  8. server_elements = tf.constant(["a", "b", "c"])
  9. # construct private inputs of client
  10. with tf.device(client_device):
  11. client_elements = tf.constant(["a", "b", "c", "d"])
  12. client_values = tf.constant([100, 200, 400, 800])
  13. # use protocol to securely compute intersection size and sum
  14. protocol_instance = tf_pjc.PrivateIntersectionSum(client_device, server_device)
  15. client_result_op, server_wait_op = protocol_instance(client_elements, client_values, server_elements)
  16. # print private result (which is local to the client)
  17. with tf.device(client_device):
  18. intersection_size, intersection_sum = client_result_op
  19. print_size_op = tf.print("Intersection size: ", intersection_size)
  20. print_sum_op = tf.print("Intersection sum: ", intersection_sum)
  21. print_op = tf.group(print_size_op, print_sum_op)
  22. # run in TensorFlow session
  23. with tf.Session() as sess:
  24. sess.run([print_op, server_wait_op])

Future releases will also include the possibility of using TF PJC in conjunction with TF Encrypted as a kernel for tfe.sets.intersection_sum.

Installation

Python 3 packages are available from PyPI:

  1. pip install tf-pjc