mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-08-25 03:11:21 +00:00
Updates for signatures with keycard
This commit is contained in:
+10
-1
@@ -2,13 +2,22 @@ import keycard_wallet as keycard_wallet
|
||||
import time # For testing
|
||||
|
||||
pin = '111111'
|
||||
path0 = "m/44'/60'/0'/0/0"
|
||||
path1 = "m/44'/61'/0'/0/0"
|
||||
path2 = "m/44'/62'/0'/0/0"
|
||||
path3 = "m/44'/63'/0'/0/0"
|
||||
path4 = "m/44'/64'/0'/0/0"
|
||||
|
||||
my_wallet = keycard_wallet.KeycardWallet()
|
||||
print("Setup communication with card...", my_wallet.setup_communication(pin))
|
||||
|
||||
print("Load mnemonic...", my_wallet.load_mnemonic())
|
||||
|
||||
print("Public key", my_wallet.get_public_key_for_path())
|
||||
print("Public key", my_wallet.get_public_key_for_path(path0))
|
||||
print("Public key", my_wallet.get_public_key_for_path(path1))
|
||||
print("Public key", my_wallet.get_public_key_for_path(path2))
|
||||
print("Public key", my_wallet.get_public_key_for_path(path3))
|
||||
print("Public key", my_wallet.get_public_key_for_path(path4))
|
||||
|
||||
print("Signature", my_wallet.sign_message_for_path())
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ class KeycardWallet:
|
||||
print(f"Error during unpair: {e}")
|
||||
return False
|
||||
|
||||
def get_public_key_for_path(self, path: str = "m/44'/60'/0'/0/0") -> str | None:
|
||||
def get_public_key_for_path(self, path: str = "m/44'/60'/0'/0/0") -> bytes | None:
|
||||
try:
|
||||
if not self.card.is_secure_channel_open or not self.card.is_pin_verified:
|
||||
return None
|
||||
@@ -106,14 +106,18 @@ class KeycardWallet:
|
||||
public_only = True,
|
||||
keypath = path
|
||||
)
|
||||
# TODO (marvin) clean this up
|
||||
public_key = public_key.public_key
|
||||
public_key = VerifyingKey.from_string(public_key[1:], curve=SECP256k1)
|
||||
public_key = public_key.to_string("compressed")[1:]
|
||||
|
||||
return public_key.public_key.hex()
|
||||
return public_key
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error getting public key: {e}")
|
||||
return None
|
||||
|
||||
def sign_message_for_path(self, message: bytes = b"DefaultMessageTestDefaultMessage", path: str = "m/44'/60'/0'/0/0") -> str | None:
|
||||
def sign_message_for_path(self, message: bytes = b"DefaultMessageTestDefaultMessage", path: str = "m/44'/60'/0'/0/0") -> bytes | None:
|
||||
try:
|
||||
if not self.card.is_secure_channel_open or not self.card.is_pin_verified:
|
||||
return None
|
||||
@@ -125,7 +129,7 @@ class KeycardWallet:
|
||||
make_current = False
|
||||
)
|
||||
|
||||
return signature.signature.hex()
|
||||
return signature.signature
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error signing message: {e}")
|
||||
|
||||
Reference in New Issue
Block a user