The hardest part of post-quantum wallet adoption on Ethereum is not the cryptography. It is liquidity inertia. Billions of dollars already sit in audited Safe{Wallet} multisigs, and almost no DAO or treasury wants to migrate funds into a brand-new standalone wallet contract.
So instead of asking teams to move funds, I built QVaultSafeGuard.sol in QVault v0.4.0: a single multi-Safe guard contract that bolts pure-Keccak WOTS+-128 + XMSS post-quantum co-signing onto any existing Safe v1.3, v1.4, or v1.5 without moving a single wei.
How it works with unmodified Safe{Wallet}
QVaultSafeGuard implements both Safe's ITransactionGuard (0xe6d7a83a) and Safe v1.5's IModuleGuard (0x58401ed8), plus ERC-165 (0x01ffc9a7).
- One-time attach (via Safe Transaction Builder): Your Safe executes a 2-call batch:
guard.configureSafe(...)(binding the Safe's XMSS root, salt, freeze hash, and policy) followed bysafe.setGuard(address(guard)). - Pre-approve with a one-time PQ signature: Before executing a Safe transaction, any owner or relayer calls
guard.approveSafeTx(safe, safeNonce, to, value, dataHash, operation, deadline, pqSig). Because it takesdataHash = keccak256(data), even a huge MultiSend Safe batch costs constant calldata gas. - Execute normally in
app.safe.global: Safe'sexecTransactioncallscheckTransaction(...), which checks thatapprovedSafeTx[safe][txKey]exists forISafe(safe).nonce() - 1and consumes it atomically.
Three Safe-specific gotchas worth getting right
- Safe increments
nonce++before callingcheckTransaction. InsidecheckTransaction,ISafe(msg.sender).nonce()is alreadytxNonce + 1. Subtracting 1 ensures the PQ signature binds to the exact executing nonce. - Blocking ECDSA attackers from uninstalling or overwriting the guard. Once a Safe calls
configureSafe, subsequent calls toconfigureSaferevert withAlreadyConfigured. And insidecheckTransaction, any self-call (to == safe, which coverssetGuard(0),enableModule,swapOwner,setFallbackHandler) and anyDELEGATECALLunconditionally require a PQ approval. Even if a quantum computer breaks 100% of the Safe's ECDSA owners, the attacker cannot remove the guard, overwrite the XMSS root, or drain funds. - Hash-locked emergency freeze + PQ rotation. Calling
emergencyFreeze(safe, freezeSecret)locks all Safe transactions in 35,783 gas without touching XMSS leaves. CallingrotateRoot(...)with a valid PQ signature unfreezes the Safe and rotates to a fresh 1,024-leaf epoch at the same Safe address.
Measured gas (solc 0.8.28, optimizer 200 runs, depth=10, Cancun & Prague identical)
| Operation | Gas (Cancun & Prague / EIP-7623) |
|---|---|
verifySafeActionView (pure WOTS+-128 + XMSS verify) | 57,023 |
approveSafeTx (verify + bitmap burn + store pre-approval) | 146,331 |
emergencyFreeze (instant Safe kill switch) | 35,783 |
rotateRoot (unfreeze + fresh 1,024 leaves) | 112,989 |
All 20 cross-language Rust + Browser WASM + Solidity checks (including a MockSafe quantum-hijack test suite trying to drain ETH, call setGuard(0), overwrite configureSafe, and call unapproved modules) run locally in ~30s:
git clone https://github.com/regitxx/qvault && cd qvault cargo test && cargo build --release --all-targets cd evm-verify && npm install && node verify.mjs && node verify-wasm.mjs Try the Safe Batch Builder & Browser WASM signer
Open the Safe{Wallet} PQ Guard tab at https://qvault.reziiix.com (keys stay 100% client-side in a 185 KB Rust WebAssembly module; exports a ready-to-import Safe Transaction Builder JSON).
Caveat: v0.4.0 is newly engineered and not yet externally audited, so test on Arbitrum Sepolia / Base Sepolia before attaching to mainnet treasuries. Feedback from Safe module builders and auditors welcome.


