Skip to content

Validate Choice wrapper to reject non-boolean values#163

Merged
moCello merged 2 commits intomasterfrom
mocello/choice-validation
Mar 20, 2026
Merged

Validate Choice wrapper to reject non-boolean values#163
moCello merged 2 commits intomasterfrom
mocello/choice-validation

Conversation

@moCello
Copy link
Copy Markdown
Member

@moCello moCello commented Mar 19, 2026

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

This is a breaking change we the error type in the Serializable trait implementation for Choice changed from rkyv's Infallable to dusk_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.

moCello added 2 commits March 19, 2026 14:30
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.
@moCello moCello merged commit 4bbf3fa into master Mar 20, 2026
3 checks passed
@moCello moCello deleted the mocello/choice-validation branch March 20, 2026 12:06
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.

2 participants