Skip to content

Commit

Permalink
SFT-4203: fixed casa signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
mjg-foundation committed Oct 4, 2024
1 parent 288e73b commit e8fd32f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 4 additions & 7 deletions ports/stm32/boards/Passport/modules/tasks/sign_text_file_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
13 changes: 0 additions & 13 deletions ports/stm32/boards/Passport/modules/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down

0 comments on commit e8fd32f

Please sign in to comment.