-
Notifications
You must be signed in to change notification settings - Fork 256
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 to_bytes to bigint #166
Merged
+57
−12
Merged
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
774aa1c
Add to_bytes to bigint
ValarDragon d20c4b6
Fix lint + changelog
ValarDragon 1a25434
Fix comments
ValarDragon 56bd59e
Update to_bits per pratyush's suggestion
ValarDragon dc422ab
Switch to *_be, *_le API
ValarDragon 902e51d
Fix lint
ValarDragon dfd26c6
Update ff/src/biginteger/macros.rs
ValarDragon f7b87cb
move to_bits to default impl
ValarDragon 84f2c6b
Merge branch 'bigint_to_bytes' of github.com:arkworks-rs/algebra into…
ValarDragon 2926b91
Fix ec usage of to_bits
ValarDragon 2237bb9
Apply suggestion
ValarDragon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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.
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.
I think these can all be made default impls on the trait itself? For the bits, you can call
BitIteratorXX::new(self)...
, andto_bytes_be
is implemented directly in terms ofto_bytes_le
.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.
True, ok I'll do that
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.
I didn't realize the trait had
AsRef<[u64]>
, seems kind of word to be in the trait imo. Why would we not allow float back ends?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.
Actually I think its weird to only implement one of
to_bytes_le
andto_bytes_be
as the default, I'd prefer it in the macro. (The reason to put it in the default impl would be for users implementing these in an alternate fashion, but that then assumes thatto_bytes_le
is the native endianness to do it)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.
Actually I think we can move
to_bytes_le
also to the trait, as it can be implemented fromAsRef<[u64]>
.(This is an example of why the
AsRef<[u64]>
trait bound is useful)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.
I'll move it for now, but I think its worth revisiting if BigInt needs AsRef<[u64]>, I feel like we shouldn't make PrimeField / elliptic curves depend on that. (Agreed that its fine for the prime field generation macro though)
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.
We lose capacity hints with the
to_bytes
being a default implementation, not really sure its worth making it default then?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.
Ah no, I was wrong. The capacity hints are still available