Open Poppy22 opened 8 months ago
There is no way to do comparison using arithmetic secret sharing from my understanding. It must be already being converted to binary, if it works with arithmetic secret sharing.
There is no way to do comparison using arithmetic secret sharing from my understanding. It must be already being converted to binary, if it works with arithmetic secret sharing.
Hello
In paper crypten crypten, that say:
we can produce [x < y] by computing their difference [z]= [x]-[y] and comparing result to zero: [z <0]. We compute [z <0] by first converting [z] to a binary secret-share
, computing its sign bit, and converting the resulting bit to an arithmetic sharing [b].
I observe functions gt
, ge
, le
in MPC/primitives. So, how should we call functions when we need to compare two numbers.
Thank you!
If you use a comparison operator for arithmetic secret sharing (e.g., a < b?), it internally subtracts the value and compare it with zero (a - b < 0?), which involves arithmetic operation (a-b), and then comparison. It first does the arithmetic operation and then convert to binary secret sharing, and perform comparison with zero, and convert the result back to arithmetic secret sharing.
So, to answer your question:
If you use a comparison operator for arithmetic secret sharing (e.g., a < b?), it internally subtracts the value and compare it with zero (a - b < 0?), which involves arithmetic operation (a-b), and then comparison. It first does the arithmetic operation and then convert to binary secret sharing, and perform comparison with zero, and convert the result back to arithmetic secret sharing.
So, to answer your question:
- You should compare two numbers in an arithmetic secret shared format, not binary. CrypTen internally converts it to binary when needed.
I got it. Thank you!
Hello,
From what I understood, binary secret sharing should be used for logical operations, such as comparisons, as this would be faster.
Given the code below, which simply compares two numbers
x
andy
using both binary secret sharing, I receive an error:The error is:
AttributeError: 'BinarySharedTensor' object has no attribute 'sub'
How should binary secret sharing be used for comparisons? It seems that only arithmetic secret sharing is working. What am I missing?