# BChainGuard: A New Framework for Cyberthreats Detection in Blockchain Using Machine Learning
## 3 Contribution: BChainGuard
### BChainGuard Phases  
Phase 1: Selection of the dataset and artificial intelligence tool  
In this phase, the dataset of attack on the blockchain is selected which is located in [26]. In addition, we plan to use SVM (support vector machine) as a machine learning tool and MLP (multi-layer perceptron) as a deep learning tool.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Tools** & **Technique of Detection** & **Cyberthreat Coverage** & **Limitations** \\ \hline TRS [17] & Using graph theory to detect anomalies in smart contract & Smart contract vulnerabilities & In the case of a transaction having a large scale this rate of anomalies detection is similar to the existing method \\ \hline ADM [18] & Using one-class SVM and K-means for transaction anomalies detection & DDoS, 51\% attack, and Double spending attack & The anomalies are executed by the authors themselves so they can be nonrealistic \\ \hline ContractGuard [19] & A mechanism for intrusion detection & Attempts of malicious intrusion & Needs more experience with real smart contract vulnerabilities \\ \hline SODA [20] & On-chain applications to detect anomalies & DAO attack, time hijacking, smart contract vulnerabilities & Used only for online detection of a specific attack list \\ \hline BAD [21] & Blockchain Anomaly Detection solution & Eclipse attack, zero-day attack & Used only for online detection of 2 kinds of attacks \\ \hline SolGuard [22] & A solution to detect anomalies in smart contract & Smart contract vulnerabilities and DoS attack & High overheads due to deployment and runtime \\ \hline DefectChecker [23] & Analyzing byte code to detect anomalies in smart contracts & Detecting if a contract is controlled by an attacker & functions call issues cannot be detected \\ \hline \hline \end{tabular}
\end{table}
Table 1: Comparison of the existing frameworks for blockchain intrusion detection.  
Phase 2: Linking the dataset to the Ethereum blockchain  
To link the dataset from the client to the blockchain, there are two strategies: (1) on-chain solution, which means uploading the whole dataset in the blockchain, or (2) off-chain solution, which means uploading only the hash of the dataset to the blockchain. Both strategies help to protect the integrity of the dataset.  
Phase 3: Checking the integrity of the data set and executing classification techniques  
Before executing the classification techniques on the client side using Python, we can either: (1) download the dataset from the blockchain in case we choose on-chain strategies or (2) hash the dataset and compare the hash with that of the dataset in the blockchain in case of off-chain strategies.  
Phase 4: Uploading decision functions to the blockchain  
During this phase, classification techniques are executed in the local machine using Python. Next, we extract the parameters of the decision function for both SVM and MLP. Finally, upload these parameters to be used by smart contracts on blockchain to segregate between normal behavior and abnormal behavior. This helps to protect the blockchain against attack.  
Phase 5: Performance evaluation  
The performance evaluation of the proposed techniques can be measured following many parameters, such as the accuracy, the recall, the f1-score, and the time of execution. The proposed technique will also be compared with an existing technique using the same dataset [27] to validate the contribution and to show its effectiveness.