1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 04:18:10 +00:00

core: update references to keychain everywhere

This commit is contained in:
matejcik 2020-07-21 14:59:54 +02:00 committed by matejcik
parent ff4ec2185e
commit c85d768b81
35 changed files with 57 additions and 57 deletions

View File

@ -3,8 +3,8 @@ from trezor.messages.BinanceGetAddress import BinanceGetAddress
from apps.binance import CURVE, SLIP44_ID, helpers
from apps.common import paths
from apps.common.keychain import Keychain, with_slip44_keychain
from apps.common.layout import address_n_to_str, show_address, show_qr
from apps.common.seed import Keychain, with_slip44_keychain
@with_slip44_keychain(SLIP44_ID, CURVE, allow_testnet=True)

View File

@ -3,7 +3,7 @@ from trezor.messages.BinancePublicKey import BinancePublicKey
from apps.binance import CURVE, SLIP44_ID, helpers
from apps.common import layout, paths
from apps.common.seed import Keychain, with_slip44_keychain
from apps.common.keychain import Keychain, with_slip44_keychain
@with_slip44_keychain(SLIP44_ID, CURVE, allow_testnet=True)

View File

@ -10,7 +10,7 @@ from trezor.messages.BinanceTxRequest import BinanceTxRequest
from apps.binance import CURVE, SLIP44_ID, helpers, layout
from apps.common import paths
from apps.common.seed import Keychain, with_slip44_keychain
from apps.common.keychain import Keychain, with_slip44_keychain
@with_slip44_keychain(SLIP44_ID, CURVE, allow_testnet=True)

View File

@ -10,7 +10,7 @@ from .keychain import with_keychain
from .ownership import get_identifier
if False:
from apps.common.seed import Keychain
from apps.common.keychain import Keychain
@with_keychain

View File

@ -14,7 +14,7 @@ from .keychain import with_keychain
from .ownership import generate_proof, get_identifier
if False:
from apps.common.seed import Keychain
from apps.common.keychain import Keychain
# Maximum number of characters per line in monospace font.
_MAX_MONO_LINE = 18

View File

@ -3,7 +3,8 @@ from trezor.messages import InputScriptType
from trezor.messages.HDNodeType import HDNodeType
from trezor.messages.PublicKey import PublicKey
from apps.common import coins, layout, seed
from apps.common import coins, layout
from apps.common.keychain import get_keychain
async def get_public_key(ctx, msg):
@ -12,7 +13,7 @@ async def get_public_key(ctx, msg):
coin = coins.by_name(coin_name)
curve_name = msg.ecdsa_curve_name or coin.curve_name
keychain = await seed.get_keychain(ctx, [(curve_name, [])])
keychain = await get_keychain(ctx, curve_name, [[]])
node = keychain.derive(msg.address_n)

View File

