-
Notifications
You must be signed in to change notification settings - Fork 435
optimize paddingFixedWidth of sha3 using divmod hint #1450
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
base: master
Are you sure you want to change the base?
Conversation
Thanks for the PR. I'll review it soon. |
if d.minimalLength > 0 { | ||
comparator.AssertIsLessEq(d.minimalLength, length) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the constraint comparator.AssertIsLessEq(length, maxLen)
should be added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constraint comparator.AssertIsLessEq(length, maxLen)
should be added to prevent the wrong value from being returned when length>maxLen.
@@ -109,7 +115,7 @@ func (d *digest) FixedLengthSum(length frontend.Variable) []uints.U8 { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the constraint comparator.AssertIsLessEq(length, maxLen)
should be added
Description
In this PR, a divmod function is implemented with hint, and it is used to optimize the paddingFixedWidth of sha3 to reduce the number of selects in the process of padding data and calculating numberOfBlocks.
In the project we are currently working on, one of the data lengths to be keccak256 hashed ranges from 1130 to 1710. Using the new FixedLengthSum can reduce about 50,000 constraints, as shown below:
Type of change
How has this been tested?
How has this been benchmarked?
Checklist:
golangci-lint
does not output errors locally