Skip to main content

Python wrapper for the Zenroom virtual machine

Project description


Zenroom

zenroom.py 🐍
A python wrapper for Zenroom

Build status Code coverage PyPI


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.

🚩 Table of Contents (click to expand)

💾 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) 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

A good set of examples of zencode contracts could be found here https://github.com/DECODEproject/dddc-pilot-contracts

ZENCODE

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, errors = zenroom.zencode_exec(contract)
print(result)

NOTE The result is in bytes and not string if you want a string you want to .decode() it

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)

Returns

  • tuple: The output from Zenroom expressed as a byte string, the eventual errors generated as a string

ZENROOM SCRIPTS

from zenroom import zenroom

script = "print('Hello world')"
output, errors = zenroom.zenroom_exec(script)

print(output)

The same arguments and the same result are applied as the zencode call.


📋 Testing

Tests are made wuth pytests, just run

python setup.py test


🌐 Links

https://decodeproject.eu/

https://zenroom.org/

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

zenroom-1.1.0rc2.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

zenroom-1.1.0rc2-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file zenroom-1.1.0rc2.tar.gz.

File metadata

  • Download URL: zenroom-1.1.0rc2.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for zenroom-1.1.0rc2.tar.gz
Algorithm Hash digest
SHA256 4bb072bafbdd158c531d046c191a233426e931e8570b5f6f2751f10668d5ee54
MD5 2eec22e0445f91bd958ff99e58ba1f02
BLAKE2b-256 cad3cf5205193a158f94615f0fade0d8feff39a6265aa0b0feb403fef60a8972

See more details on using hashes here.

File details

Details for the file zenroom-1.1.0rc2-py3-none-any.whl.

File metadata

  • Download URL: zenroom-1.1.0rc2-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for zenroom-1.1.0rc2-py3-none-any.whl
Algorithm Hash digest
SHA256 c53113585ea499e18c146b2611ff3523f287bc1e4935b68ea9d06cb502c10bb3
MD5 92d6ebac576c608cb42ef423decb90c3
BLAKE2b-256 e87ff8d542bece45dfb30f1b86f957eb67fee6f0bb515875ed998ec7b7320e24

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page