feat: add cancel_authwit to Token, NFT and MultiToken - #36
Draft
alejoamiras wants to merge 1 commit into
Draft
Conversation
This was referenced Aug 19, 2026
Upstream-parity function present in every upstream reference token
contract but absent from all three of ours. Without it, a private
authwit that has been granted but not yet consumed cannot be revoked.
Ported verbatim from the upstream Token/NFT contracts (aztec-packages
v5.1.0):
#[external("private")]
fn cancel_authwit(inner_hash: Field) {
let on_behalf_of = self.msg_sender();
let nullifier = compute_authwit_nullifier(on_behalf_of, inner_hash);
self.context.push_nullifier_unsafe(nullifier);
}
Cancellation pre-emits the same authwit nullifier the consume path
emits, so a later authwit-gated call fails with a duplicate nullifier.
Three tests per contract: the negative case (cancel then attempt to
consume -> duplicate nullifiers), a positive control (same flow without
the cancel succeeds, attributing the failure to the cancel), and caller
isolation (a foreign account cancelling with the owner's exact inner
hash does NOT revoke the owner's authwit, since the nullifier is bound
to msg_sender). READMEs list the new function.
Additive: a new selector, no existing ABI touched.
Validated: token 84 / nft 64 / multitoken 80 Noir tests, aztec compile
OK. Codex adversarial review: safe and upstream-equivalent; its two
suggestions (tighten the negative assertion, add the caller-isolation
test) are applied — note its proposed error string 'already present'
was empirically wrong, the matchable revert is 'duplicate nullifiers'.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
alejoamiras
force-pushed
the
stack/closeout-cancel-authwit
branch
from
August 19, 2026 16:16
c6ba431 to
9c47655
Compare
Benchmark Comparison
Contract: escrow
Contract: logic
Contract: multitoken
Contract: nft
Contract: token
Contract: vault
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
Adds
cancel_authwitto Token, NFT and MultiToken. Every upstream reference token contract has it; none of ours did, so a private authwit that has been granted but not yet consumed could not be revoked.Ported verbatim from upstream (aztec-packages v5.1.0):
Cancellation pre-emits the same nullifier the consume path emits, so a later authwit-gated call fails on the duplicate.
Additive — a new selector; no existing ABI touched.
Tests (3 per contract, 9 total)
duplicate nullifiersinner_hashdoes not revoke the owner's authwit, proving themsg_senderbindingValidation
Full Noir suites: token 84 · nft 64 · multitoken 80.
aztec compileOK.Codex adversarial review: "safe and upstream-equivalent." Both of its suggestions applied. Note its proposed assertion string (
already present) was empirically wrong — that's the world-state DB log line; the matchable revert reason isduplicate nullifiers, verified by running.