lschoe / mpyc

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

Question on SecFld did not support '>='. #62

Closed winnnnnny closed 1 year ago

winnnnnny commented 1 year ago

Hello, sorry for disturbing you.

I tried to use comparison on SecFld type and found that only operator supported is '=='. For the other operators, it will return a type error. TypeError: '>=' not supported between instances of 'SecFld34(GF(8589934609))' and 'SecFld34(GF(8589934609))' Sorry for my lack of knowledge on this. I am curious why any other operators like '>=' are not supported. In addition, the documentation mentions that Secure number types ensures that operators such as +,*,>= are defined by operator overloading. So, does it mean SecFld is not a Secure number type?

lschoe commented 1 year ago

Comparisons like < are (currently) not supported for (secure) field elements. To get secure integers with comparisons you can use types created with mpc.SecInt().

Mathematically it does not really make sense to support comparisons like $<$ for finite fields because such an order lacks common properties such as $a\leq b \wedge c\leq d \Rightarrow a+c\leq b+d$. But one can fix an order for the finite field elements anyway, e.g., for a binary field $\mathbb F_{2^n}$ view the elements as nonnegative integers between $0$ and $2^n-1$. This may be useful in some applications, but is not supported yet in MPyC.