@ -1,14 +1,14 @@
from trezor import wire
from apps.common import HARDENED, coininfo
from apps.common.seed import get_keychain
from apps.common.keychain import get_keychain
if False:
from protobuf import MessageType
from typing import Callable, Optional, Tuple, TypeVar
from typing_extensions import Protocol
from apps.common.seed import Keychain, MsgOut, Handler
from apps.common.keychain import Keychain, MsgOut, Handler
class MsgWithCoinName(MessageType, Protocol):
coin_name = ... # type: Optional[str]
@ -21,24 +21,21 @@ if False:
def get_namespaces_for_coin(coin: coininfo.CoinInfo):
namespaces = []
curve = coin.curve_name
slip44_id = coin.slip44 | HARDENED
# BIP-44 - legacy: m/44'/slip44' (/account'/change/addr)
namespaces.append((curve, [44 | HARDENED, slip44_id]))
namespaces.append([44 | HARDENED, slip44_id])
# BIP-45 - multisig cosigners: m/45' (/cosigner/change/addr)
namespaces.append((curve, [45 | HARDENED]))
namespaces.append([45 | HARDENED])
# "purpose48" - multisig as done by Electrum
# m/48'/slip44' (/account'/script_type'/change/addr)
namespaces.append((curve, [48 | HARDENED, slip44_id]))
namespaces.append(("slip21", [b"SLIP-0019"]))
namespaces.append([48 | HARDENED, slip44_id])
if coin.segwit:
# BIP-49 - p2sh segwit: m/49'/slip44' (/account'/change/addr)
namespaces.append((curve, [49 | HARDENED, slip44_id]))
namespaces.append([49 | HARDENED, slip44_id])
# BIP-84 - native segwit: m/84'/slip44' (/account'/change/addr)
namespaces.append((curve, [84 | HARDENED, slip44_id]))
namespaces.append([84 | HARDENED, slip44_id])
return namespaces
@ -55,7 +52,8 @@ async def get_keychain_for_coin(
raise wire.DataError("Unsupported coin type")
namespaces = get_namespaces_for_coin(coin)
keychain = await get_keychain(ctx, namespaces)
slip21_namespaces = [[b"SLIP-0019"]]
keychain = await get_keychain(ctx, coin.curve_name, namespaces, slip21_namespaces)
return keychain, coin

View File

@ -1,7 +1,7 @@
from trezor import utils, wire
from trezor.crypto import bip32, hashlib, hmac
from apps.common import seed
from apps.common.keychain import Keychain
from apps.common.readers import read_bitcoin_varint
from apps.common.writers import (
empty_bytearray,
@ -67,7 +67,7 @@ def verify_nonownership(
proof: bytes,
script_pubkey: bytes,
commitment_data: bytes,
keychain: seed.Keychain,
keychain: Keychain,
coin: CoinInfo,
) -> bool:
try:
@ -106,9 +106,9 @@ def verify_nonownership(
return not_owned
def get_identifier(script_pubkey: bytes, keychain: seed.Keychain) -> bytes:
def get_identifier(script_pubkey: bytes, keychain: Keychain) -> bytes:
# k = Key(m/"SLIP-0019"/"Ownership identification key")
node = keychain.derive(_OWNERSHIP_ID_KEY_PATH)
node = keychain.derive_slip21(_OWNERSHIP_ID_KEY_PATH)
# id = HMAC-SHA256(key = k, msg = scriptPubKey)
return hmac.Hmac(node.key(), script_pubkey, hashlib.sha256).digest()

View File

@ -10,7 +10,7 @@ from trezor.messages.TxInputType import TxInputType
from trezor.utils import HashWriter, ensure
from apps.common.coininfo import CoinInfo
from apps.common.seed import Keychain
from apps.common.keychain import Keychain
from apps.common.writers import write_bitcoin_varint
from ..common import ecdsa_hash_pubkey

View File

@ -7,7 +7,8 @@ from apps.common import mnemonic
from apps.common.passphrase import get as get_passphrase
if False:
from apps.common.seed import Bip32Path, MsgIn, MsgOut, Handler, HandlerWithKeychain
from apps.common.paths import Bip32Path
from apps.common.keychain import MsgIn, MsgOut, Handler, HandlerWithKeychain
class Keychain:

View File

@ -4,7 +4,7 @@ from trezor.messages.EosGetPublicKey import EosGetPublicKey
from trezor.messages.EosPublicKey import EosPublicKey
from apps.common import paths
from apps.common.seed import Keychain, with_slip44_keychain
from apps.common.keychain import Keychain, with_slip44_keychain
from apps.eos import CURVE, SLIP44_ID
from apps.eos.helpers import public_key_to_wif, validate_full_path
from apps.eos.layout import require_get_public_key

View File

@ -8,7 +8,7 @@ from trezor.messages.EosTxActionRequest import EosTxActionRequest
from trezor.utils import HashWriter
from apps.common import paths
from apps.common.seed import Keychain, with_slip44_keychain
from apps.common.keychain import Keychain, with_slip44_keychain
from apps.eos import CURVE, SLIP44_ID, writers
from apps.eos.actions import process_action
from apps.eos.helpers import base58_encode, validate_full_path

View File

@ -1,7 +1,7 @@
from trezor import wire
from apps.common import HARDENED, seed
from apps.common.seed import get_keychain
from apps.common.keychain import get_keychain
from . import CURVE, networks
@ -13,7 +13,7 @@ if False:
from trezor.messages.EthereumSignTx import EthereumSignTx
from apps.common.seed import MsgOut, Handler, HandlerWithKeychain
from apps.common.keychain import MsgOut, Handler, HandlerWithKeychain
class MsgWithAddressN(MessageType, Protocol):
address_n = ... # type: List[int]
@ -25,8 +25,8 @@ async def from_address_n(ctx: wire.Context, address_n: List[int]) -> seed.Keycha
slip44_hardened = address_n[1]
if slip44_hardened not in networks.all_slip44_ids_hardened():
raise wire.DataError("Forbidden key path")
namespace = CURVE, [44 | HARDENED, slip44_hardened]
return await get_keychain(ctx, [namespace])
namespace = [44 | HARDENED, slip44_hardened]
return await get_keychain(ctx, CURVE, [namespace])
def with_keychain_from_path(
@ -55,8 +55,8 @@ def with_keychain_from_chain_id(
if networks.is_wanchain(msg.chain_id, msg.tx_type):
slip44 = networks.SLIP44_WANCHAIN
namespace = CURVE, [44 | HARDENED, slip44 | HARDENED]
keychain = await get_keychain(ctx, [namespace])
namespace = [44 | HARDENED, slip44 | HARDENED]
keychain = await get_keychain(ctx, CURVE, [namespace])
with keychain:
return await func(ctx, msg, keychain)

View File

@ -1,8 +1,8 @@
from trezor.messages.LiskAddress import LiskAddress
from apps.common import paths
from apps.common.keychain import with_slip44_keychain
from apps.common.layout import address_n_to_str, show_address, show_qr
from apps.common.seed import with_slip44_keychain
from apps.lisk import CURVE, SLIP44_ID
from .helpers import get_address_from_public_key, validate_full_path

View File

@ -1,7 +1,7 @@
from trezor.messages.LiskPublicKey import LiskPublicKey
from apps.common import layout, paths
from apps.common.seed import with_slip44_keychain
from apps.common.keychain import with_slip44_keychain
from apps.lisk import CURVE, SLIP44_ID
from apps.lisk.helpers import validate_full_path

View File

@ -4,7 +4,7 @@ from trezor.messages.LiskMessageSignature import LiskMessageSignature
from trezor.utils import HashWriter
from apps.common import paths
from apps.common.seed import with_slip44_keychain
from apps.common.keychain import with_slip44_keychain
from apps.common.signverify import require_confirm_sign_message
from apps.common.writers import write_bitcoin_varint
from apps.lisk import CURVE, SLIP44_ID

View File

@ -8,7 +8,7 @@ from trezor.messages.LiskSignedTx import LiskSignedTx
from trezor.utils import HashWriter
from apps.common import paths
from apps.common.seed import with_slip44_keychain
from apps.common.keychain import with_slip44_keychain
from apps.lisk import CURVE, SLIP44_ID, layout
from apps.lisk.helpers import get_address_from_public_key, validate_full_path

View File

@ -5,11 +5,11 @@ from trezor.messages.CipheredKeyValue import CipheredKeyValue
from trezor.ui.text import Text
from apps.common.confirm import require_confirm
from apps.common.seed import get_keychain
from apps.common.keychain import get_keychain
async def cipher_key_value(ctx, msg):
keychain = await get_keychain(ctx, [("secp256k1", [])])
keychain = await get_keychain(ctx, "secp256k1", [[]])
if len(msg.value) % 16 > 0:
raise wire.DataError("Value length must be a multiple of 16")

View File

@ -8,7 +8,7 @@ from trezor.utils import chunks
from apps.common import HARDENED
from apps.common.confirm import require_confirm
from apps.common.seed import get_keychain
from apps.common.keychain import get_keychain
from .sign_identity import serialize_identity, serialize_identity_without_proto
@ -17,7 +17,7 @@ async def get_ecdh_session_key(ctx, msg):
if msg.ecdsa_curve_name is None:
msg.ecdsa_curve_name = "secp256k1"
keychain = await get_keychain(ctx, [(msg.ecdsa_curve_name, [])])
keychain = await get_keychain(ctx, msg.ecdsa_curve_name, [[]])
identity = serialize_identity(msg.identity)
await require_confirm_ecdh_session_key(ctx, msg.identity)

View File

@ -8,14 +8,14 @@ from trezor.utils import chunks
from apps.common import HARDENED, coins
from apps.common.confirm import require_confirm
from apps.common.seed import get_keychain
from apps.common.keychain import get_keychain
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, [])])
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)

View File

@ -1,8 +1,8 @@
from trezor.messages.MoneroAddress import MoneroAddress
from apps.common import paths
from apps.common.keychain import with_slip44_keychain
from apps.common.layout import address_n_to_str, show_qr
from apps.common.seed import with_slip44_keychain
from apps.monero import CURVE, SLIP44_ID, misc
from apps.monero.layout import confirms
from apps.monero.xmr import addresses, crypto, monero

View File

@ -20,7 +20,7 @@ from trezor.messages.MoneroGetTxKeyAck import MoneroGetTxKeyAck
from trezor.messages.MoneroGetTxKeyRequest import MoneroGetTxKeyRequest
from apps.common import paths
from apps.common.seed import with_slip44_keychain
from apps.common.keychain import with_slip44_keychain
from apps.monero import CURVE, SLIP44_ID, misc
from apps.monero.layout import confirms
from apps.monero.xmr import crypto

View File

@ -2,7 +2,7 @@ from trezor.messages.MoneroGetWatchKey import MoneroGetWatchKey
from trezor.messages.MoneroWatchKey import MoneroWatchKey
from apps.common import paths
from apps.common.seed import with_slip44_keychain
from apps.common.keychain import with_slip44_keychain
from apps.monero import CURVE, SLIP44_ID, misc
from apps.monero.layout import confirms
from apps.monero.xmr import crypto

View File

@ -11,7 +11,7 @@ from trezor.messages.MoneroKeyImageSyncStepAck import MoneroKeyImageSyncStepAck
from trezor.messages.MoneroKeyImageSyncStepRequest import MoneroKeyImageSyncStepRequest
from apps.common import paths
from apps.common.seed import with_slip44_keychain
from apps.common.keychain import with_slip44_keychain
from apps.monero import CURVE, SLIP44_ID, misc
from apps.monero.layout import confirms
from apps.monero.xmr import crypto, key_image, monero

View File

@ -10,7 +10,7 @@ from trezor.messages.MoneroLiveRefreshStepAck import MoneroLiveRefreshStepAck
from trezor.messages.MoneroLiveRefreshStepRequest import MoneroLiveRefreshStepRequest
from apps.common import paths
from apps.common.seed import with_slip44_keychain
from apps.common.keychain import with_slip44_keychain
from apps.monero import CURVE, SLIP44_ID, misc
from apps.monero.layout import confirms
from apps.monero.xmr import crypto, key_image, monero

View File

@ -3,7 +3,7 @@ import gc
from trezor import log, utils, wire
from trezor.messages import MessageType
from apps.common.seed import with_slip44_keychain
from apps.common.keychain import with_slip44_keychain
from apps.monero import CURVE, SLIP44_ID
from apps.monero.signing.state import State

View File

@ -1,8 +1,8 @@
from trezor.messages.NEMAddress import NEMAddress
from apps.common.keychain import with_slip44_keychain
from apps.common.layout import address_n_to_str, show_address, show_qr
from apps.common.paths import validate_path
from apps.common.seed import with_slip44_keychain
from apps.nem import CURVE, SLIP44_ID
from apps.nem.helpers import check_path, get_network_str
from apps.nem.validators import validate_network

View File

@ -4,8 +4,8 @@ from trezor.messages.NEMSignedTx import NEMSignedTx
from trezor.messages.NEMSignTx import NEMSignTx
from apps.common import seed
from apps.common.keychain import with_slip44_keychain
from apps.common.paths import validate_path
from apps.common.seed import with_slip44_keychain
from apps.nem import CURVE, SLIP44_ID, mosaic, multisig, namespace, transfer
from apps.nem.helpers import NEM_HASH_ALG, check_path
from apps.nem.validators import validate

View File

@ -2,8 +2,8 @@ from trezor.messages.RippleAddress import RippleAddress
from trezor.messages.RippleGetAddress import RippleGetAddress
from apps.common import paths
from apps.common.keychain import with_slip44_keychain
from apps.common.layout import address_n_to_str, show_address, show_qr
from apps.common.seed import with_slip44_keychain
from apps.ripple import CURVE, SLIP44_ID, helpers

View File

@ -6,7 +6,7 @@ from trezor.messages.RippleSignTx import RippleSignTx
from trezor.wire import ProcessError
from apps.common import paths
from apps.common.seed import with_slip44_keychain
from apps.common.keychain import with_slip44_keychain
from apps.ripple import CURVE, SLIP44_ID, helpers, layout
from apps.ripple.serialize import serialize

View File

@ -2,8 +2,8 @@ from trezor.messages.StellarAddress import StellarAddress
from trezor.messages.StellarGetAddress import StellarGetAddress
from apps.common import paths, seed
from apps.common.keychain import with_slip44_keychain
from apps.common.layout import address_n_to_str, show_address, show_qr
from apps.common.seed import with_slip44_keychain
from apps.stellar import CURVE, SLIP44_ID, helpers

View File

@ -8,7 +8,7 @@ from trezor.messages.StellarTxOpRequest import StellarTxOpRequest
from trezor.wire import ProcessError
from apps.common import paths, seed
from apps.common.seed import with_slip44_keychain
from apps.common.keychain import with_slip44_keychain
from apps.stellar import CURVE, SLIP44_ID, consts, helpers, layout, writers
from apps.stellar.operations import process_operation

View File

@ -2,8 +2,8 @@ from trezor.crypto import hashlib
from trezor.messages.TezosAddress import TezosAddress
from apps.common import paths, seed
from apps.common.keychain import with_slip44_keychain
from apps.common.layout import address_n_to_str, show_address, show_qr
from apps.common.seed import with_slip44_keychain
from apps.tezos import CURVE, SLIP44_ID, helpers

View File

@ -6,7 +6,7 @@ from trezor.utils import chunks
from apps.common import paths, seed
from apps.common.confirm import require_confirm
from apps.common.seed import with_slip44_keychain
from apps.common.keychain import with_slip44_keychain
from apps.tezos import CURVE, SLIP44_ID, helpers

View File

@ -7,7 +7,7 @@ from trezor.messages import TezosBallotType, TezosContractType
from trezor.messages.TezosSignedTx import TezosSignedTx
from apps.common import paths
from apps.common.seed import with_slip44_keychain
from apps.common.keychain import with_slip44_keychain
from apps.common.writers import write_bytes_unchecked, write_uint8, write_uint32_be
from apps.tezos import CURVE, SLIP44_ID, helpers, layout