Power and Pitfalls of Generic Smart Contracts

Andrea Benini, Mauro Gambini, S. Migliorini, F. Spoto
{"title":"Power and Pitfalls of Generic Smart Contracts","authors":"Andrea Benini, Mauro Gambini, S. Migliorini, F. Spoto","doi":"10.1109/BCCA53669.2021.9657048","DOIUrl":null,"url":null,"abstract":"Generics are a powerful feature of programming languages that allows one to write highly reusable code. More specifically, they are based on the use of type placeholders in order to produce parametrized code, that can be instantiated for each concrete type provided for them. In many programming languages, such as Java, they are implemented by erasure, ie. replaced by their upper bound type during compilation into bytecode. This paper originated from a real security issue that we found while using generics for writing smart contracts for blockchain, in order to implement a contract for shared entities (such as a company shared by its shareholders), for the Hotmoka blockchain, whose contracts are written in Java. The considered case study is particularly important since the validators’ set of the blockchain itself is a special case of shared entities. The analysis shows that the power of generics comes at the risk of a too permissive typing of the compiled code, due to the erasure mechanism, with a consequent possible attack to the validators’ set. This paper proposes a solution that forces the compiler to generate more precise type information than those arising by erasure.","PeriodicalId":202582,"journal":{"name":"2021 Third International Conference on Blockchain Computing and Applications (BCCA)","volume":"13 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2021-11-15","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"2","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"2021 Third International Conference on Blockchain Computing and Applications (BCCA)","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1109/BCCA53669.2021.9657048","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 2

Abstract

Generics are a powerful feature of programming languages that allows one to write highly reusable code. More specifically, they are based on the use of type placeholders in order to produce parametrized code, that can be instantiated for each concrete type provided for them. In many programming languages, such as Java, they are implemented by erasure, ie. replaced by their upper bound type during compilation into bytecode. This paper originated from a real security issue that we found while using generics for writing smart contracts for blockchain, in order to implement a contract for shared entities (such as a company shared by its shareholders), for the Hotmoka blockchain, whose contracts are written in Java. The considered case study is particularly important since the validators’ set of the blockchain itself is a special case of shared entities. The analysis shows that the power of generics comes at the risk of a too permissive typing of the compiled code, due to the erasure mechanism, with a consequent possible attack to the validators’ set. This paper proposes a solution that forces the compiler to generate more precise type information than those arising by erasure.
通用智能合约的功能和缺陷
泛型是编程语言的一个强大特性,它允许编写高度可重用的代码。更具体地说,它们基于使用类型占位符来生成参数化代码,这些代码可以为提供给它们的每个具体类型实例化。在许多编程语言(如Java)中,它们是通过擦除实现的。在编译成字节码时由它们的上界类型替换。本文源于一个真实的安全问题,我们在使用泛型为区块链编写智能合约时发现,为了实现共享实体(如股东共享的公司)的合约,对于Hotmoka区块链,其合约是用Java编写的。考虑的案例研究特别重要,因为区块链本身的验证者集是共享实体的特殊情况。分析表明,由于擦除机制,泛型的强大带来了编译代码类型过于宽松的风险,从而可能对验证器集造成攻击。本文提出了一种解决方案,强制编译器生成比擦除产生的更精确的类型信息。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术官方微信