Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.


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 (https://dev.zenroom.org/) 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) and macOS machines.


🎮 Usage

Two main calls are exposed zencode_exec and zenroom_exec, one to run zencode and one for zenroom scripts as names suggest. The names follow the standard Zenroom naming as per Zenroom documentation.

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 (https://github.com/DECODEproject/Zenroom/tree/master/test/zencode_simple)[here] and (https://github.com/DECODEproject/Zenroom/tree/master/test/zencode_coconut)[here].

The complete documentation about zencode is available on http://dev.zenroom.org/zencode

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

Returns

  • an object (#ZenroomResult)[ZenroomResult] that is a facility to access the stdout and stderr result from the execution of the script

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.

ZenroomResult

This is a facility object that allows to acces the output result of the execution of zen{code,room}_exec commands.

Each time zenroom and zencode are executed stdout and stderr will be filled accordingly and a code is returned (0 for success and 1 if errored).

The following methods and properties are available:

stdout

This property contains all the output printing from the script/zencode run

stderr

This property contains all the content going to stderr that contains debug info and or stacktrace of the script/zencode run

has_error()

Returns True or False based on the return code of the zen{room,code}_exec calls

get_warnings()

Filters the warning messages from the stderr

get_errors()

Filters the error messages from the stderr

get_debug()

Filters the debug messages from the stderr

get_info()

Filters the info messages from the stderr

📋 Testing

Tests are made wuth pytests, just run

python setup.py test


🌐 Links

https://decodeproject.eu/

https://zenroom.org/

Release files for zenroom 1.0.7rc0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zenroom 1.0.7rc0
File Size Uploaded
zenroom-1.0.7rc0.tar.gz 24.5 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for zenroom 1.0.7rc0
File Interpreter ABI Platform
zenroom-1.0.7rc0-py3-none-any.whl Python 3 none any Details

Total release size: 49.2 MB

Release files / zenroom-1.0.7rc0.tar.gz

Download URL zenroom-1.0.7rc0.tar.gz
Size 24.5 MB
Tags Source
SHA-256 checksum
How to use checksums
a780c75ff4341f81b714b54d110bd9ca036482959435083b12532045eb7136db
BLAKE2b-256 checksum
How to use checksums
a3801bae09c489e54fc4bbec966280a02f2cbcd3b8f55363f2f667499eb43f08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

Release files / zenroom-1.0.7rc0-py3-none-any.whl

Download URL zenroom-1.0.7rc0-py3-none-any.whl
Size 24.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
210a25680ec0f44bb4997a14ed8b670f904845165496a459a2858e59d5dfca25
BLAKE2b-256 checksum
How to use checksums
19bb49b44c988042e5e261228e7bf9925860ec203c78e8fd9efc75420fc0030c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

Release history Release notifications | RSS feed

5.10.2

1 release file

4.0.0

1 release file

3.23.0

1 release file

3.20.0

1 release file

3.18.0

1 release file

3.9.1

21 release files

3.8.0

21 release files

3.7.2

21 release files

3.7.1

21 release files

3.7.0

21 release files

3.6.0

21 release files

3.5.1

21 release files

3.5.0

21 release files

3.4.0

21 release files

3.1.0

21 release files

3.0.4

21 release files

3.0.2

21 release files

3.0.1

21 release files

2.9.0

21 release files

2.8.1

21 release files

2.8.0

21 release files

2.4.2

21 release files

2.4.1

21 release files

1.0.13

2 release files

1.0.12

2 release files

1.0.9

2 release files

1.0.8

1 release file

This release

1.0.7rc0 This release

2 release files

1.0.6

1 release file

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.3.0

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

1 release file

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page