A python wrapper for Zenroom
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.
This library has been developed for a specific deliverable within the project, and as such will likely not be suitable for most people's needs. Here we directly include a binary build of Zenroom compiled only for Linux (amd64), so any other platforms will be unable to use this library. This library has also only been tested under Python 3.
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
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) machines.
Two main calls are exposed, one to run
zencode and one for
If you don't know what
zencode is, you can start with this blogpost
A good set of examples of
zencode contracts could be found here
Here a quick usage example:
from zenroom import zenroom contract = """Scenario 'coconut': "To run over the mobile wallet the first time and store the output as keypair.keys" Given that I am known as 'identifier' When I create my new keypair Then print all data """ result = zenroom.zencode_exec(contract) print(result.stdout)
The zencode function accepts the following:
script(str): Required byte string or string containing script which Zenroom will execute
keys(str): Optional byte string or string containing keys which Zenroom will use
data(str): Optional byte string or string containing data upon which Zenroom will operate
conf(str): Optional byte string or string containing conf data for Zenroom
verbosity(int): Optional int which controls Zenroom's log verbosity ranging from 1 (least verbose) up to 3 (most verbose)
- ZenroomResult: The output is an object that holds two attributes
from zenroom import zenroom script = "print('Hello world')" stdout = zenroom.zenroom_exec(script=script) print(output.stdout) # guess what
The same arguments and the same result are applied as the
Tests are made wuth pytests, just run
python setup.py test