-
Notifications
You must be signed in to change notification settings - Fork 22
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
Move canon check from Digest
to BFieldElement
#235
Merged
Merged
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
jan-ferdinand
added
the
⏭️ breaking change
Breaking change, will require an increment of the major version number. E.g: 0.3.0 -> 0.4.0
label
Oct 3, 2024
jan-ferdinand
commented
Oct 3, 2024
Comment on lines
-462
to
+465
let mut buffer = [0u8; 8]; | ||
u.fill_buffer(&mut buffer)?; | ||
let num_leafs = u64::from_be_bytes(buffer) >> 1; // num_leafs can be at most 63 bits | ||
|
||
let mut peaks = vec![]; | ||
for _ in 0..(num_leafs.count_ones()) { | ||
let peak = Digest::arbitrary(u)?; | ||
peaks.push(peak); | ||
} | ||
let num_leafs = u.arbitrary::<u64>()? >> 1; // num_leafs can be at most 63 bits | ||
let peaks = (0..num_leafs.count_ones()) | ||
.map(|_| Digest::arbitrary(u)) | ||
.try_collect()?; |
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.
This piece of code came up when searching for the regex (b|l|n)e_bytes
. The change doesn't really fit the theme of this PR, but I couldn't resist simplifying things.
@Sword-Smith, any opposition? |
Sword-Smith
approved these changes
Oct 7, 2024
- Reject non-canonical `BFieldElement`s when parsing string slices or interpreting byte sequences - Move canon check of `BFieldElement`s from `Digest` to `BFieldElement` - Deprecate functionality for platform-dependent endianness when decoding BREAKING CHANGE: The error variant `NotCanonical` from enum `TryFromDigestError` has moved into enum `ParseBFieldElementError`.
jan-ferdinand
force-pushed
the
bfield_parsing
branch
from
October 7, 2024 09:29
2c355ba
to
7dafa32
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
⏭️ breaking change
Breaking change, will require an increment of the major version number. E.g: 0.3.0 -> 0.4.0
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.
BFieldElement
s when parsing string slices or interpreting byte sequencesBFieldElement
s fromDigest
toBFieldElement
BREAKING CHANGE: The error variant
NotCanonical
from enumTryFromDigestError
has moved into enumParseBFieldElementError
.This was described as the cleaner solution in #199, a sentiment I concur with.
Supersedes #206.