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

Convert certain mod(mul(X, Y), A) into mulmod(X, Y, A) #10688

Open
hrkrshnn opened this issue Dec 23, 2020 · 1 comment
Open

Convert certain mod(mul(X, Y), A) into mulmod(X, Y, A) #10688

hrkrshnn opened this issue Dec 23, 2020 · 1 comment

Comments

@hrkrshnn
Copy link
Member

@hrkrshnn hrkrshnn commented Dec 23, 2020

If A is a constant that divides 2**256 (so basically of the form 2**N), then the two expressions should be the same. mod(mul(X, Y), A) costs 10 and mulmod(X, Y, A) costs 8 (excluding the shorter deploy code.)

@hrkrshnn
Copy link
Member Author

@hrkrshnn hrkrshnn commented Dec 23, 2020

May also be worth considering converting mod(add(X, Y), A) into addmod(X, Y, A) where A divides 2**256. Also if we can prove that add(X, Y) does not overflow, then the both expressions would be the same for any A (doesn't have to divide 2**256)

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

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.