emp-sh2pc
emp-sh2pc copied to clipboard
Constructing secret negative integers returns wrong value
Hi, I've noticed that constructing secret negative integers does not work as expected when the bit length is below 32. Here is an example:
void fun(){
Integer y = Integer(32, -1, ALICE);
cout << y.reveal<int>() << endl; // prints -1
Integer x = Integer(16, -1, ALICE);
cout << x.reveal<int>() << endl; // prints 65535
}
int main(int argc, char** argv) {
int port, party;
parse_party_and_port(argv, &party, &port);
NetIO * io = new NetIO(party==ALICE ? nullptr : "127.0.0.1", port);
setup_semi_honest(io, party);
fun();
delete io;
}
With 16 bits, the result is (2^16) - 1.
Are bit lengths below 32 not supported?
Thank you for looking into this!