Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shift operation will change a secure negative integer from signed to unsigned #37

Open
zyl2016 opened this issue Sep 13, 2023 · 0 comments

Comments

@zyl2016
Copy link

zyl2016 commented Sep 13, 2023

Hello, sorry for disturbing you.
I have observed that shift operations can be conducted on secure integers successfully on bit-representation. However, it will turn a negative signed integer into an unsigned one.
Here is an example.

Integer a(32, -44, ALICE);
cout<< "a:	"<< a.reveal<int32_t>()<<endl;
a = (a >> 2);
cout<< "a:	"<< a.reveal<int32_t>()<<endl;

The output is:

a:        -44
a:        1073741813

From the view of bit representation, the 11111111 11111111 11111111 11010100 is shifted by 2 bits to 11111111 11111111 11111111 11110101 successfully. However, it is now converted to an unsigned form.
In comparison, if the operation is conducted on a public variable

int a = -44;
cout<< "a:	"<< a<<endl;
a = a >> 2;
cout<< "a:	"<< a<<endl;

The output is:

a:        -44
a:        -11

I am curious whether this is caused by my misuse of shift or if I did not define the type of variable correctly. Or maybe, this behavior is special in the MPC scenario so I should avoid using it. May you help me by explaining this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant