From 64fd20b3402871cb32110a1dd2bce268efa3438a Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Tue, 19 Sep 2023 18:32:04 +0300 Subject: [PATCH] updating the signature check in register endpoint --- README.md | 4 ++-- server/oceandbs/views.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index acf9f54..d58032c 100644 --- a/README.md +++ b/README.md @@ -344,13 +344,13 @@ Stay tuned for more integrations and services. Follow the issues on github to se ## Contributing -This project is fully open-source, backed by the $OCEAN community and is obviously open for contributions. +This project is fully open-source, backed by the OCEAN community and is open for contributions. The first version has been implemented following the TDD strategy, so please first familiarize yourself with the test suite, which can be run using the `./manage.py test` command, directly from the root of your server in the context of your virtual environment. ## Authors and acknowledgment -Thanks to the $OCEAN community for the funding and the $OCEAN core team for the technical support and insights. +Thanks to the OCEAN community for the funding and the OCEAN core team for the technical support and insights. ## License diff --git a/server/oceandbs/views.py b/server/oceandbs/views.py index e968e58..9dc240a 100644 --- a/server/oceandbs/views.py +++ b/server/oceandbs/views.py @@ -23,6 +23,7 @@ from .models import Quote, Storage, File, PaymentMethod, AcceptedToken, UPLOAD_CODE from .utils import check_params_validity, upload_files_to_ipfs, upload_files_to_microservice, create_allowance from web3.auto import w3 +from eth_account.messages import encode_defunct # Storage service creation class @@ -100,7 +101,9 @@ def post(self, request): try: print(f"Received signature in request: {signature}") print(f"Received original_message in request: {original_message}") - recovered_address = w3.eth.account.recover_message(original_message, signature=signature) + message = encode_defunct(text=original_message) + print(f"Encoded message: {message}") + recovered_address = w3.eth.account.recover_message(message, signature=signature) print(f"Recovered Ethereum address: {recovered_address}") except Exception as e: print("Failed to verify the signature.")