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

[EzPC] Strange behavior with shifting operation on secret integer data type #192

Open
winnnnnny opened this issue Sep 4, 2023 · 0 comments

Comments

@winnnnnny
Copy link

Hi, when I use a shifting operation on the secret integer data type, it turns out to be an unexpected behavior. Here is an example.

def void main(){
    uint32_bl var0001 = 98u;
    output(CLIENT, var0001);
    var0001 = ~var0001;
    output(CLIENT, var0001);
    var0001 = var0001 >> 27u;
    output(CLIENT, var0001);

    uint32_pl var0002 = 98u;
    output(CLIENT, var0002);
    var0002 = ~var0002;
    output(CLIENT, var0002);
    var0002 = var0002 >> 27u;
    output(CLIENT, var0002);
}

The output is:

Value of var0002:
98
Value of var0002:
4294967197
Value of var0002:
31
Value of var0001:
98
Value of var0001:
4294967197
Value of var0001:
0

For the public integer variable var0002, it works as expected. In the binary form, it can represented as:
00000000 00000000 00000000 01100010 ->
11111111 11111111 11111111 10011101 ->
00000000 00000000 00000000 00011111, which is finally 31.
However, for the secret integer variable var0001, it goes wrong at the step of shifting. I guess there is some problem with shifting operations on secret integers. I also tried this example on signed integers and arithmetic sharing, which showed the same result. Otherwise, did I use the shifting operation in the wrong way?

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