docs(vault): document hand-rolled authwit rationale + regression test - #22
Merged
Merged
Conversation
…ssion test
A modernization audit suggested refactoring the vault to
#[authorize_once("from", "nonce")] like the other token contracts and
flagged the missing nonce==0 self-call assertion as a hygiene gap. That
refactor would be a functional regression: the vault's nonce is
dual-purpose — it is forwarded as the authwit nonce of the inner token
operations (asset transfer, shares burns), so a self-caller must be
able to pass a nonzero nonce to repeat otherwise-identical operations
(private authwit nullifiers commit to the inner call hash, nonce
included). Verified against the macro source and confirmed by
adversarial codex review.
Document the rationale on both validation helpers and add a regression
test performing two identical private self-deposits with distinct
nonces — exactly the flow #[authorize_once] would break.
Validated: aztec compile clean, vault_contract 188/188 Noir tests.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
IlyasRidhuan
force-pushed
the
stack/vault-authorize-once
branch
from
August 12, 2026 16:40
cf42eb6 to
e10ab87
Compare
IlyasRidhuan
approved these changes
Aug 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Documents why the Vault deliberately hand-rolls its authwit validation instead of using
#[authorize_once](as Token/NFT/MultiToken do), and adds a regression test pinning the behavior.Why
A modernization audit recommended the macro refactor and flagged the "missing"
nonce == 0self-call assertion. Investigating showed the refactor would be a functional regression: the Vault'snonceis dual-purpose — it is forwarded as the authwit nonce of the inner token operations the vault performs on the user's behalf (transfer_public_to_public,burn_public,burn_private— ten call sites). A self-caller needs no vault authwit but still grants token authwits to the vault, and distinct nonces are what let otherwise-identical operations repeat: private authwit nullifiers commit to the inner call hash, nonce included. Forcingnonce == 0on self-calls would break e.g. two identical private self-deposits.Verified against the
#[authorize_once]macro source in aztec-nr v5.1.0 and confirmed by adversarial codex review (which also confirmed no other runtime protection is missing from the manual implementation — all 19 entry points validate before effectful work with correct arity).The new test performs two identical private self-deposits with distinct nonces — exactly the flow the macro would revert.
Validation
aztec compileclean ·vault_contract188/188 Noir tests (187 existing + the new regression test).🤖 Generated with Claude Code