-
Notifications
You must be signed in to change notification settings - Fork 133
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
Add rot gadget to o1js #1182
Merged
Merged
Add rot gadget to o1js #1182
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MartinMinkov
changed the base branch from
main
to
feature/range-check-64-develop
October 12, 2023 21:55
MartinMinkov
changed the title
WIP: add rot function to o1js
WIP: add rot gadget to o1js
Oct 12, 2023
This commit introduces a new function 'rot' in rot.ts file which performs bitwise rotation on a given word. It supports both left and right rotation modes. The function also includes a check for the number of bits to be rotated, ensuring it is within the range of 0 to 64. The rotation function is designed to work with both constant and provable words.
…> for limbs and crumbs
…ative field elements
…ess, shifted, bound values for readability
…method to improve usability This change allows users to call the rot method without specifying the bits parameter, which will default to 64 for Field class, UInt64.NUM_BITS for UInt64 class, and UInt32.NUM_BITS for UInt32 class.
- Update the example output to match the correct result of the operation - Change the direction parameter description from boolean to 'left' or 'right' string values for better readability and understanding of the function usage
…eration to provide more clarity on its functionality
… unnecessary witness calls
Re-reviewed, only thing left from my side is #1182 (comment) |
All good on my side |
…lude 0 and MAX_BITS" This reverts commit 142e30f.
…ove performance The checkMaxBits function was previously used to ensure that the input is at most 64 bits. However, this check is no longer necessary as the input size is now guaranteed by the type system.
…es to reflect recent changes
…mat of other entries for consistency
- Change single line comment to JSDoc style for better IDE support - Add parameter descriptions for better understanding - Improve wording and formatting for better readability - Add @throws tag to highlight error conditions - Update example code to match new parameter descriptions
…ts to a separate file
mitschabaude
approved these changes
Oct 26, 2023
…test.ts to bitwise.unit-test.ts
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds the implementation for a
ROT
gate to the existingGadgets
namespace. For context of what a bitwise rotation is, a rotation (often referred to as a "bitwise rotation") is an operation that shifts the bits of a binary number either to the left or to the right, but unlike a standard shift operation, the bits that "fall off" the end are not discarded. Instead, they "wrap around" to the other end.The implementation is based on the original OCaml implementation which is specified here
In our
ROT
implementation, we handle the constant case by using the added functionality in the bindings, and for the prover case, we specify the implementation in this PR.Note: The
rotate
function that is specified for theROT
gate will also be used for the upcoming shift gates.Tested
This PR adds e2e tests, unit tests, and verification key tests for the ROT gate.
🔗 bindings: o1-labs/o1js-bindings#184