Skip to content

Fix SHA256 word range checks and U32ADD carry constraints#3021

Open
huitseeker wants to merge 3 commits intonextfrom
huitseeker/tob3
Open

Fix SHA256 word range checks and U32ADD carry constraints#3021
huitseeker wants to merge 3 commits intonextfrom
huitseeker/tob3

Conversation

@huitseeker
Copy link
Copy Markdown
Collaborator

This PR fixes TOB-MIDENCORE-4 and TOB-MIDENCORE-9.

The SHA256 fix checks that all message words are valid u32 values before they are used by the SHA256 schedule. This covers hash, merge, and hash_bytes, including words loaded from memory.

The U32ADD fix enforces that the high carry helper limb h3 is zero for U32ADD and U32ADD3. This prevents forged carry outputs such as 65536, including the carry path used by u64::overflowing_add.

The verifier artifacts and relation digest constants were updated to match the new AIR. This includes the RELATION_DIGEST constants in Rust and MASM, the AIR snapshot, and the generated recursive verifier constraint program.

Tests were added for rejected SHA256 non-u32 message words, forged U32ADD and U32ADD3 carries, and the u64::overflowing_add carry propagation case.

@huitseeker huitseeker changed the title Huitseeker/tob3 Fix SHA256 word range checks and U32ADD carry constraints Apr 20, 2026
@huitseeker huitseeker marked this pull request as ready for review April 20, 2026 06:52
Copy link
Copy Markdown
Contributor

@Al-Kindi-0 Al-Kindi-0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

Comment on lines +124 to +127
$$
h_3 = 0 \text{ | degree} = 1
$$

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very strange, my memory tells me that we had these constraints in the docs. Maybe in some of the local work I was doing on tagging design docs, but not sure.

@huitseeker huitseeker requested a review from bobbinth April 21, 2026 14:07
@huitseeker huitseeker force-pushed the huitseeker/tob3 branch 2 times, most recently from a3c870b to 6c77566 Compare April 22, 2026 11:50
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