Skip to content

Instantly share code, notes, and snippets.

@jvmncs
Last active December 2, 2018 19:24
Show Gist options
  • Save jvmncs/dba07b2d5769fd76702ef016e5fa074e to your computer and use it in GitHub Desktop.
Save jvmncs/dba07b2d5769fd76702ef016e5fa074e to your computer and use it in GitHub Desktop.
def matmul(prot: Pond,
x: PondMaskedTensor,
y: PondMaskedTensor):
a, a0, a1, alpha_on_0, alpha_on_1 = x.unwrapped
b, b0, b1, beta_on_0, beta_on_1 = y.unwrapped
with tf.device(prot.crypto_producer.device_name):
ab = a.matmul(b)
ab0, ab1 = prot._share(ab)
with tf.device(prot.server_0.device_name):
alpha = alpha_on_0
beta = beta_on_0
z0 = (ab0
+ a0.matmul(beta)
+ alpha.matmul(b0)
+ alpha.matmul(beta))
with tf.device(prot.server_1.device_name):
alpha = alpha_on_1
beta = beta_on_1
z1 = (ab1
+ a1.matmul(beta)
+ alpha.matmul(b1))
return PondPrivateTensor(prot, z0, z1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment