From e8fd32fd5e65ac92b10343eebf466fe8c420b0ca Mon Sep 17 00:00:00 2001 From: Matt Gleason Date: Fri, 4 Oct 2024 16:13:34 -0400 Subject: [PATCH] SFT-4203: fixed casa signatures --- .../modules/flows/sign_electrum_message_flow.py | 2 +- .../Passport/modules/tasks/sign_text_file_task.py | 11 ++++------- ports/stm32/boards/Passport/modules/utils.py | 13 ------------- 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/ports/stm32/boards/Passport/modules/flows/sign_electrum_message_flow.py b/ports/stm32/boards/Passport/modules/flows/sign_electrum_message_flow.py index b83f3ccf8..464ba4f96 100644 --- a/ports/stm32/boards/Passport/modules/flows/sign_electrum_message_flow.py +++ b/ports/stm32/boards/Passport/modules/flows/sign_electrum_message_flow.py @@ -82,7 +82,7 @@ async def show_message(self): async def do_sign(self): (sig, address, error) = await spinner_task('Signing Message', sign_text_file_task, - args=[self.message, self.subpath, self.addr_format, True]) + args=[self.message, self.subpath, self.addr_format]) if error is None: self.signature = sig self.goto(self.show_signed) diff --git a/ports/stm32/boards/Passport/modules/tasks/sign_text_file_task.py b/ports/stm32/boards/Passport/modules/tasks/sign_text_file_task.py index ec2f9fdbb..00dcf2387 100644 --- a/ports/stm32/boards/Passport/modules/tasks/sign_text_file_task.py +++ b/ports/stm32/boards/Passport/modules/tasks/sign_text_file_task.py @@ -11,20 +11,17 @@ import stash import chains -from utils import sign_message_digest, sign_message_digest_recoverable +from utils import sign_message_digest_recoverable -async def sign_text_file_task(on_done, text, subpath, addr_fmt, recoverable=False): +async def sign_text_file_task(on_done, text, subpath, addr_fmt): with stash.SensitiveValues() as sv: node = sv.derive_path(subpath) address = sv.chain.address(node, addr_fmt) digest = chains.current_chain().hash_message(text.encode()) - if recoverable: - # signature will be 65 bytes - signature = sign_message_digest_recoverable(digest, subpath) - else: - signature = sign_message_digest(digest, subpath) + # signature will be 65 bytes + signature = sign_message_digest_recoverable(digest, subpath) await on_done(signature, address, None) diff --git a/ports/stm32/boards/Passport/modules/utils.py b/ports/stm32/boards/Passport/modules/utils.py index 259626a62..61ca11fe0 100644 --- a/ports/stm32/boards/Passport/modules/utils.py +++ b/ports/stm32/boards/Passport/modules/utils.py @@ -1038,19 +1038,6 @@ def split_to_lines(s, width): return '\n'.join([s[i:i + width] for i in range(0, len(s), width)]) -def sign_message_digest(digest, subpath): - from foundation import secp256k1 - # do the signature itself! - with stash.SensitiveValues() as sv: - node = sv.derive_path(subpath) - pk = node.private_key() - sv.register(pk) - - rv = secp256k1.sign_ecdsa(digest, pk) - - return rv - - def sign_message_digest_recoverable(digest, subpath): from trezorcrypto import ecdsa # do the signature itself!