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 after using combination of multiplication and bitwise negation #194

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

Comments

@winnnnnny
Copy link

Hi, when I use a combination of multiplication and bitwise Negationm, the following output function will not work correctly.
Here is an example.

def void main(){
    uint32_bl a = 32u;
    uint32_bl b = 31u;
    output(CLIENT, b);
    uint32_bl c = (~ (b * 73u)); (*The statement that triggers output error*)
    output(CLIENT, c); (*The output shows a random number*)
    output(CLIENT, a); (*The output shows a random number*)
    output(CLIENT, b); (*The output shows b + 1, however, no mutation of b should happen*)
    output(CLIENT, b); (*The output now works correctly*)
}

The output is shown below.

Value of b:
31
Value of c:
3258983666
Value of a:
1035981765
Value of b:
32
Value of b:
31

It seems that this problem is triggered by a specific combination of operations. If a combination of addition and bitwise negation is applied, there will be no unexpected behavior. Could 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

2 participants
@winnnnnny and others