智能合约不够安全?Blockstream想用Simplicity语言改变现状

来源:比特帮    发布:2017-12-15 20:44:17   

02.jpg

现实当中,智能合约引发的安全问题一直被人诟病。在今年10月举行的PLAS 2017上,Blockstream的Russell O’Connor博士介绍了关于“Simplicity:区块链的新语言”的论文,有望改变这种现状。

据介绍,Simplicity是一种用于智能合约的新的函数式编程语言,Simplicity通过扩展的功能性扩大了传统功能,改进了安全性,并集成了MAST。

Blockstream官网上对Simplicity进行了这样的描述:

作为现有的加密货币语言的替代方案,基于相继式演算的Simplicity语言提供了一些重大改进,其中第一个是扩展功能。 比特币自己的编程语言,比特币脚本的一个问题是,在比特币早期,一些操作码是被禁用的。例如,您可以在比特币脚本中添加数字,但不能将它们相乘。O’Connor想要更灵活的东西。

Simplicity也提高了安全性。首先是类型安全:Simplicity是一种使用组合子的类型函数式编程语言。还有来自可分析性的安全性:尽管Simplicity是有限完整的,允许对所有有限计算进行编程,并且提供了强大的智能合约系统所需的所有功能,但其图灵不完整,不允许无限循环,但允许进行静态分析。最后,正式语义支持助理Coq证明中的语言推理,允许形式验证的安全性,例如O’Connor正式验证了以Simplicity编写的SHA-256哈希函数的实现。

通过与Merklized抽象语法树(MAST),Simplicity对现有的加密货币语言进行了改善。作为一种原生的MAST编程语言,Simplicity将其程序安排到树中,然后只显示需要进行补救的部分;程序中未使用的部分会被删除,增加了隐私性,并减少了区块空间要求。

关于这种用于智能合约的新的函数式编程语言,巴比特对Russell O’Connor博士进行了简单采访,以下为访谈全文:

8btc:设计Simplicity语言的初衷是什么呢?
What‘s the purpose to create Simplicity language?

Russell O’Connor:One of Blockstream’s goals is to realize the potential of smart contracts on the blockchain. The complexity of existing languages in the ecosystem can make it difficult to safely secure and manage funds with smart contracts. With Simplicity, we are building a security-first approach to smart contracting.

Blockstream的目标之一是要在区块链上实现智能合约。在目前的生态系统中,已有的语言太过复杂,很难通过智能合约来安全地保管和管理资产。Simplicity以安全为第一要务,让我们可以更安全地开发智能合约。

8btc:现有的比较通用或者常见的加密货币语言有哪几种?分别有什么特点呢?
Currently, what are the common languages being using? What are the features of them?

Russell O’Connor:Bitcoin Script and Ethereum’s EVM are currently two common languages for processing smart contracts.

Bitcoin Script works well for a variety of smart contracts ranging from simple digital signature validation to more complex smart contracts such as Lightning payments and atomic swaps. However, Bitcoin Script is limited in its expressiveness. For example, multiplication was disabled by Satoshi Nakamoto early in Bitcoin’s history.

Ethereum’s EVM language is very expressive and allows arbitrary computations to be performed. However, this expressivity comes with drawbacks. For example, there is no universal algorithm that can determine the maximum cost of executing a smart contract. As a result Ethereum has funds locked by smart contracts that are too expensive to ever execute.

目前用来处理智能合约的通常有两种语言:Bitcoin Script以及以太坊的EVM。

Bitcoin Script在很多智能合约上都表现出色,从简单的数字签名验证到更复杂的智能合约,比如闪电网络付款以及原子交换。但是Bitcoin Script在表达能力上则有所不足,比如中本聪在早期的时候就已经把乘法功能禁用了。

以太坊的EVM语言表达能力非常强,并且允许进行任意计算,但如此强大的表达能力有利也有弊。比如说,并不存在一个通用算法能够确定执行一个智能合约的最大成本,导致以太坊上有一些资金被智能合约锁定,而且因为成本太昂贵而无法执行智能合约。

8btc:Simplicity新语言有哪些特点?对现有的加密数字货币语言有什么改进?
What are the features of the new Simplicity language? Are there improvements towards the languages being using right now?

Russell O’Connor:In many ways Simplicity is better defined by what features it leaves out. Simplicity is a purely functional language without mutable state. Simplicity has no unbounded loop nor recursion and no function-types. These design choices make Simplicity amenable to both static analysis and formal analysis while still being flexible enough to define any finitary computation. Analysability helps developers reason about their Simplicity code and allows them to prove that their smart contracts behave correctly and that their programs will not be too expensive to run.

