# Permit2 unordered-nonce checker

Version 1.0.0. Source review: 3 December 2026. All bundled examples are synthetic.

## What the checker establishes

Given a nonce and a supplied bitmap word, the checker calculates the exact word position, bit position, single-nonce mask, selected bit state and expected bitmap after OR with that mask. It runs in the reader's browser. Inputs are not sent to an RPC endpoint, wallet, server or analytics service by this tool.

This is a mathematical check of supplied values. The owner, chain, Permit2 contract, block, bitmap provenance, token, spender, signature and runtime spending authority remain unknown. The tool produces no transaction payload, signature, wallet request or chain-state observation. It neither chooses a permission to invalidate nor confirms a revocation.

## Pinned implementation and date meanings

The implementation reference is Uniswap/permit2 commit [`cc56ad0f3439c502c246fc5cfcc3db92bb8b7219`](https://github.com/Uniswap/permit2/commit/cc56ad0f3439c502c246fc5cfcc3db92bb8b7219), dated 29 September 2023. DN reviewed that source on 3 December 2026. No deployment was matched to the source and no live state was retrieved. The review date is not a state observation date.

The [source register](permit2-nonce-sources.json) records the exact source paths, Git blob IDs, SHA-256 hashes and byte counts. A hash establishes byte identity, not correctness or a matching deployment. The official [SignatureTransfer documentation](https://developers.uniswap.org/docs/protocols/permit2/concepts/signature-transfer) supplies the conceptual context; the pinned source controls the behavior modeled here.

## Input contract

Both inputs are required strings. Accepted forms are decimal digits (`257`) or hexadecimal digits with `0x` or `0X` prefix (`0x101`). Decimal strings may contain at most 78 digits; hexadecimal strings may contain at most 64 digits after the prefix. Leading zeroes are accepted within those limits and normalized in the output. The allowed integer range is 0 through 2^256 − 1, inclusive.

Whitespace, signs, fractions, separators, exponent notation, binary/octal prefixes and incomplete or trailing characters are rejected. Blank means unknown, not zero. JavaScript Number inputs are rejected even if they appear integral. The browser uses text controls and validates the complete input rather than silently truncating an overlong paste.

The nonce and the bitmap have different meanings. The nonce selects a word and one bit inside it. The bitmap is the complete 256-bit value supplied for that word. The tool cannot tell whether the bitmap came from the right owner, chain, contract, word or block. A mismatched supplied word can still yield mathematically valid output.

## Exact arithmetic

For nonce `n` and supplied bitmap `B`:

| Output | Formula | Range or meaning |
| --- | --- | --- |
| Word position `w` | `floor(n / 256)` | 0 to 2^248 − 1; upper 248 bits |
| Bit position `b` | `n mod 256` | 0 to 255; lower eight bits |
| Single-nonce mask `M` | `2^b` | Exactly one bit set |
| Selected bit is set | `(B AND M) != 0` | State of this bit in the supplied word only |
| Expected bitmap `B′` | `B OR M` | Model of invalidating that bit |

The production calculation uses BigInt throughout. No floating-point conversion, rounding or implicit string-to-Number conversion is used. All result integers are decimal strings; hexadecimal outputs are padded to 32 bytes. The bit position is also a string in JSON.

The pinned [`bitmapPositions`](https://github.com/Uniswap/permit2/blob/cc56ad0f3439c502c246fc5cfcc3db92bb8b7219/src/SignatureTransfer.sol) implementation performs the eight-bit split. `invalidateUnorderedNonces` ORs the supplied mask into the calling owner's selected word. The checker derives a mask for one nonce; it does not generate the function call.

The modeled result must satisfy three checks: the selected bit is set; all other bits are unchanged; repeating OR with the same mask does not change the result. A previously set bit stays set. The separate nonce-use path uses XOR and reverts when the bit was already set. XOR is not the invalidation operation modeled here, and a reverting call does not permanently clear the bit.

The actual storage mapping and invalidation argument use uint256 word indices. The word derived from a valid uint256 nonce fits uint248. This method does not claim the invalidation function rejects every larger arbitrary word index; the UI does not accept a separate word-index input.

## Worked synthetic example

Nonce `257` gives word `1` and bit `1`. The single-nonce mask is `2`. A supplied bitmap of `5` has bits zero and two set, so the selected bit is clear. OR with the mask produces `7`, preserving both previously set bits. OR with `2` again still produces `7`.

At the boundary, nonce `255` selects word zero, bit 255; nonce `256` selects word one, bit zero. A maximum uint256 nonce selects the maximum uint248 word and bit 255. The fixture includes these cases and `9007199254740993`, an integer beyond the JavaScript Number safe-integer boundary.

These examples do not describe a real account or an observed permission. No wallet action follows from them.

## Interpretation limits

A set bit cannot distinguish a previously consumed nonce from an explicit invalidation. A clear bit does not establish that a signature is valid, unexpired or authorized in its caller context. The checker does not evaluate any signature, domain, witness, token approval, balance, spender restriction or deployed implementation.

This method applies only to Permit2 SignatureTransfer unordered nonces. It does not model Permit2 AllowanceTransfer's ordered nonces, ERC-2612 nonces, account transaction nonces or delegated session policies. It grants no execution authority.

## Reproduce the synthetic results

Download [the fixture JSON](permit2-nonce-fixtures.json) and [the Python verifier](permit2-nonce-verify.py) into the same folder, then run:

```sh
python3 permit2-nonce-verify.py
```

Python 3 and its standard library are sufficient; there are no third-party packages or network calls. An explicit fixture path is also supported:

```sh
python3 permit2-nonce-verify.py /path/to/permit2-nonce-fixtures.json
```

The verifier independently uses integer division/remainder, exponentiation and conditional addition. It checks the fixture's expected values without importing or executing the production JavaScript. Its successful result establishes agreement for those invented cases, not contract security, deployment matching or live authorization.

The repository's separate Node tests exercise production JavaScript against these fixtures, exact upper bounds, malformed inputs, export encoding and 4,096 independent word/bit/bitmap combinations. Upstream source tests were inspected as documentation; DN did not run the upstream Foundry suite for this release. Browser lifecycle checks and their environment belong in the release record rather than being inferred from fixture verification.

## Export and maintenance

The downloaded calculation JSON retains the exact supplied strings, normalized integer values, formulas, pinned source metadata, unknown chain context and limitations. It is a local calculation record, not signed evidence or a transaction receipt. The receipt does not invent a chain observation timestamp.

Recheck the method if the referenced source revision changes, a real deployment is proposed for assessment, or input grammar or calculation behavior changes. Preserve this versioned fixture; corrections should produce a new version with a stated change record.
