zenroom


Namezenroom JSON
Version 4.0.0 PyPI version JSON
download
home_pagehttps://github.com/dyne/Zenroom
SummaryZenroom for Python: Bindings of Zenroom library for Python.
upload_time2023-10-31 11:18:33
maintainer
docs_urlNone
authorDanilo Spinella, David Dashyan, Puria Nafisi Azizi
requires_python>=3.8, <4
licenseAGPLv3
keywords zenroom crypto-language-processing virtual-machine blockchain crypto ecc dyne ecdh ecdsa zero-knowledge-proofs javascript npm ecp2 miller-loop hamming-distance elgamal aes-gcm aead seccomp goldilocks
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Use Zenroom in Python3
<p align="center">
  <br/>
  <a href="https://dev.zenroom.org/">
    <img src="https://dev.zenroom.org/_media/images/zenroom_logo.png" height="140" alt="Zenroom">
  </a>
  <h2 align="center">
    zenroom.py ๐Ÿ
    <br>
    <sub>A Python3 wrapper of <a href="https://zenroom.org">Zenroom</a>, a secure and small virtual machine for crypto language processing</sub> </h2>
  
<br><br>

  <a href="https://travis-ci.com/dyne/zenroom-py">
    <img src="https://travis-ci.com/dyne/zenroom-py.svg?branch=master" alt="Build status"/>
  </a>
  <a href="https://codecov.io/gh/dyne/zenroom-py">
    <img src="https://codecov.io/gh/dyne/zenroom-py/branch/master/graph/badge.svg" alt="Code coverage"/>
  </a>
  <a href="https://pypi.org/project/zenroom/">
    <img alt="PyPI" src="https://img.shields.io/pypi/v/zenroom.svg" alt="Latest release">
  </a>
</p>

<hr/>


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

