From 231a236da22b483286661ebae5144917c7d66c29 Mon Sep 17 00:00:00 2001 From: rgascoin Date: Mon, 12 Dec 2022 20:53:24 +0100 Subject: [PATCH 1/3] Chore: PyAleph can not validate signature comming from Polkadotjs provider. Solution: update substrate-interface from 1.1.7 to 1.2.0 --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index a0d3442ed..93c32f209 100644 --- a/setup.cfg +++ b/setup.cfg @@ -69,7 +69,7 @@ install_requires = secp256k1==0.14.0 sentry-sdk==1.5.11 setproctitle==1.2.2 - substrate-interface==1.1.7 + substrate-interface==1.2.0 ujson==5.1.0 # required by aiocache urllib3==1.26.8 uvloop==0.16.0 From aff020daa0ddccb5a6d67c8f32fdaf1ccd0b4b18 Mon Sep 17 00:00:00 2001 From: rgascoin Date: Wed, 14 Dec 2022 12:00:33 +0100 Subject: [PATCH 2/3] Chore: substrate-interface can be safely upgrade to 1.3.4 before breaking changes. --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 93c32f209..188d5e79a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -69,7 +69,7 @@ install_requires = secp256k1==0.14.0 sentry-sdk==1.5.11 setproctitle==1.2.2 - substrate-interface==1.2.0 + substrate-interface==1.3.4 ujson==5.1.0 # required by aiocache urllib3==1.26.8 uvloop==0.16.0 From 824ff04d3cecb54721587a3636c31ac4cb4f90d0 Mon Sep 17 00:00:00 2001 From: rgascoin Date: Wed, 21 Dec 2022 17:23:54 +0100 Subject: [PATCH 3/3] Feat: Add a new test with a message signed by a provider --- tests/chains/test_substrate.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/chains/test_substrate.py b/tests/chains/test_substrate.py index e476e055c..742a786c9 100644 --- a/tests/chains/test_substrate.py +++ b/tests/chains/test_substrate.py @@ -6,6 +6,8 @@ from aleph.schemas.pending_messages import parse_message TEST_MESSAGE = '{"chain": "DOT", "channel": "TEST", "sender": "5CGNMKCscqN2QNcT7Jtuz23ab7JUxh8wTEtXhECZLJn5vCGX", "type": "AGGREGATE", "item_type": "inline", "time": 1601913525.231501, "item_content": "{\\"key\\":\\"test\\",\\"address\\":\\"5CGNMKCscqN2QNcT7Jtuz23ab7JUxh8wTEtXhECZLJn5vCGX\\",\\"content\\":{\\"a\\":1},\\"time\\":1601913525.231498}", "item_hash": "bfbc94fae6336d52ab65a4d907d399a0c16222bd944b3815faa08ad0e039ca1d", "signature": "{\\"curve\\": \\"sr25519\\", \\"data\\": \\"0x1ccefb257e89b4e3ecb7d71c8dc1d6e286290b9e32d2a11bf3f9d425c5790f4bff0b324dc774d20a13e38a340d1a48fada71fb0c68690c3adb8f0cc695b0eb83\\"}", "content": {"key": "test", "address": "5CGNMKCscqN2QNcT7Jtuz23ab7JUxh8wTEtXhECZLJn5vCGX", "content": {"a": 1}, "time": 1601913525.231498}}' +TEST_MESSAGE_SIGNED_BY_PROVIDER = '{"chain": "DOT", "channel": "TEST", "sender": "5D9eKrAsfitxW48YrqMUXejcrnB2N8tLxPeFmoEZ4G74JFyz", "type": "POST", "item_type": "inline", "time": 1670865119.443, "item_content": "{\\"type\\":\\"Toolshed\\",\\"address\\":\\"5D9eKrAsfitxW48YrqMUXejcrnB2N8tLxPeFmoEZ4G74JFyz\\",\\"content\\":\\"Did the quick brown fox jump over the lazy dog?!\\",\\"time\\":1670865119.443}", "item_hash": "2f6e60df7ce1cdb2fb3be8ec09ffd20b5b781338984ff5f6f33830943f4397ba", "signature": "{\\"curve\\": \\"sr25519\\", \\"data\\": \\"0x866806b04e4cd99cd3a0f80232b8255d13c2782056a5e755fba5f233ccf8bf03a5fc2d708f8f70258b62d8e327da3a3ae6a280f1cab27eb912f125e0a1ade98a\\"}", "content": {"address": "5D9eKrAsfitxW48YrqMUXejcrnB2N8tLxPeFmoEZ4G74JFyz", "time": 1670865119.443, "content": "Did the quick brown fox jump over the lazy dog?!", "type": "Toolshed"}}' + @pytest.mark.asyncio @@ -17,6 +19,15 @@ async def test_verify_signature_real(): assert result is True +@pytest.mark.asyncio +async def test_verify_signature_from_provider(): + message_dict = json.loads(TEST_MESSAGE_SIGNED_BY_PROVIDER) + raw_message = parse_message(message_dict) + + result = await verify_signature(raw_message) + assert result is True + + @pytest.mark.asyncio async def test_verify_signature_bad_json(): message_dict = json.loads(TEST_MESSAGE)