Python wrapper for the Zenroom virtual machine
Project description
zenroom.py 🐍
A Python3 wrapper of Zenroom, a secure and small virtual machine for crypto language processing
Zenroom and Zenroom.py are part of the DECODE project about data-ownership and technological sovereignty. Our effort is that of improving people's awareness of how their data is processed by algorithms, as well facilitate the work of developers to create along privacy by design principles using algorithms that can be deployed in any situation without any change.
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.
💾 Installation
pip install zenroom
NOTE - the above command attempts to install the zenroom package, pulling in the Zenroom VM as a precompiled binary, so will only work on Linux (amd64) and macOS machines.
🎮 Usage
Two main calls are exposed, one to run zencode
and one for zenroom scripts
.
If you don't know what zencode
is, you can start with this blogpost
https://decodeproject.eu/blog/smart-contracts-english-speaker
The official documentation is available on https://dev.zenroom.org/zencode/
A good set of examples of zencode
contracts could be found on
🐍 Python wrapper
the wrapper exposes two simple calls:
zenroom_exec
zencode_exec
as the names suggest are the two methods to execute zenroom (lua scripts) and zencode.
args
Both functions accept the same arguments:
script
string the lua script or the zencode script to be executedkeys
string the optional keys string to pass in execution as documented in zenroom docs heredata
string the optional data string to pass in execution as documented in zenroom docs hereconf
string the optional conf string to pass according to zen_config here
return
Both functions return the same object result ZenResult
that have two attributes:
stdout
string holds the stdout of the script executionstderr
string holds the stderr of the script execution
Examples
Example usage of zencode_exec(script, keys=None, data=None, conf=None)
from zenroom import zenroom
contract = """Scenario 'simple': 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.stdout)
Example usage of zenroom_exec(script, keys=None, data=None, conf=None)
from zenroom import zenroom
script = "print('Hello world')"
result = zenroom.zenroom_exec(script)
print(result.stdout)
The same arguments and the same result are applied as the zencode_exec
call.
📋 Testing
Tests are made with pytests, just run
python setup.py test
in (zenroom_test.py
)[https://github.com/DECODEproject/Zenroom/blob/master/bindings/python3/zenroom/zenroom_test.py]
file you'll find more usage examples of the wrapper
🌐 Links
😍 Acknowledgements
Copyright (C) 2018 by Dyne.org foundation, Amsterdam
Originally designed and written by Sam Mulube.
Designed, written and maintained by Puria Nafisi Azizi.
This project is receiving funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement nr. 732546 (DECODE).
👥 Contributing
- FORK IT
- Create your feature branch
git checkout -b feature/branch
- Commit your changes
git commit -am 'Add some fooBar'
- Push to the branch
git push origin feature/branch
- Create a new Pull Request
- Thank you
💼 License
Zenroom.py - a python wrapper of zenroom
Copyright (c) 2018 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 <http://www.gnu.org/licenses/>.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file zenroom-1.0.11.tar.gz
.
File metadata
- Download URL: zenroom-1.0.11.tar.gz
- Upload date:
- Size: 20.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28769342c14a1d4efcf88077eb34cc39061890982ce9deb6b233102d3ed7e737 |
|
MD5 | a87371b63ed966163a67f7b416cace66 |
|
BLAKE2b-256 | 32021aedcad8635e7c688f6f7b1f41e63fee6c083fb031b1d1347843164137e6 |
File details
Details for the file zenroom-1.0.11-py3-none-any.whl
.
File metadata
- Download URL: zenroom-1.0.11-py3-none-any.whl
- Upload date:
- Size: 20.9 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79a9629550f0c499ca1cb602428fa6c8f6e019887cdcd2827760ebecf9d74b0b |
|
MD5 | fac28cd04d819af02f909da0d365ef5d |
|
BLAKE2b-256 | 9ca8deec4b7060f8d030cf83e5f0b7dd811484e2c771ad05c0893649a0bf70ca |