在很多情况下,也许说“有哪些特点是Simplicity所不具有的”,才能更好地介绍Simplicity这门语言。Simplicity仅仅是一门不具有可变状态的函数式语言,没有无限循环或递归,也没有函数类型。这种设计使得Simplicity能够进行静态分析和正规分析,同时还能灵活地对有限计算进行定义。Simplicity的可分析性能够帮助程序员解释他们用Simplicity写的代码,证明他们的智能合约运行正确,证明他们写的程序运行起来成本不会太高。

8btc:Simplicity是如何提高安全性的?
How does Simplicity enhance the security?

Russell O’Connor:We need high assurance software in order to secure funds within smart contracts. Simplicity comes with formal semantics defined in the Coq proof assistant. Formal semantics lets developers reason about the programs they write in Simplicity and allow them to prove they behave correctly. These proofs are checked by the Coq proof assistant to ensure that the proofs themselves are correct. This allows developers to achieve the highest standards of assurance available in the computing industry today. As an example, the SHA-256 cryptographic hash function has been programmed in Simplicity and verified correct using the Coq proof assistant.

我们需要可靠的软件来保证智能合约里的资产安全。Simplicity含有由Coq证明助理定义的正式语义学,可以让开发者解释他们使用Simplicity写的程序,并证明这些程序能够正确运行。这使得开发者能够达到计算行业内目前所能达到的最高可靠程度。为了给大家举个例子,我们已经用Simplicity把SHA-256密码学哈希函数写出来了,并用Coq证明助理证明了其正确性。

8btc:拓展性上,Simplicity是如何更好实现的?Simplicity还有哪些其他特点?
On scalability level, how does Simplicity achieve it in a better way? What other features Simplicity got?

Russell O’Connor:Simplicity has features that aim to keep smart contracts scalable.

The most important feature is MAST (Merkelized Abstract Syntax Trees), which is a technique that prunes unused code before it is placed on the blockchain. This lowers the costs of smart contracts and enhances privacy for users.

Simplicity also allows code to be shared between programs, saving on blockchain space. This potentially allows the network to compress the blockchain during download because common routines only need to be transmitted one time to each peer.

Simplicity含有旨在保持智能合约可扩展性的功能。

其中最重要的一个功能是MAST (默克尔化抽象语法树),在把代码推到区块链上之前,能够剪去未使用的代码,从而降低智能合约的成本、提高用户隐私保护。

Simplicity把代码保存在区块链上,这就使得不同程序也可以共享代码,这个功能有个潜在的好处,就是下载时能够让网络压缩区块链,因为通用的代码只需要向每个节点传输一次即可。

8btc:有哪些需求的用户适合使用Simplicity呢?
What kind of users should use Simplicity?

Russell O’Connor:Simplicity is designed to be a low-level language that is part of a blockchain’s consensus protocol. While it is possible to write Simplicity programs by hand, I expect developers will build tools on top of Simplicity that let users create smart contracts using various user-friendly languages that will be compiled into Simplicity. Because of Simplicity’s flexibility, an entire ecosystem of different smart contracting languages can be built upon it.

按照区块链共识协议的要求,Simplicity被设计成一个低门槛的语言,完全可以使用该语言手写程序,同时我估计也会有开发者在Simplicity的基础上开发更多用户友好的工具,使得用户也能方便地使用Simplicity及其衍生工具撰写智能合约。Simplicity非常灵活,甚至可以在其之上建立包含不同智能合约语言的一整个生态系统。

8btc:Simplicity现在处在什么阶段?预计在什么时候会正式发布?
Which phase is Simplicity at now? When will it be officially launched?

Russell O’Connor:Simplicity is under active research and development at Blockstream. Our recent publication at the PLAS 2017 workshop is a first step to gather feedback on the proposed design of Simplicity. The next step is to make an SDK (software development kit) available to enable developers everywhere to build new tools that use Simplicity. Then we can make Simplicity available on Blockstream’s Elements project so that anyone can experiment with Simplicity on a sidechain.

Blockstream 正在积极研究开发Simplicity。我们最近在PLAS 2017工作坊上发表了最新成果,对Simplicity的设计初稿征求意见。接下来要把SDK (软件开发工具包)开放给全世界的开发者,让他们开发使用Simplicity的工具。之后我们就可以把Simplicity开放到Blockstream的Elements项目上,这样每个人都可以在侧链上对Simplicity进行试验。