lschoe / mpyc

MPyC: Multiparty Computation in Python
MIT License
367 stars 76 forks source link

SecFlt's output bug #83

Closed ZhangHaoTian007 closed 7 months ago

ZhangHaoTian007 commented 7 months ago

In the output method of runtime.py, the output of SecFlt uses the SecureFloat._output method. However, the SecureFloat._output method recursively calls the output method in runtime.py. This can lead to issues where, if the current node is not in the receivers, x_s and x_e become None, resulting in assertion errors and errors in the return values in the SecureFloat._output method.

I hope to find a solution for this issue. If my understanding is incorrect, please let me know.

lschoe commented 7 months ago

There should be no problem here. The calls to the _output() method in the _output() method of SecureFloat are for the significand and the exponent, which are a SecureFixedPoint and a SecureInteger, respectively.

ZhangHaoTian007 commented 7 months ago

There should be no problem here. The calls to the _output() method in the _output() method of SecureFloat are for the significand and the exponent, which are a SecureFixedPoint and a SecureInteger, respectively.

But if the node performing the output is not in the set of receivers, then the _output method inside it, which calls the output method in runtime.py to retrieve the significand and exponent, will return None. As a result, the assertions and return values cannot handle None.

I noticed that while mpyc provides senders and receivers parameters in both input and output, there doesn't seem to be a demo for scenarios where each party has different inputs and outputs.

lschoe commented 7 months ago

Yes, now I see. Good catch, thx! I've fixed the SecureFloat._output() method to handle this case. It gets a bit involved because we want to hide from the parties who are not receivers when the significand s happens to be 0 . If the significand s is 0, we set the exponent e to 0 as well, to prevent information leaking from e.

lschoe commented 7 months ago

I noticed that while mpyc provides senders and receivers parameters in both input and output, there doesn't seem to be a demo for scenarios where each party has different inputs and outputs.

Did you see the Oblivious Transfer demo mpyc/demos/ot.py? That demo has private inputs and private outputs for the parties in the OT protocol.