In Uniswap v4, hook permissions (BEFORE_SWAP, AFTER_SWAP, BEFORE_ADD_LIQUIDITY, return-delta flags, etc.) are encoded directly into the lowest 14 bits (uint160(addr) & 0x3FFF) of the hook contract's 20-byte address.
Finding a valid 14-bit salt alone only takes ~16,384 hashes (~40ms in Foundry's CPU HookMiner). However, if you also want leading zero bytes (0x000000... or 0x0000000000...) to permanently save 12 calldata gas per zero byte on every transaction hitting your router or hook, search complexity jumps to 38–42 bits — which takes days or months on CPU.
Here is how we built a single-block CUDA Keccak-256 kernel that reaches 1.36 GH/s on a single NVIDIA L4 GPU (~3,400x faster than Foundry CPU), plus a zero-dependency open-source verifier CLI.
Why CREATE2 Is Dramatically Faster Than Wallet Vanity Mining
Standard EVM/TRON vanity wallet mining requires elliptic-curve point addition (secp256k1) on every attempt (~300–400 MH/s on an L4).
By contrast, EIP-1014 CREATE2 uses zero elliptic-curve math:
address = keccak256(0xff || deployer[20] || salt[32] || initCodeHash[32])[12:]
The preimage is always 85 bytes, which fits completely inside a single 136-byte Keccak-256 rate block (0x01 domain separator at byte 85, 0x80 at byte 135). Every candidate salt costs just one keccak_f1600 permutation.
The 8-Byte Lane Alignment Trick
In the 85-byte preimage, bytes 21..52 hold the 32-byte salt. Looking at little-endian 64-bit Keccak lanes (st[0..16]):
-
st[3]covers bytes24..31→ entirely insidesalt[3..10] -
st[4]covers bytes32..39→ entirely insidesalt[11..18]
By placing thread_id in st[3] and the inner loop counter in st[4], the GPU inner loop loads 11 precomputed constant lanes from __constant__ memory and performs zero byte packing or shifting.
And after keccak_f1600(st), both leading hex prefixes AND Uniswap v4's 14-bit 0x3FFF mask collapse into two 64-bit register checks:
uint32_t w0 = __byte_perm((uint32_t)(st[1] >> 32), 0, 0x0123);
uint32_t w1 = __byte_perm((uint32_t)(st[2] & 0xFFFFFFFFULL), 0, 0x0123);
uint64_t top64 = ((uint64_t)w0 << 32) | (uint64_t)w1;
if ((top64 & d_pref_mask) == d_pref_val) {
uint32_t w3 = __byte_perm((uint32_t)(st[3] & 0xFFFFFFFFULL), 0, 0x0123);
uint32_t w4 = __byte_perm((uint32_t)(st[3] >> 32), 0, 0x0123);
uint64_t bot64 = ((uint64_t)w3 << 32) | (uint64_t)w4;
if ((bot64 & d_suff_mask) == d_suff_val) {
// Match! (For Uniswap v4 Hooks: d_suff_mask = 0x3FFFULL)
}
}
Empirical Benchmark: Foundry CPU vs NVIDIA L4 CUDA (1.36 GH/s)
Measured on an NVIDIA L4 (sm_89, 524,288 threads, 1,024 iterations/launch): 1,362.67 MH/s (1.36 GH/s).
| Target Constraint | Difficulty | Expected Hashes | Foundry CPU (~400 KH/s) | NVIDIA L4 CUDA (1.36 GH/s) |
|---|---|---|---|---|
14-bit v4 Hook + 0x0000 (4 zeros) |
30 bits | 1.07 B | ~45 min | ~0.8 s (1s measured) |
14-bit v4 Hook + 0x000000 (6 zeros) |
38 bits | 274.9 B | ~8 days | ~3.4 min |
0x0000000000... (5 zero bytes, -60 gas/call) |
40 bits | 1.10 T | ~32 days | ~13.5 min |
14-bit v4 Hook + 0x0000000 (7 zeros) |
42 bits | 4.40 T | ~127 days | ~54 min |
Reproducible Verification Vector & Open-Source CLI
Because CREATE2 only depends on public inputs (deployer + keccak256(initCode)), salt mining is 100% trustless — no private keys or source code are ever shared.
We published a zero-dependency Python verifier CLI on GitHub: uniswap-v4-hook-verifier.
You can independently verify our 1-second L4 benchmark output (0x0000 + BEFORE_SWAP | AFTER_SWAP = 0x0c00) offline:
python3 verify_hook.py verify \
--deployer 0x4e59b44847b379578588920cA78FbF26c0B4956C \
--salt 0x0d554b0b21a05577ab7a1b5c0dbc16f58404482bef4ff4323bb08c8a0c52af51 \
--init-code-hash 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
Output:
Address (EIP-55) : 0x0000E11Ec03A91aB93444Eaa4fB07E83A0EaCc00
Leading Zero Hex : 4 nibbles
Total Zero Bytes : 3 (saves 36 calldata gas / call)
Uniswap v4 Mask : 0x0c00 (binary 00110000000000)
Active v4 Hooks : BEFORE_SWAP_FLAG, AFTER_SWAP_FLAG
Online Browser Verifier & On-Demand GPU Mining
If you want to test 14-bit hook flags directly in your browser (or offload 36–44 bit salt mining to L4 GPUs without configuring CUDA yourself), see our CREATE2 & Uniswap v4 HookMiner tool and the full benchmark breakdown.
Top comments (0)