Zenroom for Python:Zenroom库的Python绑定。
项目描述
在Python3中使用Zenroom
zenroom.py 🐍
A Python3 wrapper of Zenroom, a secure and small virtual machine for crypto language processing
This library attempts to provide a very simple wrapper around the Zenroom (https://zenroom.dyne.org/) crypto virtual machine developed as part of the DECODE project (https://decodeproject.eu/), that aims to make the Zenroom virtual machine easier to call from normal Python code.
Zenroom itself does have good cross platform functionality, so if you are interested in finding out more about the functionalities offered by Zenroom, then please visit the website linked to above to find out more.
💾 安装
pip install zenroom
注意 - 上述命令尝试安装zenroom包,将Zenroom VM作为预编译的二进制文件拉入,因此只能在Linux和macOS机器上工作。
对于边缘(master分支的最新提交)版本,请运行
pip install zenroom --pre
The zenroom
package is just a wrapper around the zencode-exec
utility. You also need to install zencode-exec
, you can download if from the official releases on github
下载后,您需要将其移动到您的路径中的某个位置
sudo cp zencode-exec /usr/local/bin/
警告:在Mac OS上,可执行文件是 zencode-exec.command
,您需要将其链接到 zencode-exec
sudo cp zencode-exec.command /usr/local/bin/
cd /usr/local/bin
sudo ln -s zencode-exec.command zencode-exec
🎮 使用
暴露了两个主要调用,一个用于运行 zencode
,另一个用于 zenroom 脚本
。
如果您不知道 zencode
是什么,您可以从此博客文章开始 https://decodeproject.eu/blog/smart-contracts-english-speaker 官方文档可在 https://dev.zenroom.org/zencode/ 查找
在 https://decodeproject.eu/ 可以找到一组关于 zencode
合同的好例子
🐍 Python 包装器
包装器公开了两个简单的调用
zenroom_exec
zencode_exec
如名称所示,是执行 zenroom(lua 脚本)和 zencode 的两种方法。
参数
两个函数都接受相同的参数
script
字符串 要执行的 lua 脚本或 zencode 脚本keys
字符串 可选的密钥字符串,如 zenroom 文档中所述,用于执行 此处data
字符串 可选的数据字符串,如 zenroom 文档中所述,用于执行 此处conf
字符串 可选的 conf 字符串,根据 zen_config 此处
返回值
两个函数都返回相同的对象结果 ZenResult
,该对象有两个属性
示例
zencode_exec(script, keys=None, data=None, conf=None)
的示例使用
from zenroom import zenroom
contract = """Scenario ecdh: Create a keypair"
Given that I am known as 'identifier'
When I create the keypair
Then print my data
"""
result = zenroom.zencode_exec(contract)
print(result.output)
zenroom_exec(script, keys=None, data=None, conf=None)
的示例使用
from zenroom import zenroom
script = "print('Hello world')"
result = zenroom.zenroom_exec(script)
print(result.output)
与 zencode_exec
调用相同,应用了相同的参数和相同的结果。
📋 测试
测试使用pytest进行,只需运行
python setup.py test
在zenroom_test.py
文件中,您可以找到更多包装器的使用示例
🌐 链接
😍 致谢
版权所有(C)2018-2022,由阿姆斯特丹Dyne.org基金会
最初由Sam Mulube设计和编写。
由Puria Nafisi Azizi设计、编写和维护。
由Danilo Spinella和David Dashyan改写。
👥 贡献
请首先查看Dyne.org - 贡献者许可协议,然后
- 🔀 FORK IT
- 创建您的功能分支
git checkout -b feature/branch
- 提交您的更改
git commit -am 'Add some fooBar'
- 推送到分支
git push origin feature/branch
- 创建新的Pull Request
gh pr create -f
- 🙏 感谢
💼 许可证
Zenroom.py - a python wrapper of zenroom
Copyright (c) 2018-2022 Dyne.org foundation, Amsterdam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://gnu.ac.cn/licenses/>.
项目详情
zenroom-4.0.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 6e3c6c83cddf5c90ce1e6f463370be705940f150d95ef1ccda40362c71fcc873 |
|
MD5 | a765abaada603377fedfe6f3f24d6bbb |
|
BLAKE2b-256 | 05b272c56b900a00ac49fae5450fa3d7434874e5cc7fda9355f56bffea6fc514 |