Skip to content

docs(vault): document hand-rolled authwit rationale + regression test - #22

Merged
IlyasRidhuan merged 1 commit into
stack/deploy-toolingfrom
stack/vault-authorize-once
Aug 12, 2026
Merged

docs(vault): document hand-rolled authwit rationale + regression test#22
IlyasRidhuan merged 1 commit into
stack/deploy-toolingfrom
stack/vault-authorize-once

Conversation

@alejoamiras

@alejoamiras alejoamiras commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

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 == 0 self-call assertion. Investigating showed the 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 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. Forcing nonce == 0 on 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 compile clean · vault_contract 188/188 Noir tests (187 existing + the new regression test).

🤖 Generated with Claude Code

@alejoamiras alejoamiras changed the title docs(vault): explain why authwit validation is hand-rolled, add regression test docs(vault): document hand-rolled authwit rationale + regression test Aug 12, 2026
…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
IlyasRidhuan force-pushed the stack/vault-authorize-once branch from cf42eb6 to e10ab87 Compare August 12, 2026 16:40
@IlyasRidhuan
IlyasRidhuan merged commit bedde5a into main Aug 12, 2026
5 of 9 checks passed
@alejoamiras
alejoamiras deleted the stack/vault-authorize-once branch August 12, 2026 17:00
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