privateml
privateml copied to clipboard
In some cases, the algorithm of SPDZ has a little blemishes.
Hello. I am running the spdz/Basic SPDZ.ipynb code. When I modified the test data, I was getting this error.
The following code is the test case that you gave. I changed the w to 6497992661811505122. In fact, this will trigger mod operation and causing the result of PublicElement is not equal to v+w.
Correspondingly, some operate has similar problems with triggering mod Q operation.
# test case
v = 5
w =6497992661811505122
for x_type in [PublicElement, PrivateElement]:
for y_type in [PublicElement, PrivateElement]:
x = x_type(v)
y = y_type(w)
print('unwrap:%d---------(v + w):%d' % (z.unwrap(), v + w))
z = x + y; assert z.unwrap() == v + w
z = x - y; assert z.unwrap() == v - w
z = x * y; assert z.unwrap() == v * w
z = x.square(); assert z.unwrap() == v * v
# log
unwrap:4---------(v + w):6497992661811505127
File "privateml/spdz/aa.py", line 196, in <module>
assert z.unwrap() == v + w
AssertionError