# Resilience Analysis for Double Spending via Sequential Decision Optimization
## 7 Attack Planning as an Optimal Switching Problem
### Numerical Illustration of Optimal Switching
However, for a different set of parameters we obtain another interesting situation:Here we observe that the attack is economically justifiable (line 19). Having started chain bifurcation at block difference zero, the secret mining is pursued (line 6, column \([,2]\)). However, being one block ahead, it is better to publish the secret chain to pocket the reward for a single block (line 7, column \([,2]\)). If the block difference is two or three, then one shall continue secret mining (lines 8, 9, column \([,2]\)), but for larger block difference, an attack (line 10, column \([,2]\)) should be launched. If the attack is already launched, one shall continue secret mining, with the exception when all confirming blocks are received and the attacker's advantage is exactly one block (line 7, column \([,8]\)), in which case the secret branch should be published. As illustrated above, the optimal double-spending strategy exhibits a relatively complex behavior. Due to its time-changing nature and non-obvious parameter dependence, it is difficult to face all quantitative aspects by diagrams and numerical case studies. For practical use, we suggest that a detailed investigation should be performed on a given parameter set using our code. Finally, let us numerically investigate the values \(v_{0}^{*}(0,2)\) for different gains \(C=100,50,30\) from a potentially successful double spending depending on the proportion \(q\in[0.15,0.3]\) between the mining capacity of the attacker and the total mining power. ```
1 FC-100;z<-6;q<-0.1;Q<-100;c<-5;rh<-0.1;z=0.07
2 ratio<-mq(from>0,z,to-0.3,length-20)
3 values<-seq(from>0,t>0,length-length(ratio))
4########################



20% for \(C=50\) and \(C=100\). Let us emphasize that such calculations can be used to determine the block number required to secure a transaction depending on its size. ## 9 Conclusions

Unfortunately, even relatively unsophisticated (classical textbook-style) double-spending attacks happen regularly. These malicious actions cause huge losses to investors and jeopardize the perspectives of the promising blockchain technology. In fact, the situation is worrying. The point here is that the double-spending problem actually concerns more than a single payment which may disappear later. The sheer possibility to rewrite the ledger with a deep re-organization of its blocks may cause enormous consequences. In this work, we show that planning an attack on a PoW-based system can be formulated as optimal sequential decision problem. Therefore, we consider two cases: A simplified model of a double-spending attack, which can be treated as an optimal stopping problem, and a more detailed modeling which requires an optimal stochastic switching toolbox. In the optimal stopping situation, the strategy consists of a secret mining, followed by a later payment. The optimal payment moment is determined by the length difference between the official and secret chains since their fork-off and depends on model parameters (mining capacity ratio, confirming block number and on the revenue/loss from the success/failure of the attack). A more complex stochastic switching model upgrades this framework by introducing the option to abandon secret mining at any time. Furthermore, a switching model provides also a more realistic context since it takes into account mining costs and rewards for published blocks. Most importantly, the optimal strategy can be used to determine whether it is worth attacking the PoW-based system. This insight may allow important conclusions on its vulnerability. However, to address this topic within an entirely realistic situation, the present models must be further developed to include propagation delay, and uncertainty in observations. Furthermore, complex consensus protocols based on (delegated) proof of stake, proof of storage, proof of burn or their combinations must be investigated from a similar perspective. Finally, also the possibility to slow down the honest mining by diverse malicious actions (in the spirit of [14]) must be examined.