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

Add rot function to bindings #184

Merged
merged 10 commits into from
Oct 26, 2023
Merged

Add rot function to bindings #184

merged 10 commits into from
Oct 26, 2023

Conversation

MartinMinkov
Copy link
Contributor

@MartinMinkov MartinMinkov commented Oct 12, 2023

Summary

This PR exposes the ROT constraint to our JS bindings and adds a rot function for finite fields in the case of constants.

Context

In the context of bitwise operations, 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.

There are two primary types of rotations:

  1. Rotate Left (ROL): In this operation, bits are shifted to the left. The bits that fall off the leftmost side "wrap around" and reappear on the rightmost side.
  2. Rotate Right (ROR): In this operation, bits are shifted to the right. The bits that fall off the rightmost side "wrap around" and reappear on the leftmost side.

Tested

This work is tested in the upper layers of o1js with unit and e2e tests that are built on top of the exposed gate constraint.

🔗 o1js: o1-labs/o1js#1182

Base automatically changed from feature/range-check-64-develop to main October 16, 2023 18:42
… on 64-bit integers

This function allows for the rotation of bits in a 64-bit integer, either to the left or right, by a specified number of bits. This is useful for cryptographic operations that require bit manipulation.
…lect its functionality, as it is not limited to 64 bits
@MartinMinkov MartinMinkov marked this pull request as ready for review October 17, 2023 17:47
@MartinMinkov MartinMinkov changed the title WIP: add rot function to bindings add rot function to bindings Oct 17, 2023
@MartinMinkov MartinMinkov changed the title add rot function to bindings Add rot function to bindings Oct 17, 2023
Copy link
Member

@mitschabaude mitschabaude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pre-approving with the comment above!

… string literal types 'left' | 'right' for better readability and understanding of the code
@MartinMinkov MartinMinkov merged commit 26edbdf into main Oct 26, 2023
1 check passed
@MartinMinkov MartinMinkov deleted the feat/ROT-gadget branch October 26, 2023 17:29
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

Successfully merging this pull request may close these issues.

2 participants