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

Implementation of bitwise operations between BigInteger #713

Merged
merged 5 commits into from
Dec 14, 2023

Conversation

hdvanegasm
Copy link
Contributor

@hdvanegasm hdvanegasm commented Dec 13, 2023

Description

I implemented bitwise operations between BigInteger: AND, XOR, NOT, and OR. In the modifications, the trait BigInteger now implements the necessary traits to support the mentioned bitwise operations, and I included the implementations for those operations for the BigInt struct. Also, I wrote some tests for this functionality.

This PR doesn't close any issue. It's just a feature that I found missing in the library.

@hdvanegasm hdvanegasm requested review from a team as code owners December 13, 2023 13:43
@hdvanegasm hdvanegasm requested review from z-tech, Pratyush and mmagician and removed request for a team December 13, 2023 13:43
@mmaker
Copy link
Member

mmaker commented Dec 13, 2023

in the unittests, any chance you could add some checks on the higher limbs (right now you're testing only on the least significant) and de morgan's law ?

hdvanegasm and others added 3 commits December 13, 2023 09:57
It's not clear to me that BigInteger should represent integers mod
2^(N*64), so I'm not ready to take responsability for supporting bitwise
NOT in the API. I'm also not sure bitwise operations like >> and <<
should be treated differently.
Copy link
Member

@mmaker mmaker left a comment

Choose a reason for hiding this comment

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

Looks good to me now! A few notes copy-pasted from my commit message:

  • It's not clear to me that BigInteger should represent integers mod 2^(N*64), so I'm not ready to take responsability for supporting bitwise NOT in the API of BigInteger (it's however in BigInt)

  • I'm also not sure bitwise operations like >> should be treated differently. I think we should add support for Shr in the API and deprecate div2() and divn() perhaps in a different PR?

Can another maintainer can have a look at this?

Copy link
Contributor

@z-tech z-tech left a comment

Choose a reason for hiding this comment

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

These changes look safe to me. Shr and such would be nice (related) features and cleaning up any duplicated capability seems reasonable.

@mmaker mmaker merged commit b7b988f into arkworks-rs:master Dec 14, 2023
45 checks passed
@hdvanegasm hdvanegasm deleted the bitwise-ops branch December 14, 2023 13:59
@z-tech
Copy link
Contributor

z-tech commented Dec 14, 2023

Thanks btw @hdvanegasm!

mmaker added a commit that referenced this pull request Dec 15, 2023
PR #713 introduced underdefined trait constraints for BigInteger and tests
were not really using the `BigInteger` trait.
mmaker added a commit that referenced this pull request Dec 15, 2023
PR #713 introduced underdefined trait constraints for BigInteger and tests
were not really using the `BigInteger` trait.
@mmaker mmaker mentioned this pull request Dec 15, 2023
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.

3 participants