Skip to content

fix: Add constraint to SHA extension that checks if the appended length is a multiple of 8 #1400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2025

Conversation

Avaneesh-axiom
Copy link
Contributor

@Avaneesh-axiom Avaneesh-axiom commented Mar 10, 2025

We have a bug where the message length (in bits) that is appended to the message as part of the SHA-256 padding algorithm is not constrained to be a multiple of 8 (and hence being a length in bytes) but rather to be a multiple of 4 here. But we assume that it is a multiple of 8 in another constraint here.

The fix is to correctly constrain that the appended length is a multiple of 8. Since the length is stored in little endian, we check that it's first three bits are zero.

Closes INT-3600

Copy link

group app.proof_time_ms app.cycles app.cells_used leaf.proof_time_ms leaf.cycles leaf.cells_used
verify_fibair (-55 [-3.8%]) 1,393 147,020 8,194,664 - - -
fibonacci_program (+40 [+0.8%]) 5,032 1,500,096 51,485,167 - - -
regex_program (-31 [-0.2%]) 13,982 4,140,164 167,389,450 - - -
ecrecover_program (+10 [+0.4%]) 2,519 295,181 15,586,346 - - -

Commit: ba51eb9

Benchmark Workflow

Copy link
Contributor

@jonathanpwang jonathanpwang left a comment

Choose a reason for hiding this comment

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

LGTM

@jonathanpwang jonathanpwang changed the title [fix] Add constraint to SHA extension that checks if the appended length is a multiple of 8 fix: Add constraint to SHA extension that checks if the appended length is a multiple of 8 Mar 10, 2025
@jonathanpwang jonathanpwang merged commit fad6c89 into main Mar 10, 2025
16 checks passed
@jonathanpwang jonathanpwang deleted the fix/sha-len-bug branch March 10, 2025 16:21
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