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

Refactor UInt{8,16,64,128} into one struct UInt #121

Merged
merged 32 commits into from
Jan 3, 2024
Merged

Conversation

Pratyush
Copy link
Member

@Pratyush Pratyush commented May 10, 2023

Description

closes: #116


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (master)
  • Linked to Github issue with discussion and accepted design OR have an explanation in the PR that describes this work.
  • Wrote unit tests
  • Updated relevant documentation in the code
  • Added a relevant changelog entry to the Pending section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

Copy link
Member

@mmagician mmagician 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 so far.
I wonder whether we could completely get rid of uint8 module?
To preserve+ the functionality, it would require the UInt<const N: usize, T: PrimInt + Debug, F: Field> struct to implement new_input_vec, which would in turn require an extra trait bound T: ToConstraintField. These seem like natural things to have for u16 etc. anyway.

This could easily be a follow-up PR though, but if you agree then let's open an issue for tracking.

@Pratyush
Copy link
Member Author

Unfortunately I think there's a special impl of ToConstraintField for [u8]s that's used in the new_input_vec impl. Generalizing it to support larger sizes shouldn't be difficult, but would require moving away from calling ToConstraintField. Maybe that's fine though.

@mmagician
Copy link
Member

Rather than generalizing we could just implement ToConstraintField for &[u16] etc no?

src/bits/uint/mod.rs Outdated Show resolved Hide resolved
@Pratyush Pratyush requested a review from a team as a code owner December 28, 2023 18:37
@Pratyush Pratyush requested review from z-tech and removed request for a team December 28, 2023 18:37
@Pratyush Pratyush added this pull request to the merge queue Jan 3, 2024
@Pratyush Pratyush removed this pull request from the merge queue due to a manual request Jan 3, 2024
@Pratyush Pratyush added this pull request to the merge queue Jan 3, 2024
@Pratyush Pratyush removed this pull request from the merge queue due to the queue being cleared Jan 3, 2024
@Pratyush Pratyush merged commit d011859 into master Jan 3, 2024
5 of 11 checks passed
@Pratyush Pratyush deleted the refactor-uints branch January 3, 2024 13:23
@autquis
Copy link

autquis commented Jan 3, 2024

@Pratyush After moving ToBytesGadget to convert, it is no longer part of prelude. Is it intended?
I'm fixing crypto-primitive for this change. For example, in:
https://github.com/arkworks-rs/crypto-primitives/blob/8bbb4824ede5f2cf115f1a37e08410b57944a4f6/src/signature/constraints.rs#L10

It was previously enough to use ark-r1cs-std::prelude::* but now I need either use it explicitly or update the prelude.

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.

5 participants