Validate Choice wrapper to reject non-boolean values#163
Merged
Conversation
Fix audit finding P1.11-2 (MEDIUM). The Choice wrapper accepted arbitrary u8 values through From<u8>, Serializable::from_bytes, and rkyv CheckBytes, violating the subtle crate's requirement that Choice holds only 0 or 1. - From<u8>: mask input with & 1 (matches subtle::Choice behavior) - Serializable::from_bytes: reject values > 1 with InvalidData error - rkyv CheckBytes: manual impl replacing auto-derived, rejects > 1
Use --all-features --features rkyv/size_32 in clippy and check targets so rkyv compiles without baking size_32 into the crate feature. Fix all clippy warnings in Dusk code: use div_ceil, iterator enumerate, elide needless lifetimes, remove needless borrows, gate test-only import. Add file-level #![allow] for upstream zkcrypto lint warnings that cannot be fixed without modifying upstream code. Fix bare URL doc warnings in design.rs and scalar/dusk.rs.
d2899e1 to
a77a113
Compare
HDauven
approved these changes
Mar 20, 2026
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.
The Choice wrapper accepted arbitrary
u8values throughFrom<u8>,Serializable::from_bytes, andrkyvCheckBytes, violating thesubtlecrate's requirement thatChoiceholds only 0 or 1.From<u8>: mask input with & 1 (matchessubtle::Choicebehavior)Serializable::from_bytes: reject values > 1 withInvalidDataerrorrkyvCheckBytes: manual impl replacing auto-derived, rejects > 1This is a breaking change we the error type in the
Serializabletrait implementation forChoicechanged from rkyv'sInfallabletodusk_bytes::Error.This makes the implementation more in line with other implementations of
Serializable.Also fix clippy, check, and doc make targets and resolve all Dusk lint warnings.