Skip to content

fix: don't copy BoundedVec data past length - #20

Open
asterite wants to merge 2 commits into
masterfrom
fix/sha512-var-dirty-storage-tail
Open

fix: don't copy BoundedVec data past length#20
asterite wants to merge 2 commits into
masterfrom
fix/sha512-var-dirty-storage-tail

Conversation

@asterite

Copy link
Copy Markdown
Contributor

Problem Resolved

Resolves https://github.com/noir-lang/noir-library-claude/issues/2

Summary of Changes

digest_var takes a BoundedVec as an input and copied all of its storage into a byte array to produce the digest. The problem is that data past the BoundedVec's length must be zero for the hash to be produced correctly. If it's the case that the BoundedVec was shrinked from some previous non-zero value, the hash isn't correct then.

This PR only copies the relevant data. The second commit is a small optimization.

PR Checklist

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

asterite and others added 2 commits July 24, 2026 14:09
sha512_var/sha384_var copied the full backing array of the input
BoundedVec into the padded message buffer, so prover-controlled bytes
past `len` survived into the padding zero-fill region and polluted the
digest. Mask the copy so bytes past `len` are always zero, and add
regression tests that build a dirty vec via push/pop.

Fixes noir-lang/noir-library-claude#2

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@asterite
asterite requested a review from TomAFrench July 24, 2026 17:25
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.

1 participant