Abstract
Recently, the development of blockchain technology has given us an opportunity to improve the security and trustworthiness of multimedia. With the applications of blockchain technology, smart contracts have been widely used in many industries. However, the current development of smart contracts faces many challenges. One of the challenges is that the coding process is complicated for developers, leading to unnormalized code and can cause development and maintenance issues. Also, this is an important limitation factor in the development of smart contracts. To solve this problem, this paper proposes a method of generating contract templates based on the Long Short-Term Memory Recurrent Neural Network (LSTM-RNN) to simplify the coding process. First, the contracts available online were crawled, before detecting the vulnerabilities of these contracts. Contracts with less vulnerabilities are used as training data. For better generation effects, the Abstract Syntax Tree (AST) and the word2vec are used to extract the lexical unit sequence features to obtain a word vector in order to analyze the semantics of the code. Afterwards, the generated sequence vector features are fed to LSTM-RNN for template generation. The efficiency of four types of vectorization method models were tested and the results showed that the Skip-Gram+ HS used in this paper achieved the highest performance. In addition, a security test was conducted based on the contracts before and after using the contract templates for normalized coding. The results show that the proposed method is not only a beneficial attempt to combine deep learning with blockchain technology, but also provides an effective guidance for improving the security of smart contracts.
Similar content being viewed by others
References
Alexandru CV (2016) Guided code synthesis using deep neural networks. In: Proceedings of the 2016 24th ACM SIGSOFT international symposium on foundations of software engineering, pp 1068–1070
Alharby M, Van Moorsel A (2017) Blockchain-based smart contracts: a systematic mapping study. arXiv:1710.06372
Almadhoun R, Kadadha M, Alhemeiri M et al (2018) A user authentication scheme of IoT devices using blockchain-enabled fog nodes. In: 2018 IEEE/ACS 15th international conference on computer systems and applications (AICCSA), pp 1–8
Atzei N, Bartoletti M, Cimoli T (2017) A survey of attacks on ethereum smart contracts (sok). In: International conference on principles of security and trust, pp 164–186
Bengio Y (2005) Hierarchical probabilistic neural network language model. In: International workshop on artificial intelligence and statistics, pp 246–252
Brabrand C, M?ller A, Schwartzbach MI (2008) Dual syntax for XML languages. Inf Syst 33(4-5):385–406
Das A K, Kalam S, Sahar N et al (2020) UCFL: user categorization using fuzzy logic towards PUF based two-phase authentication of fog assisted IoT devices. Comput Sec 97:101938
Datta S, Das AK, Kumar A, Sinha D (2019) Authentication and privacy preservation in IoT based forest fire detection by using blockchainCa review. In: International conference on internet of things and connected technologies, pp 133–143
Datta S, Kumar S, Sinha D, Das A K (2022) BSSFFS: blockchain-based sybil-secured smart forest fire surveillance. J Ambient Intell Humanized Comput 13(5):2479–2510
Dingman W, Cohen A, Ferrara N et al (2019) Defects and Vulnerabilities in smart contracts, a classification using the NIST bugs framework. Int J Netw Distributed Comput 7(3):121–132
Durieux T, Ferreira JF, Abreu R et al (2020) Empirical review of automated analysis tools on 47,587 ethereum smart contracts. In: Proceedings of the ACM/IEEE 42nd international conference on software engineering, pp 530–541
Fluss R, Faraggi D, Reiser B (2005) Estimation of the Youden Index and its associated cutoff point. Biometric J: J Math Methods Biosci 47(4):458–472
Fotiou N, Pittaras I, Siris VA et al (2019) Secure IoT access at scale using blockchains and smart contracts. In: 2019 IEEE 20th international symposium on“ a world of wireless, mobile and multimedia networks”(WoWMoM), pp 1–6
Halgamuge MN, Guruge D (2022) Fair rewarding mechanism in music industry using smart contracts on public-permissionless blockchain. Multimed Tools Appl 81(2):1523–1544
Hao Z, Mao D, Zhang B et al (2020) A novel visual analysis method of food safety risk traceability based on blockchain. Int J Environ Res Public Health 17(7):2300
Hao Z, Wang G, Mao D et al (2021) A novel method for food market regulation by emotional tendencies predictions from food reviews based on blockchain and saes. Foods 10(6):1398
Hasan H R, Salah K (2018) Proof of delivery of digital assets using blockchain and smart contracts. IEEE Access 6:65439–65448
Hou L, Zhu J, Kwok J et al (2019) Normalization helps training of quantized lstm. Adv Neural Inf Process Syst:32
Jiang F, Fu Y, Gupta BB et al (2018) Deep learning based multi-channel intelligent attack detection for data security. IEEE Trans Sustain Comput 5(2):204–212
Jiang B, Liu Y, Chan WK (2018) Contractfuzzer: fuzzing smart contracts for vulnerability detection. In: 2018 33rd IEEE/ACM international conference on automated software engineering (ASE), pp 259–269
Kim H K, Kim H, Cho S (2017) Bag-of-concepts: comprehending document representation through clustering words in distributed representation. Neurocomputing 266:336–352
Kim D, Seo D, Cho S, Kang P (2019) Multi-co-training for document classification using various document representations: TF-IDF, LDA, and Doc2Vec. Inf Sci 477:15–29
Kim G, Yi H, Lee J, Paek Y, Yoon S (2016) LSTM-based system-call language modeling and robust ensemble method for designing host-based intrusion detection systems (2016). arXiv:1611.01726
Kosba A, Miller A, Shi E et al (2016) Hawk: the blockchain model of cryptography and privacy-preserving smart contracts. In: 2016 IEEE symposium on security and privacy (SP), pp 839–858
Le P, Zuidema W (2015) Compositional distributional semantics with long short term memory. arXiv:1503.02510
Lee D, Park N (2021) Blockchain based privacy preserving multimedia intelligent video surveillance using secure Merkle tree. Multimed Tools Appl 80:34517–34534
Li J, Li J, Fu X et al (2016) Learning distributed word representation with multi-contextual mixed embedding. Knowl-Based Syst 106:220–230
Liu Y, Lu Q, Zhu C et al (2021) A blockchain-based platform architecture for multimedia data management. Multimed Tools Appl 80(20):30707–30723
Luu L, Chu DH, Olickel H et al (2016) Making smart contracts smarter. In: Proceedings of the 2016 ACM SIGSAC conference on computer and communications security, pp 254–269
Ma Z, Zhu L, Yu F R et al (2021) Protection of surveillance recordings via blockchain-assisted multimedia security. Int J Sensor Netw 37(2):69–80
Mao D, Hao Z (2019) A novel sketch-based three-dimensional shape retrieval method using multi-view convolutional neural network. Symmetry 11 (5):703
Mao D, Hao Z, Wang F et al (2018) Innovative blockchain-based approach for sustainable and credible environment in food trade: a case study in shandong province, china. Sustainability 10(9):3149
Mao D, Hao Z, Wang F et al (2019) Novel automatic food trading system using consortium blockchain. Arab J Sci Eng 44(4):3439–3455
Mao D, Wang F, Wang Y, Hao Z (2019) Visual and user-defined smart contract designing system based on automatic coding. IEEE Access 7:73131–73143
McCorry P, Shahandashti SF, Hao F (2017) A smart contract for boardroom voting with maximum voter privacy. In: International conference on financial cryptography and data security, pp 357–375
Mehar M I et al (2019) Understanding a revolutionary and flawed grand experiment in blockchain: the DAO attack. J Cases Inf Technol (JCIT) 21(1):19–32
Mou L, Li G, Zhang L et al (2016) Convolutional neural networks over tree structures for programming language processing. Thirtieth AAAI conference on artificial intelligence
Nugaliyadde A, Sohel F, Wong KW et al (2019) Language modeling through Long-Term memory network. In: 2019 international joint conference on neural networks (IJCNN). pp 1–6
Parizi RM, Dehghantanha A (2018) Smart contract programming languages on blockchains: an empirical evaluation of usability and security. In: International conference on Blockchain, pp 75–91
Parr TJ, Quong RW (1995) ANTLR: a predicated-LL (k) parser generator. Soft: Pract Exper 25(7):789–810
Peng H, Mou L, Li G et al (2015) Building program vector representations for deep learning. In: International conference on knowledge science, engineering and management. Springer, pp 547–553
Prechtel D, Groβ T, Müller T (2019) Evaluating spread of ‘gasless send’in ethereum smart contracts. In: 2019 10th IFIP international conference on new technologies, mobility and security (NTMS), pp 1–6
Rozario AM, Vasarhelyi MA (2018) Auditing with smart contracts. Int J Digit Account Res 18:1–27
Somasundaram N (2019) UBS introduces smart contracts for structured products, https://www.risk.net/derivatives/6745731/ubs-using-smart-contracts-for-some-structured-products. Accessed 18 June 2019
Tariq N, Asim M, Khan F A et al (2020) A blockchain-based multi-mobile code-driven trust mechanism for detecting internal attacks in internet of things. Sensors 21(1):23
Tikhomirov S, Voskresenskaya E, Ivanitskiy I et al (2018) Smartcheck: static analysis of ethereum smart contracts. In: Proceedings of the 1st international workshop on emerging trends in software engineering for Blockchain, pp 9–16
Tsankov P, Dan A, Drachsler-Cohen D et al (2018) Securify: practical security analysis of smart contracts. In: Proceedings of the 2018 ACM SIGSAC conference on computer and communications security. pp 67–82
Vukolić M (2017) Rethinking permissioned blockchains. In: Proceedings of the ACM workshop on blockchain, cryptocurrencies and contracts, pp 3–7
Wang G, Hao Z, Zhang B et al (2022) Convergence and robustness of bounded recurrent neural networks for solving dynamic Lyapunov equations. Inf Sci 588:106–123
White M, Vendome C, Linares-Vásquez M et al (2015) Toward deep learning software repositories. In: 2015 IEEE/ACM 12th working conference on mining software repositories, pp 334–345
Wu H C, Luk R W P, Wong K F et al (2008) Interpreting tf-idf term weights as making relevance decisions. ACM Trans Inf Syst (TOIS) 26(3):1–37
Xu Y, Qu W, Li Z, Min G, Li K, Liu Z (2014) Efficient k-Means++ approximation with MapReduce. IEEE Trans Parallel Distributed Syst 25(12):3135–3144
Yang N, Li G, Ding H et al (2019) Study on tibetan word Vector based on word2vec. J Phys: Conf Series. IOP Publishing 1187(5):052074
Zen H, Acoustic modeling in statistical parametric speech synthesis-from HMM to LSTM-RNN (2015)
Zhao Z, Hao Z, Wang G et al (2021) Sentiment analysis of review data using blockchain and LSTM to improve regulation for a sustainable market. J Theo Appl Electr Comm Res 17(1):1–19
Acknowledgements
This work was supported in part by the National Natural Science Foundation of China under Grant 62277001, in part by the National Key Technology R&D Program of China under Grant SQ2020YFB10027, ZT2025002 in part by the Scientific Research Program of Beijing Municipal Education Commission under Grant KZ202110011017, in part by the Natural Science Foundation of Beijing Municipality under Grant 9232005, in part by the Beijing Municipal Philosophy and Social Science Foundation under Grant 19GLB036, in part by Major Science and Technology Special Project of Yunnan Province under Grant 202102AD080006, in part by the Open Research Fund of the Beijing Key Laboratory of Big Data Technology for Food Safety (Project No. BTBD-2021KF05), in part by University of Macau (File no. MYRG2019-00006-FST), and in part by the Science and Technology Development Fund of the Macau SAR (0091/2020/A2).
Funding
The authors declare that they have no conflict of interest
Author information
Authors and Affiliations
Corresponding authors
Additional information
Publisher’s note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Rights and permissions
Springer Nature or its licensor (e.g. a society or other partner) holds exclusive rights to this article under a publishing agreement with the author(s) or other rightsholder(s); author self-archiving of the accepted manuscript version of this article is solely governed by the terms of such publishing agreement and applicable law.
About this article
Cite this article
Hao, Z., Zhang, B., Mao, D. et al. A novel method using LSTM-RNN to generate smart contracts code templates for improved usability. Multimed Tools Appl 82, 41669–41699 (2023). https://doi.org/10.1007/s11042-023-14592-x
Received:
Revised:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s11042-023-14592-x