encryptogroup / ABY

ABY - A Framework for Efficient Mixed-protocol Secure Two-party Computation
GNU Lesser General Public License v3.0
460 stars 132 forks source link

How to compare two signed number? #169

Closed allensll closed 3 years ago

allensll commented 3 years ago

To my understanding, ABY does not support the signed number directly. Are there some methods to solve Millionaire Problem based on ABY when the number could be negative? Thanks.

dd23 commented 3 years ago

The building blocks that ABY currently offers only work on unsigned numbers.

There are different options for you to solve your problem:

  1. Implemente the circuits that you need for signed numbers. Pull Request are welcome.
  2. If you are only interested in comparison: Shift all input values by half the range to the positive domain. For 8-bit signed values from -127 to +127 for example you can just add +127 to every value and then do an unsigned comparison on values from 0 to 254. This shift can be done by every party locally, before the values are input into the MPC cicuit, so it does not add overhead to the MPC computation.