Skip to content

Reject malformed 32-bit constants in AND/XOR and SHA256 compilation [LASuggestion3]#374

Open
rose2221 wants to merge 1 commit intomainfrom
rs/suggestion3
Open

Reject malformed 32-bit constants in AND/XOR and SHA256 compilation [LASuggestion3]#374
rose2221 wants to merge 1 commit intomainfrom
rs/suggestion3

Conversation

@rose2221
Copy link
Copy Markdown
Collaborator

  • Add 32-bit width assertions before as u32 truncation in process_binop_opcode (3 sites) to reject constants exceeding 32 bits at compile time instead of silently truncating
  • Add matching assertion in cow_to_digit in binops.rs for self-contained validation independent of callers
  • Add 32-bit width assertion in sha256_compression.rs for hash value constants used in the optimization path
  • Refactor all assertion sites to bind into_bigint() once and reuse, avoiding redundant Montgomery-to-integer conversions

@Bisht13
Copy link
Copy Markdown
Collaborator

Bisht13 commented Mar 23, 2026

Consider adding a #[test] (e.g. in binops.rs) that constructs a ConstantOrR1CSWitness::Constant with a value exceeding 32 bits and asserts the assertion fires via #[should_panic].

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