Skip to content

Commit

Permalink
Remove keyring tag (#39)
Browse files Browse the repository at this point in the history
* removed automated "keyring" handling from ZenroomSha256.sign method
* improved sample code
* simplified dependency management
* improved github workflows
* fixed parse_asn1_dict_payload parsing issue with data or key being set to None and being converted to 'null'
* added testcases for the data and key set to None
* added testcase for script encoding/decoding
* blackified

Signed-off-by: Jürgen Eckel <[email protected]>
  • Loading branch information
eckelj authored Dec 21, 2022
1 parent b8b734e commit c34b874
Show file tree
Hide file tree
Showing 13 changed files with 221 additions and 169 deletions.
102 changes: 102 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# Planetmint and IPDB software contributors.
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
# Code is Apache-2.0 and docs are CC-BY-4.0

---
name: CI
on:
push:
branches:
- "*"
tags:
- "v*.*.*"
pull_request:
branches:
- "main"

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
with:
options: "--check -l 119"
src: "."
audit:
needs: lint
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install pip-audit
run: pip install --upgrade pip pip-audit

- name: Install dependencies
run: pip install .

- name: Create requirements.txt
run: pip freeze > requirements.txt

- name: Audit dependencies
run: pip-audit

test:
needs: lint
runs-on: ubuntu-latest

steps:
- name: Check out repository code
uses: actions/checkout@v3

- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Setup poetry
uses: Gr1N/setup-poetry@v7

- name: Install dependencies
run: poetry install --with test

- name: Run tests
run: poetry run pytest -v

release:
needs: test
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest

steps:
- name: Check out repository code
uses: actions/checkout@v3

- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Setup poetry
uses: Gr1N/setup-poetry@v7

- name: Install dependencies
run: poetry install --with dev

- name: Upload to PyPI
run: |
poetry build
poetry publish -u __token__ -p ${{ secrets.PYPI_TOKEN }}
- name: Upload to GitHub
uses: softprops/action-gh-release@v1
with:
files: dist/*
34 changes: 0 additions & 34 deletions .github/workflows/audit.yml

This file was deleted.

29 changes: 0 additions & 29 deletions .github/workflows/build-test.yml

This file was deleted.

17 changes: 0 additions & 17 deletions .github/workflows/lint.yml

This file was deleted.

36 changes: 0 additions & 36 deletions .github/workflows/tag-release.yml

This file was deleted.

37 changes: 0 additions & 37 deletions .github/workflows/unit-test.yml

This file was deleted.

7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

1.1.0 (2022-12-15)
------------------
* removed automated "keyring" handling from ZenroomSha256.sign method
* improved sample code
* simplified dependency management
* improved github workflows

1.0.0 (2022-11-28)
------------------
* support of the neweste zenroom 2.3.1
Expand Down
2 changes: 1 addition & 1 deletion docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Preimage Sha 256

.. code-block:: python
>>> from cryptoconditions import PreimageSha256
>>> from planetmint_cryptoconditions import PreimageSha256
>>> secret = b'Beware! Trying to understand crypto can lead to knowledge intoxications.'
Expand Down
8 changes: 5 additions & 3 deletions planetmint_cryptoconditions/types/zenroom.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def sign(self, message, condition_script, private_keys):
in_data, out_data = self.convert_input_message_2_data(message)
result = zencode_exec(
condition_script,
keys=json.dumps({"keyring": private_keys}),
keys=json.dumps(private_keys),
data=json.dumps(in_data),
)

Expand Down Expand Up @@ -272,8 +272,10 @@ def parse_json(self, data):

def parse_asn1_dict_payload(self, data):
self._script = data["script"].decode()
self._data = literal_eval(data["data"].decode("utf8"))
self._keys = literal_eval(data["keys"].decode("utf8"))
tmp_data = data["data"].decode("utf8") if data["data"].decode("utf8") != "null" else "None"
self._data = literal_eval(tmp_data)
tmp_keys = data["keys"].decode("utf8") if data["keys"].decode("utf8") != "null" else "None"
self._keys = literal_eval(tmp_keys)

def validate(self, *, message):
"""
Expand Down
4 changes: 2 additions & 2 deletions planetmint_cryptoconditions/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "1.0.0"
__short_version__ = "1.0"
__version__ = "1.1.0"
__short_version__ = "1.1"
Loading

0 comments on commit c34b874

Please sign in to comment.