```bash
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 and macOS
machines.

for the edge (syn to the latest commit on master) version please run:
```bash
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](https://github.com/dyne/Zenroom/releases/)

When after downloading you have to move it somewhere in your path:
```
sudo cp zencode-exec /usr/local/bin/
```

Warning: on Mac OS, the executable is `zencode-exec.command` and you have to symlink it to `zencode-exec`
```
sudo cp zencode-exec.command /usr/local/bin/
cd /usr/local/bin
sudo ln -s zencode-exec.command zencode-exec
```

***
## ๐ŸŽฎ 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/](https://dev.zenroom.org/zencode/)

A good set of examples of `zencode` contracts could be found on
* [zencode simple tests](https://github.com/dyne/Zenroom/tree/master/test/zencode_simple)
* [zencode coconut tests](https://github.com/dyne/Zenroom/tree/master/test/zencode_coconut)


### ๐Ÿ 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](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)** the lua script or
 the zencode script to be executed
- `keys` **[string](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)** the optional keys
 string to pass in execution as documented in zenroom docs [here](https://dev.zenroom.org/wiki/how-to-exec/#keys-string)
- `data` **[string](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)** the optional data
 string to pass in execution as documented in zenroom docs [here](https://dev.zenroom.org/wiki/how-to-exec/#data-string)
- `conf` **[string](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)** the optional conf
 string to pass according to zen_config [here](https://github.com/dyne/Zenroom/blob/master/src/zen_config.c#L99-L104)

#### return
Both functions return the same object result `ZenResult` that have two attributes:

- `stdout` **[string](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)** holds the stdout of the script execution
- `stderr` **[string](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)** holds the stderr of the script execution

##### Examples

Example usage of `zencode_exec(script, keys=None, data=None, conf=None)`


```python
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)
```


Example usage of `zenroom_exec(script, keys=None, data=None, conf=None)`

```python
from zenroom import zenroom

script = "print('Hello world')"
result = zenroom.zenroom_exec(script)

print(result.output)
```

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/dyne/Zenroom/blob/master/bindings/python3/tests/test_all.py) file you'll find more usage examples of the wrapper

***
## ๐ŸŒ Links

https://decodeproject.eu/

https://zenroom.org/

https://dev.zenroom.org/

## ๐Ÿ˜ Acknowledgements

Copyright (C) 2018-2022 by [Dyne.org](https://www.dyne.org) foundation, Amsterdam

Originally designed and written by Sam Mulube.

Designed, written and maintained by Puria Nafisi Azizi 

Rewritten by Danilo Spinella and David Dashyan

<img src="https://ec.europa.eu/cefdigital/wiki/download/attachments/289112547/logo-cef-digital-2021.png" width="310" alt="Project funded by the European Commission">
This project is receiving funding from the European Unionโ€™s Horizon 2020 research and innovation programme under grant agreement nr. 732546 (DECODE).

***

## ๐Ÿ‘ฅ Contributing
Please first take a look at the [Dyne.org - Contributor License Agreement](CONTRIBUTING.md) then

1.  ๐Ÿ”€ [FORK IT](https://github.com/dyne/Zenroom//fork)
2.  Create your feature branch `git checkout -b feature/branch`
3.  Commit your changes `git commit -am 'Add some fooBar'`
4.  Push to the branch `git push origin feature/branch`
5.  Create a new Pull Request `gh pr create -f`
6.  ๐Ÿ™ Thank you

***

## ๐Ÿ’ผ License

      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 <http://www.gnu.org/licenses/>.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dyne/Zenroom",
    "name": "zenroom",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8, <4",
    "maintainer_email": "",
    "keywords": "zenroom,crypto-language-processing,virtual-machine,blockchain,crypto,ecc,dyne,ecdh,ecdsa,zero-knowledge-proofs,javascript,npm,ecp2,miller-loop,hamming-distance,elgamal,aes-gcm,aead,seccomp,goldilocks",
    "author": "Danilo Spinella, David Dashyan, Puria Nafisi Azizi",
    "author_email": "danyspin@dyne.org, mail@davie.li, puria@dyne.org",
    "download_url": "https://files.pythonhosted.org/packages/05/b2/72c56b900a00ac49fae5450fa3d7434874e5cc7fda9355f56bffea6fc514/zenroom-4.0.0.tar.gz",
    "platform": null,
    "description": "# Use Zenroom in Python3\n<p align=\"center\">\n  <br/>\n  <a href=\"https://dev.zenroom.org/\">\n    <img src=\"https://dev.zenroom.org/_media/images/zenroom_logo.png\" height=\"140\" alt=\"Zenroom\">\n  </a>\n  <h2 align=\"center\">\n    zenroom.py \ud83d\udc0d\n    <br>\n    <sub>A Python3 wrapper of <a href=\"https://zenroom.org\">Zenroom</a>, a secure and small virtual machine for crypto language processing</sub> </h2>\n  \n<br><br>\n\n  <a href=\"https://travis-ci.com/dyne/zenroom-py\">\n    <img src=\"https://travis-ci.com/dyne/zenroom-py.svg?branch=master\" alt=\"Build status\"/>\n  </a>\n  <a href=\"https://codecov.io/gh/dyne/zenroom-py\">\n    <img src=\"https://codecov.io/gh/dyne/zenroom-py/branch/master/graph/badge.svg\" alt=\"Code coverage\"/>\n  </a>\n  <a href=\"https://pypi.org/project/zenroom/\">\n    <img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/zenroom.svg\" alt=\"Latest release\">\n  </a>\n</p>\n\n<hr/>\n\n\nThis library attempts to provide a very simple wrapper around the Zenroom\n(https://zenroom.dyne.org/) crypto virtual machine developed as part of the\nDECODE project (https://decodeproject.eu/), that aims to make the Zenroom\nvirtual machine easier to call from normal Python code.\n\nZenroom itself does have good cross platform functionality, so if you are\ninterested in finding out more about the functionalities offered by Zenroom,\nthen please visit the website linked to above to find out more.\n\n\n***\n## \ud83d\udcbe Installation\n\n```bash\npip install zenroom\n```\n\n**NOTE** - the above command attempts to install the zenroom package, pulling in\nthe Zenroom VM as a precompiled binary, so will only work on Linux and macOS\nmachines.\n\nfor the edge (syn to the latest commit on master) version please run:\n```bash\npip install zenroom --pre\n```\n\nThe `zenroom` package is just a wrapper around the `zencode-exec` utility.\nYou also need to install `zencode-exec`, you can download if from the official [releases on github](https://github.com/dyne/Zenroom/releases/)\n\nWhen after downloading you have to move it somewhere in your path:\n```\nsudo cp zencode-exec /usr/local/bin/\n```\n\nWarning: on Mac OS, the executable is `zencode-exec.command` and you have to symlink it to `zencode-exec`\n```\nsudo cp zencode-exec.command /usr/local/bin/\ncd /usr/local/bin\nsudo ln -s zencode-exec.command zencode-exec\n```\n\n***\n## \ud83c\udfae Usage\n\nTwo main calls are exposed, one to run `zencode` and one for `zenroom scripts`.\n\nIf you don't know what `zencode` is, you can start with this blogpost\nhttps://decodeproject.eu/blog/smart-contracts-english-speaker\nThe official documentation is available on [https://dev.zenroom.org/zencode/](https://dev.zenroom.org/zencode/)\n\nA good set of examples of `zencode` contracts could be found on\n* [zencode simple tests](https://github.com/dyne/Zenroom/tree/master/test/zencode_simple)\n* [zencode coconut tests](https://github.com/dyne/Zenroom/tree/master/test/zencode_coconut)\n\n\n### \ud83d\udc0d Python wrapper\n\nthe wrapper exposes two simple calls:\n\n* `zenroom_exec`\n* `zencode_exec`\n\nas the names suggest are the two methods to execute zenroom (lua scripts) and zencode.\n\n#### args\nBoth functions accept the same arguments:\n\n- `script` **[string](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)** the lua script or\n the zencode script to be executed\n- `keys` **[string](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)** the optional keys\n string to pass in execution as documented in zenroom docs [here](https://dev.zenroom.org/wiki/how-to-exec/#keys-string)\n- `data` **[string](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)** the optional data\n string to pass in execution as documented in zenroom docs [here](https://dev.zenroom.org/wiki/how-to-exec/#data-string)\n- `conf` **[string](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)** the optional conf\n string to pass according to zen_config [here](https://github.com/dyne/Zenroom/blob/master/src/zen_config.c#L99-L104)\n\n#### return\nBoth functions return the same object result `ZenResult` that have two attributes:\n\n- `stdout` **[string](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)** holds the stdout of the script execution\n- `stderr` **[string](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)** holds the stderr of the script execution\n\n##### Examples\n\nExample usage of `zencode_exec(script, keys=None, data=None, conf=None)`\n\n\n```python\nfrom zenroom import zenroom\n\ncontract = \"\"\"Scenario ecdh: Create a keypair\"\nGiven that I am known as 'identifier'\nWhen I create the keypair\nThen print my data\n\"\"\"\n\nresult = zenroom.zencode_exec(contract)\nprint(result.output)\n```\n\n\nExample usage of `zenroom_exec(script, keys=None, data=None, conf=None)`\n\n```python\nfrom zenroom import zenroom\n\nscript = \"print('Hello world')\"\nresult = zenroom.zenroom_exec(script)\n\nprint(result.output)\n```\n\nThe same arguments and the same result are applied as the `zencode_exec` call.\n\n***\n## \ud83d\udccb Testing\n\nTests are made with pytests, just run \n\n`python setup.py test`\n\nin [`zenroom_test.py`](https://github.com/dyne/Zenroom/blob/master/bindings/python3/tests/test_all.py) file you'll find more usage examples of the wrapper\n\n***\n## \ud83c\udf10 Links\n\nhttps://decodeproject.eu/\n\nhttps://zenroom.org/\n\nhttps://dev.zenroom.org/\n\n## \ud83d\ude0d Acknowledgements\n\nCopyright (C) 2018-2022 by [Dyne.org](https://www.dyne.org) foundation, Amsterdam\n\nOriginally designed and written by Sam Mulube.\n\nDesigned, written and maintained by Puria Nafisi Azizi \n\nRewritten by Danilo Spinella and David Dashyan\n\n<img src=\"https://ec.europa.eu/cefdigital/wiki/download/attachments/289112547/logo-cef-digital-2021.png\" width=\"310\" alt=\"Project funded by the European Commission\">\nThis project is receiving funding from the European Union\u2019s Horizon 2020 research and innovation programme under grant agreement nr. 732546 (DECODE).\n\n***\n\n## \ud83d\udc65 Contributing\nPlease first take a look at the [Dyne.org - Contributor License Agreement](CONTRIBUTING.md) then\n\n1.  \ud83d\udd00 [FORK IT](https://github.com/dyne/Zenroom//fork)\n2.  Create your feature branch `git checkout -b feature/branch`\n3.  Commit your changes `git commit -am 'Add some fooBar'`\n4.  Push to the branch `git push origin feature/branch`\n5.  Create a new Pull Request `gh pr create -f`\n6.  \ud83d\ude4f Thank you\n\n***\n\n## \ud83d\udcbc License\n\n      Zenroom.py - a python wrapper of zenroom\n      Copyright (c) 2018-2022 Dyne.org foundation, Amsterdam\n\n      This program is free software: you can redistribute it and/or modify\n      it under the terms of the GNU Affero General Public License as\n      published by the Free Software Foundation, either version 3 of the\n      License, or (at your option) any later version.\n\n      This program is distributed in the hope that it will be useful,\n      but WITHOUT ANY WARRANTY; without even the implied warranty of\n      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n      GNU Affero General Public License for more details.\n\n      You should have received a copy of the GNU Affero General Public License\n      along with this program.  If not, see <http://www.gnu.org/licenses/>.\n",
    "bugtrack_url": null,
    "license": "AGPLv3",
    "summary": "Zenroom for Python: Bindings of Zenroom library for Python.",
    "version": "4.0.0",
    "project_urls": {
        "Documentation": "https://dev.zenroom.org/",
        "Homepage": "https://zenroom.org",
        "Source Code": "https://github.com/dyne/Zenroom"
    },
    "split_keywords": [
        "zenroom",
        "crypto-language-processing",
        "virtual-machine",
        "blockchain",
        "crypto",
        "ecc",
        "dyne",
        "ecdh",
        "ecdsa",
        "zero-knowledge-proofs",
        "javascript",
        "npm",
        "ecp2",
        "miller-loop",
        "hamming-distance",
        "elgamal",
        "aes-gcm",
        "aead",
        "seccomp",
        "goldilocks"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "05b272c56b900a00ac49fae5450fa3d7434874e5cc7fda9355f56bffea6fc514",
                "md5": "a765abaada603377fedfe6f3f24d6bbb",
                "sha256": "6e3c6c83cddf5c90ce1e6f463370be705940f150d95ef1ccda40362c71fcc873"
            },
            "downloads": -1,
            "filename": "zenroom-4.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a765abaada603377fedfe6f3f24d6bbb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8, <4",
            "size": 6634,
            "upload_time": "2023-10-31T11:18:33",
            "upload_time_iso_8601": "2023-10-31T11:18:33.137165Z",
            "url": "https://files.pythonhosted.org/packages/05/b2/72c56b900a00ac49fae5450fa3d7434874e5cc7fda9355f56bffea6fc514/zenroom-4.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-31 11:18:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dyne",
    "github_project": "Zenroom",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "zenroom"
}
        
Elapsed time: 0.13323s