improve usability of zenroom (#159)

* improve usability of zenroom

* * increased version
* fixed test cases
* added changelog

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>

Co-authored-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
Alberto Lerda 2022-06-27 20:55:48 +02:00 committed by GitHub
parent 5bd3784dbf
commit 4b286455e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 38 deletions

View File

@ -12,16 +12,14 @@ CONDITION_SCRIPT = """
When I create the signature of 'houses' When I create the signature of 'houses'
Then print the 'signature'""" Then print the 'signature'"""
FULFILL_SCRIPT = \ FULFILL_SCRIPT = """Scenario 'ecdh': Bob verifies the signature from Alice
"""Scenario 'ecdh': Bob verifies the signature from Alice
Given I have a 'ecdh public key' from 'Alice' Given I have a 'ecdh public key' from 'Alice'
Given that I have a 'string dictionary' named 'houses' inside 'asset' Given that I have a 'string dictionary' named 'houses' inside 'asset'
Given I have a 'signature' named 'signature' inside 'result' Given I have a 'signature' named 'signature' inside 'metadata'
When I verify the 'houses' has a signature in 'signature' by 'Alice' When I verify the 'houses' has a signature in 'signature' by 'Alice'
Then print the string 'ok'""" Then print the string 'ok'"""
SK_TO_PK = \ SK_TO_PK = """Scenario 'ecdh': Create the keypair
"""Scenario 'ecdh': Create the keypair
Given that I am known as '{}' Given that I am known as '{}'
Given I have the 'keyring' Given I have the 'keyring'
When I create the ecdh public key When I create the ecdh public key
@ -29,16 +27,13 @@ SK_TO_PK = \
Then print my 'ecdh public key' Then print my 'ecdh public key'
Then print my 'bitcoin address'""" Then print my 'bitcoin address'"""
GENERATE_KEYPAIR = \ GENERATE_KEYPAIR = """Scenario 'ecdh': Create the keypair
"""Scenario 'ecdh': Create the keypair
Given that I am known as 'Pippo' Given that I am known as 'Pippo'
When I create the ecdh key When I create the ecdh key
When I create the bitcoin key When I create the bitcoin key
Then print data""" Then print data"""
ZENROOM_DATA = { ZENROOM_DATA = {"also": "more data"}
'also': 'more data'
}
HOUSE_ASSETS = { HOUSE_ASSETS = {
"data": { "data": {
@ -50,36 +45,39 @@ HOUSE_ASSETS = {
{ {
"name": "Draco", "name": "Draco",
"team": "Slytherin", "team": "Slytherin",
} },
], ],
} }
} }
metadata = { metadata = {"units": 300, "type": "KG"}
'units': 300,
'type': 'KG'
}
@pytest.fixture @pytest.fixture
def gen_key_zencode(): def gen_key_zencode():
return GENERATE_KEYPAIR return GENERATE_KEYPAIR
@pytest.fixture @pytest.fixture
def secret_key_to_private_key_zencode(): def secret_key_to_private_key_zencode():
return SK_TO_PK return SK_TO_PK
@pytest.fixture @pytest.fixture
def fulfill_script_zencode(): def fulfill_script_zencode():
return FULFILL_SCRIPT return FULFILL_SCRIPT
@pytest.fixture @pytest.fixture
def condition_script_zencode(): def condition_script_zencode():
return CONDITION_SCRIPT return CONDITION_SCRIPT
@pytest.fixture @pytest.fixture
def zenroom_house_assets(): def zenroom_house_assets():
return HOUSE_ASSETS return HOUSE_ASSETS
@pytest.fixture @pytest.fixture
def zenroom_data(): def zenroom_data():
return ZENROOM_DATA return ZENROOM_DATA

View File

@ -12,16 +12,14 @@ CONDITION_SCRIPT = """
When I create the signature of 'houses' When I create the signature of 'houses'
Then print the 'signature'""" Then print the 'signature'"""
FULFILL_SCRIPT = \ FULFILL_SCRIPT = """Scenario 'ecdh': Bob verifies the signature from Alice
"""Scenario 'ecdh': Bob verifies the signature from Alice
Given I have a 'ecdh public key' from 'Alice' Given I have a 'ecdh public key' from 'Alice'
Given that I have a 'string dictionary' named 'houses' inside 'asset' Given that I have a 'string dictionary' named 'houses' inside 'asset'
Given I have a 'signature' named 'signature' inside 'result' Given I have a 'signature' named 'signature' inside 'metadata'
When I verify the 'houses' has a signature in 'signature' by 'Alice' When I verify the 'houses' has a signature in 'signature' by 'Alice'
Then print the string 'ok'""" Then print the string 'ok'"""
SK_TO_PK = \ SK_TO_PK = """Scenario 'ecdh': Create the keypair
"""Scenario 'ecdh': Create the keypair
Given that I am known as '{}' Given that I am known as '{}'
Given I have the 'keyring' Given I have the 'keyring'
When I create the ecdh public key When I create the ecdh public key
@ -29,16 +27,13 @@ SK_TO_PK = \
Then print my 'ecdh public key' Then print my 'ecdh public key'
Then print my 'bitcoin address'""" Then print my 'bitcoin address'"""
GENERATE_KEYPAIR = \ GENERATE_KEYPAIR = """Scenario 'ecdh': Create the keypair
"""Scenario 'ecdh': Create the keypair
Given that I am known as 'Pippo' Given that I am known as 'Pippo'
When I create the ecdh key When I create the ecdh key
When I create the bitcoin key When I create the bitcoin key
Then print data""" Then print data"""
ZENROOM_DATA = { ZENROOM_DATA = {"also": "more data"}
'also': 'more data'
}
HOUSE_ASSETS = { HOUSE_ASSETS = {
"data": { "data": {
@ -50,36 +45,39 @@ HOUSE_ASSETS = {
{ {
"name": "Draco", "name": "Draco",
"team": "Slytherin", "team": "Slytherin",
} },
], ],
} }
} }
metadata = { metadata = {"units": 300, "type": "KG"}
'units': 300,
'type': 'KG'
}
@pytest.fixture @pytest.fixture
def gen_key_zencode(): def gen_key_zencode():
return GENERATE_KEYPAIR return GENERATE_KEYPAIR
@pytest.fixture @pytest.fixture
def secret_key_to_private_key_zencode(): def secret_key_to_private_key_zencode():
return SK_TO_PK return SK_TO_PK
@pytest.fixture @pytest.fixture
def fulfill_script_zencode(): def fulfill_script_zencode():
return FULFILL_SCRIPT return FULFILL_SCRIPT
@pytest.fixture @pytest.fixture
def condition_script_zencode(): def condition_script_zencode():
return CONDITION_SCRIPT return CONDITION_SCRIPT
@pytest.fixture @pytest.fixture
def zenroom_house_assets(): def zenroom_house_assets():
return HOUSE_ASSETS return HOUSE_ASSETS
@pytest.fixture @pytest.fixture
def zenroom_data(): def zenroom_data():
return ZENROOM_DATA return ZENROOM_DATA

