Add BoxedUint::{from_be_slice_truncated, from_le_slice_truncated}#1266
Merged
Conversation
BoxedUint::{from_be_slice_truncated, from_le_slice_truncated}
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1266 +/- ##
==========================================
+ Coverage 91.33% 91.35% +0.02%
==========================================
Files 189 189
Lines 22480 22534 +54
==========================================
+ Hits 20533 20587 +54
Misses 1947 1947 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
Author
|
I'm going to try to flesh this out more with the trait changes I'd like and see if I can actually use it to implement the full RFC6979. Edit: obviously needs tests as well. |
tarcieri
commented
May 12, 2026
tarcieri
added a commit
to RustCrypto/signatures
that referenced
this pull request
Jun 6, 2026
The changes in #1360 were breaking, so this release bumps the minor version. It might be possible to get some additional breaking changes in as well, if we can land RustCrypto/crypto-bigint#1266.
Merged
tarcieri
added a commit
that referenced
this pull request
Jun 7, 2026
57e17ce to
0fd8484
Compare
BoxedUint::{from_be_slice_truncated, from_le_slice_truncated}BoxedUint::{from_be_slice_truncated, from_le_slice_truncated}
0fd8484 to
d44333a
Compare
Adds infallible constructors for `BoxedUint` that handle the error case for the current `from_be_slice`/`from_le_slice` by truncating the input. My real goal is to be able to add some slice constructors to the `Encoding` trait that can actually provide equivalent semantics between `Uint` and `BoxedUint` and also ensure construction of modulus-sized `BoxedUint`s. A truncating behavior like this eliminates the error case and allows for an infallible constructor. As it were, it's largely mimicking the `bits2int` function described in RFC6979 § 2.3.2 which is what I'd like to implement using `Uint` for ECDSA an `BoxedUint` for DSA. An infallible constructor lets us compose both `from_*e_slice_vartime` and `from_*e_slice` in terms of `from_*e_slice_truncated`, whee the former is also infallible and picks its capacity/precision on-the-fly based on the input data (e.g. we need that to decode the public modulus and figure out what precision we're working with).
d44333a to
ee3baff
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds infallible constructors for
BoxedUintthat handle the error case for the currentfrom_be_slice/from_le_sliceby truncating the input.My real goal is to be able to add some slice constructors to the
Encodingtrait that can actually provide equivalent semantics betweenUintandBoxedUintand also ensure construction of modulus-sizedBoxedUints.A truncating behavior like this eliminates the error case and allows for an infallible constructor. As it were, it's largely mimicking the
bits2intfunction described in RFC6979 § 2.3.2 which is what I'd like to implement usingUintfor ECDSA anBoxedUintfor DSA.An infallible constructor lets us compose both
from_*e_slice_vartimeandfrom_*e_slicein terms offrom_*e_slice_truncated, whee the former is also infallible and picks its capacity/precision on-the-fly based on the input data (e.g. we need that to decode the public modulus and figure out what precision we're working with).