Skip to content

fix(sha256): Add extra checks against message size when constructing msg blocks#5861

Merged
vezenovm merged 2 commits intomasterfrom
mv/fix-sha-large-padded-msg
Aug 29, 2024
Merged

fix(sha256): Add extra checks against message size when constructing msg blocks#5861
vezenovm merged 2 commits intomasterfrom
mv/fix-sha-large-padded-msg

Conversation

@vezenovm
Copy link
Copy Markdown
Contributor

@vezenovm vezenovm commented Aug 29, 2024

Description

Problem*

Resolves

Issue found in zk passport https://github.com/ocelots-app/passport-verifier/blob/47e9464e7e782b07b6d791bf1d13257fce2f486b/crates/lib/data-check/integrity/src/lib.nr#L118 when performing sha on a message with a large padding.

Summary*

The current sha algorithm accounts for message padding, but only where ithe padding is still contained in the block we are compressing. For the case where we have a padding that extends multiple blocks past the message size we end up with a correctness error. We need to add more checks against the message size to make sure we are comrpessing the correct msg block.

An increase in gate count is expected from these changes.

Additional Context

Documentation*

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [For Experimental Features] Documentation to be submitted in a separate PR.

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

Loading
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