# Hidden mint arithmetic regression — September 5, 2026

An isolated local demonstration of a correction to the legacy DeFiSec article.
It is not a token implementation, deployed-contract audit or exploit against a live system.

Files: `foundry.toml`, `test/BalanceInvariant.t.sol`, `results.json`.
Keep the `test/` directory when downloading the Solidity file.

Run from this directory with Foundry and Solidity 0.8.36 installed:

```sh
forge test --root . --use 0.8.36 -vv
```

The recorded run used Forge 1.5.1 and local solc 0.8.36, EVM target paris.
All three test functions passed. The matrix evaluates 16 balance/amount pairs
from the Cartesian product of [0, 1, 2, 10] with itself. A difference means a
changed return value or changed success/revert outcome compared with checked
subtraction. The zero branch differs in 3 cases; the bitwise-complement branch
in 4. At balance 1 and amount 1 the zero branch coincides with normal subtraction.

The final test shows how incorrect balance writes can disagree with a separate
recorded-supply value. No full ERC-20 transfer or mint operation is implemented.
This finite example does not measure vulnerability prevalence, prove token safety,
or predict whether a balance can be sold.
