async def layout_sign_identity(session_id, msg): from trezor.messages.SignedIdentity import SignedIdentity from ..common import coins from ..common import seed identity = serialize_identity(msg.identity) display_identity(identity, msg.challenge_visual) address_n = get_identity_path(identity, msg.identity.index or 0) node = await seed.get_root(session_id, msg.ecdsa_curve_name) node.derive_path(address_n) coin = coins.by_name('Bitcoin') if msg.ecdsa_curve_name == 'secp256k1': address = node.address(coin.address_type) # hardcoded bitcoin address type else: address = None pubkey = node.public_key() if pubkey[0] == 0x01: pubkey = b'\x00' + pubkey[1:] seckey = node.private_key() if msg.identity.proto == 'gpg': signature = sign_challenge( seckey, msg.challenge_hidden, msg.challenge_visual, 'gpg', msg.ecdsa_curve_name) elif msg.identity.proto == 'ssh': signature = sign_challenge( seckey, msg.challenge_hidden, msg.challenge_visual, 'ssh', msg.ecdsa_curve_name) else: signature = sign_challenge( seckey, msg.challenge_hidden, msg.challenge_visual, coin, msg.ecdsa_curve_name) return SignedIdentity(address=address, public_key=pubkey, signature=signature)
async def sign_identity(ctx, msg): if msg.ecdsa_curve_name is None: msg.ecdsa_curve_name = 'secp256k1' identity = serialize_identity(msg.identity) await require_confirm_sign_identity(ctx, msg.identity, msg.challenge_visual) address_n = get_identity_path(identity, msg.identity.index or 0) node = await seed.derive_node(ctx, address_n, msg.ecdsa_curve_name) coin = coins.by_name('Bitcoin') if msg.ecdsa_curve_name == 'secp256k1': address = node.address(coin.address_type) # hardcoded bitcoin address type else: address = None pubkey = node.public_key() if pubkey[0] == 0x01: pubkey = b'\x00' + pubkey[1:] seckey = node.private_key() if msg.identity.proto == 'gpg': signature = sign_challenge( seckey, msg.challenge_hidden, msg.challenge_visual, 'gpg', msg.ecdsa_curve_name) elif msg.identity.proto == 'ssh': signature = sign_challenge( seckey, msg.challenge_hidden, msg.challenge_visual, 'ssh', msg.ecdsa_curve_name) else: signature = sign_challenge( seckey, msg.challenge_hidden, msg.challenge_visual, coin, msg.ecdsa_curve_name) return SignedIdentity(address=address, public_key=pubkey, signature=signature)
async def sign_identity(ctx, msg): if msg.ecdsa_curve_name is None: msg.ecdsa_curve_name = "secp256k1" keychain = await get_keychain(ctx, msg.ecdsa_curve_name, [[]]) identity = serialize_identity(msg.identity) await require_confirm_sign_identity(ctx, msg.identity, msg.challenge_visual) address_n = get_identity_path(identity, msg.identity.index or 0) node = keychain.derive(address_n) coin = coins.by_name("Bitcoin") if msg.ecdsa_curve_name == "secp256k1": address = node.address( coin.address_type) # hardcoded bitcoin address type else: address = None pubkey = node.public_key() if pubkey[0] == 0x01: pubkey = b"\x00" + pubkey[1:] seckey = node.private_key() if msg.identity.proto == "gpg": signature = sign_challenge( seckey, msg.challenge_hidden, msg.challenge_visual, "gpg", msg.ecdsa_curve_name, ) elif msg.identity.proto == "signify": signature = sign_challenge( seckey, msg.challenge_hidden, msg.challenge_visual, "signify", msg.ecdsa_curve_name, ) elif msg.identity.proto == "ssh": signature = sign_challenge( seckey, msg.challenge_hidden, msg.challenge_visual, "ssh", msg.ecdsa_curve_name, ) else: signature = sign_challenge( seckey, msg.challenge_hidden, msg.challenge_visual, coin, msg.ecdsa_curve_name, ) return SignedIdentity(address=address, public_key=pubkey, signature=signature)
async def layout_sign_identity(session_id, msg): from trezor.messages.SignedIdentity import SignedIdentity from ..common import coins from ..common import seed identity = serialize_identity(msg.identity) display_identity(identity, msg.challenge_visual) address_n = get_identity_path(identity, msg.identity.index or 0) node = await seed.get_root(session_id, msg.ecdsa_curve_name) node.derive_path(address_n) coin = coins.by_name('Bitcoin') address = node.address(coin.address_type) # hardcoded bitcoin address type pubkey = node.public_key() seckey = node.private_key() signature = sign_challenge(seckey, msg.challenge_hidden, msg.challenge_visual, coin) return SignedIdentity(address=address, public_key=pubkey, signature=signature)