emp-sh2pc icon indicating copy to clipboard operation
emp-sh2pc copied to clipboard

Constructing secret negative integers returns wrong value

Open sebw42 opened this issue 1 year ago • 0 comments

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!

sebw42 avatar Jan 13 '25 07:01 sebw42