privateml icon indicating copy to clipboard operation
privateml copied to clipboard

In some cases, the algorithm of SPDZ has a little blemishes.

Open Augus753 opened this issue 4 years ago • 0 comments

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

Augus753 avatar Sep 18 '19 14:09 Augus753