tf-encrypted / tf-encrypted

A Framework for Encrypted Machine Learning in TensorFlow

Home Page:https://tf-encrypted.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in decryption result after decimal integer secret sharing

ConRresIm opened this issue · comments

commented

I use the pond protocol for secret sharing, but when I decrypt, the result is wrong。The error mainly occurs when the data value are between 100000 and 1000000000。

commented

The error mainly occurs when the data value are between 100000 and 1000000000
image
image

TL;DR With default settings, Pond is only correct for decimals up to 10^8 - 1. Outside of this bound, the protocol fails (but the security guarantee remains). This can be relaxed & configured using the fixedpoint_config parameter.

TFE (and specifically Pond) implements a fixed-point arithmetic to emulate the usual floating point ops common in TensorFlow. This is controlled by the fixedpoint_config parameter provided to the Pond protocol constructor, and its defaults are defined below:

if fixedpoint_config is None:
if tensor_factory is int64factory:
fixedpoint_config = fixed64
elif tensor_factory is int100factory:
fixedpoint_config = fixed100
else:
raise ValueError(
(
"Don't know how to pick fixedpoint configuration "
"for tensor type {}"
).format(tensor_factory)
)
_validate_fixedpoint_config(fixedpoint_config, tensor_factory)
self.fixedpoint_config = fixedpoint_config

On most platforms, the first condition will evaluate to True by default, so we will end up with a fixed point config of fixed64.
That is defined as follows:

fixed64 = FixedpointConfig(
scaling_base=3,
precision_integral=7,
precision_fractional=8,
matmul_threshold=256,
truncation_gap=20,
use_noninteractive_truncation=False,
)

The relevant number in your case is precision_integral=7, which says that this fixed-point config can only represent decimals less than 10^(7+1) - 1. In this case, the decimal will be accurate to 8 decimal places (precision_fractional=8). These numbers (as well as the others) have been chosen to be able to fit into the tf.int64 data type while still maintaining correctness & security.

Closing this since it's not a bug, feel free to follow up with a comment if that's not the case.

commented

image
image

commented

image
image
10^(7+1) - 1>999998

commented

Closing this since it's not a bug, feel free to follow up with a comment if that's not the case.

Closing this since it's not a bug, feel free to follow up with a comment if that's not the case.

there are wrong, for decimals less than or equal to 10 ^ 8-1