View File

@ -3,8 +3,8 @@
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) # SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
# Code is Apache-2.0 and docs are CC-BY-4.0 # Code is Apache-2.0 and docs are CC-BY-4.0
__version__ = '0.9.7' __version__ = "0.9.8"
__short_version__ = '0.9' __short_version__ = "0.9"
# Supported Tendermint versions # Supported Tendermint versions
__tm_supported_versions__ = ['0.34.15'] __tm_supported_versions__ = ["0.34.15"]

View File

@ -17,7 +17,7 @@ CONDITION_SCRIPT = """
FULFILL_SCRIPT = """Scenario 'ecdh': Bob verifies the signature from Alice FULFILL_SCRIPT = """Scenario 'ecdh': Bob verifies the signature from Alice
Given I have a 'ecdh public key' from 'Alice' Given I have a 'ecdh public key' from 'Alice'
Given that I have a 'string dictionary' named 'houses' inside 'asset' Given that I have a 'string dictionary' named 'houses' inside 'asset'
Given I have a 'signature' named 'signature' inside 'result' Given I have a 'signature' named 'signature' inside 'metadata'
When I verify the 'houses' has a signature in 'signature' by 'Alice' When I verify the 'houses' has a signature in 'signature' by 'Alice'
Then print the string 'ok'""" Then print the string 'ok'"""