mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-05-29 12:18:51 +00:00
style(core): apply isort 5
[no changelog]
This commit is contained in:
parent
b5c541d8fd
commit
edc2add85e
@ -11,15 +11,15 @@ from . import workflow_handlers
|
|||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor import protobuf
|
from trezor import protobuf
|
||||||
from trezor.messages import (
|
from trezor.messages import (
|
||||||
Features,
|
|
||||||
Initialize,
|
|
||||||
EndSession,
|
|
||||||
GetFeatures,
|
|
||||||
Cancel,
|
Cancel,
|
||||||
|
CancelAuthorization,
|
||||||
|
DoPreauthorized,
|
||||||
|
EndSession,
|
||||||
|
Features,
|
||||||
|
GetFeatures,
|
||||||
|
Initialize,
|
||||||
LockDevice,
|
LockDevice,
|
||||||
Ping,
|
Ping,
|
||||||
DoPreauthorized,
|
|
||||||
CancelAuthorization,
|
|
||||||
SetBusy,
|
SetBusy,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -41,10 +41,9 @@ def busy_expiry_ms() -> int:
|
|||||||
|
|
||||||
def get_features() -> Features:
|
def get_features() -> Features:
|
||||||
import storage.recovery as storage_recovery
|
import storage.recovery as storage_recovery
|
||||||
|
|
||||||
from trezor.enums import Capability
|
from trezor.enums import Capability
|
||||||
from trezor.messages import Features
|
from trezor.messages import Features
|
||||||
from trezor.ui import WIDTH, HEIGHT
|
from trezor.ui import HEIGHT, WIDTH
|
||||||
|
|
||||||
from apps.common import mnemonic, safety_checks
|
from apps.common import mnemonic, safety_checks
|
||||||
|
|
||||||
@ -206,8 +205,8 @@ async def handle_EndSession(msg: EndSession) -> Success:
|
|||||||
|
|
||||||
async def handle_Ping(msg: Ping) -> Success:
|
async def handle_Ping(msg: Ping) -> Success:
|
||||||
if msg.button_protection:
|
if msg.button_protection:
|
||||||
from trezor.ui.layouts import confirm_action
|
|
||||||
from trezor.enums import ButtonRequestType as B
|
from trezor.enums import ButtonRequestType as B
|
||||||
|
from trezor.ui.layouts import confirm_action
|
||||||
|
|
||||||
await confirm_action("ping", "Confirm", "ping", br_code=B.ProtectCall)
|
await confirm_action("ping", "Confirm", "ping", br_code=B.ProtectCall)
|
||||||
return Success(message=msg.message)
|
return Success(message=msg.message)
|
||||||
@ -216,6 +215,7 @@ async def handle_Ping(msg: Ping) -> Success:
|
|||||||
async def handle_DoPreauthorized(msg: DoPreauthorized) -> protobuf.MessageType:
|
async def handle_DoPreauthorized(msg: DoPreauthorized) -> protobuf.MessageType:
|
||||||
from trezor.messages import PreauthorizedRequest
|
from trezor.messages import PreauthorizedRequest
|
||||||
from trezor.wire.context import call_any, get_context
|
from trezor.wire.context import call_any, get_context
|
||||||
|
|
||||||
from apps.common import authorization
|
from apps.common import authorization
|
||||||
|
|
||||||
if not authorization.is_set():
|
if not authorization.is_set():
|
||||||
@ -241,6 +241,7 @@ async def handle_UnlockPath(msg: UnlockPath) -> protobuf.MessageType:
|
|||||||
from trezor.messages import UnlockedPathRequest
|
from trezor.messages import UnlockedPathRequest
|
||||||
from trezor.ui.layouts import confirm_action
|
from trezor.ui.layouts import confirm_action
|
||||||
from trezor.wire.context import call_any, get_context
|
from trezor.wire.context import call_any, get_context
|
||||||
|
|
||||||
from apps.common.paths import SLIP25_PURPOSE
|
from apps.common.paths import SLIP25_PURPOSE
|
||||||
from apps.common.seed import Slip21Node, get_seed
|
from apps.common.seed import Slip21Node, get_seed
|
||||||
from apps.common.writers import write_uint32_le
|
from apps.common.writers import write_uint32_le
|
||||||
|
@ -3,7 +3,8 @@ from typing import TYPE_CHECKING
|
|||||||
from apps.common.keychain import auto_keychain
|
from apps.common.keychain import auto_keychain
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import BinanceGetAddress, BinanceAddress
|
from trezor.messages import BinanceAddress, BinanceGetAddress
|
||||||
|
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ from apps.common.keychain import auto_keychain
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import BinanceGetPublicKey, BinancePublicKey
|
from trezor.messages import BinanceGetPublicKey, BinancePublicKey
|
||||||
|
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ def _make_input_output(input_output: BinanceInputOutput) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def produce_json_for_signing(envelope: BinanceSignTx, msg: MessageType) -> str:
|
def produce_json_for_signing(envelope: BinanceSignTx, msg: MessageType) -> str:
|
||||||
from trezor.messages import BinanceCancelMsg, BinanceOrderMsg, BinanceTransferMsg
|
|
||||||
from trezor import wire
|
from trezor import wire
|
||||||
|
from trezor.messages import BinanceCancelMsg, BinanceOrderMsg, BinanceTransferMsg
|
||||||
|
|
||||||
# NOTE: not defining kwargs in format string saves 7 bytes per each argument
|
# NOTE: not defining kwargs in format string saves 7 bytes per each argument
|
||||||
ENVELOPE_BLUEPRINT = '{{"account_number":"{}","chain_id":"{}","data":null,"memo":"{}","msgs":[{}],"sequence":"{}","source":"{}"}}'
|
ENVELOPE_BLUEPRINT = '{{"account_number":"{}","chain_id":"{}","data":null,"memo":"{}","msgs":[{}],"sequence":"{}","source":"{}"}}'
|
||||||
|
@ -3,14 +3,14 @@ from typing import TYPE_CHECKING
|
|||||||
from apps.common.keychain import auto_keychain
|
from apps.common.keychain import auto_keychain
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import BinanceSignTx, BinanceSignedTx
|
from trezor.messages import BinanceSignedTx, BinanceSignTx
|
||||||
|
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
|
|
||||||
|
|
||||||
@auto_keychain(__name__)
|
@auto_keychain(__name__)
|
||||||
async def sign_tx(envelope: BinanceSignTx, keychain: Keychain) -> BinanceSignedTx:
|
async def sign_tx(envelope: BinanceSignTx, keychain: Keychain) -> BinanceSignedTx:
|
||||||
from trezor import wire
|
from trezor import wire
|
||||||
from trezor.wire.context import call_any
|
|
||||||
from trezor.crypto.curve import secp256k1
|
from trezor.crypto.curve import secp256k1
|
||||||
from trezor.crypto.hashlib import sha256
|
from trezor.crypto.hashlib import sha256
|
||||||
from trezor.enums import MessageType
|
from trezor.enums import MessageType
|
||||||
@ -21,6 +21,7 @@ async def sign_tx(envelope: BinanceSignTx, keychain: Keychain) -> BinanceSignedT
|
|||||||
BinanceTransferMsg,
|
BinanceTransferMsg,
|
||||||
BinanceTxRequest,
|
BinanceTxRequest,
|
||||||
)
|
)
|
||||||
|
from trezor.wire.context import call_any
|
||||||
|
|
||||||
from apps.common import paths
|
from apps.common import paths
|
||||||
|
|
||||||
|
@ -11,10 +11,11 @@ from .common import ecdsa_hash_pubkey, encode_bech32_address
|
|||||||
from .scripts import output_script_native_segwit, write_output_script_multisig
|
from .scripts import output_script_native_segwit, write_output_script_multisig
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import MultisigRedeemScriptType
|
|
||||||
from trezor.crypto import bip32
|
from trezor.crypto import bip32
|
||||||
from apps.common.coininfo import CoinInfo
|
|
||||||
from trezor.enums import InputScriptType
|
from trezor.enums import InputScriptType
|
||||||
|
from trezor.messages import MultisigRedeemScriptType
|
||||||
|
|
||||||
|
from apps.common.coininfo import CoinInfo
|
||||||
|
|
||||||
|
|
||||||
def get_address(
|
def get_address(
|
||||||
@ -24,6 +25,7 @@ def get_address(
|
|||||||
multisig: MultisigRedeemScriptType | None = None,
|
multisig: MultisigRedeemScriptType | None = None,
|
||||||
) -> str:
|
) -> str:
|
||||||
from trezor.enums import InputScriptType
|
from trezor.enums import InputScriptType
|
||||||
|
|
||||||
from .multisig import multisig_get_pubkeys, multisig_pubkey_index
|
from .multisig import multisig_get_pubkeys, multisig_pubkey_index
|
||||||
|
|
||||||
node_public_key = node.public_key() # result_cache
|
node_public_key = node.public_key() # result_cache
|
||||||
|
@ -22,6 +22,7 @@ class CoinJoinAuthorization:
|
|||||||
|
|
||||||
def check_get_ownership_proof(self, msg: GetOwnershipProof) -> bool:
|
def check_get_ownership_proof(self, msg: GetOwnershipProof) -> bool:
|
||||||
from trezor import utils
|
from trezor import utils
|
||||||
|
|
||||||
from .writers import write_bytes_prefixed
|
from .writers import write_bytes_prefixed
|
||||||
|
|
||||||
params = self.params # local_cache_attribute
|
params = self.params # local_cache_attribute
|
||||||
|
@ -6,6 +6,7 @@ from .keychain import with_keychain
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import AuthorizeCoinJoin, Success
|
from trezor.messages import AuthorizeCoinJoin, Success
|
||||||
|
|
||||||
from apps.common.coininfo import CoinInfo
|
from apps.common.coininfo import CoinInfo
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
|
|
||||||
|
@ -8,10 +8,12 @@ from trezor.enums import InputScriptType, OutputScriptType
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
from apps.common.coininfo import CoinInfo
|
|
||||||
|
from trezor.crypto import bip32
|
||||||
from trezor.messages import TxInput
|
from trezor.messages import TxInput
|
||||||
from trezor.utils import HashWriter
|
from trezor.utils import HashWriter
|
||||||
from trezor.crypto import bip32
|
|
||||||
|
from apps.common.coininfo import CoinInfo
|
||||||
else:
|
else:
|
||||||
IntEnum = object
|
IntEnum = object
|
||||||
|
|
||||||
|
@ -3,9 +3,10 @@ from typing import TYPE_CHECKING
|
|||||||
from .keychain import with_keychain
|
from .keychain import with_keychain
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import GetAddress, HDNodeType, Address
|
from trezor.messages import Address, GetAddress, HDNodeType
|
||||||
from apps.common.keychain import Keychain
|
|
||||||
from apps.common.coininfo import CoinInfo
|
from apps.common.coininfo import CoinInfo
|
||||||
|
from apps.common.keychain import Keychain
|
||||||
|
|
||||||
|
|
||||||
def _get_xpubs(
|
def _get_xpubs(
|
||||||
|
@ -4,6 +4,7 @@ from .keychain import with_keychain
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import GetOwnershipId, OwnershipId
|
from trezor.messages import GetOwnershipId, OwnershipId
|
||||||
|
|
||||||
from apps.common.coininfo import CoinInfo
|
from apps.common.coininfo import CoinInfo
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
|
|
||||||
@ -12,9 +13,9 @@ if TYPE_CHECKING:
|
|||||||
async def get_ownership_id(
|
async def get_ownership_id(
|
||||||
msg: GetOwnershipId, keychain: Keychain, coin: CoinInfo
|
msg: GetOwnershipId, keychain: Keychain, coin: CoinInfo
|
||||||
) -> OwnershipId:
|
) -> OwnershipId:
|
||||||
from trezor.wire import DataError
|
|
||||||
from trezor.enums import InputScriptType
|
from trezor.enums import InputScriptType
|
||||||
from trezor.messages import OwnershipId
|
from trezor.messages import OwnershipId
|
||||||
|
from trezor.wire import DataError
|
||||||
|
|
||||||
from apps.common.paths import validate_path
|
from apps.common.paths import validate_path
|
||||||
|
|
||||||
|
@ -4,8 +4,10 @@ from .keychain import with_keychain
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import GetOwnershipProof, OwnershipProof
|
from trezor.messages import GetOwnershipProof, OwnershipProof
|
||||||
|
|
||||||
from apps.common.coininfo import CoinInfo
|
from apps.common.coininfo import CoinInfo
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
|
|
||||||
from .authorization import CoinJoinAuthorization
|
from .authorization import CoinJoinAuthorization
|
||||||
|
|
||||||
|
|
||||||
@ -16,10 +18,10 @@ async def get_ownership_proof(
|
|||||||
coin: CoinInfo,
|
coin: CoinInfo,
|
||||||
authorization: CoinJoinAuthorization | None = None,
|
authorization: CoinJoinAuthorization | None = None,
|
||||||
) -> OwnershipProof:
|
) -> OwnershipProof:
|
||||||
from trezor.wire import DataError, ProcessError
|
|
||||||
from trezor.enums import InputScriptType
|
from trezor.enums import InputScriptType
|
||||||
from trezor.messages import OwnershipProof
|
from trezor.messages import OwnershipProof
|
||||||
from trezor.ui.layouts import confirm_action, confirm_blob
|
from trezor.ui.layouts import confirm_action, confirm_blob
|
||||||
|
from trezor.wire import DataError, ProcessError
|
||||||
|
|
||||||
from apps.common.paths import validate_path
|
from apps.common.paths import validate_path
|
||||||
|
|
||||||
|
@ -11,22 +11,21 @@ from .common import BITCOIN_NAMES
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Awaitable, Callable, Iterable, TypeVar
|
from typing import Awaitable, Callable, Iterable, TypeVar
|
||||||
from typing_extensions import Protocol
|
|
||||||
|
|
||||||
from trezor.protobuf import MessageType
|
|
||||||
|
|
||||||
from trezor.messages import (
|
from trezor.messages import (
|
||||||
GetAddress,
|
GetAddress,
|
||||||
GetOwnershipId,
|
GetOwnershipId,
|
||||||
GetPublicKey,
|
|
||||||
VerifyMessage,
|
|
||||||
GetOwnershipProof,
|
GetOwnershipProof,
|
||||||
|
GetPublicKey,
|
||||||
SignTx,
|
SignTx,
|
||||||
|
VerifyMessage,
|
||||||
)
|
)
|
||||||
|
from trezor.protobuf import MessageType
|
||||||
|
from typing_extensions import Protocol
|
||||||
|
|
||||||
from apps.common.keychain import Keychain, MsgOut, Handler
|
|
||||||
from apps.common.paths import Bip32Path
|
|
||||||
from apps.common import coininfo
|
from apps.common import coininfo
|
||||||
|
from apps.common.keychain import Handler, Keychain, MsgOut
|
||||||
|
from apps.common.paths import Bip32Path
|
||||||
|
|
||||||
BitcoinMessage = (
|
BitcoinMessage = (
|
||||||
AuthorizeCoinJoin
|
AuthorizeCoinJoin
|
||||||
@ -251,9 +250,10 @@ def get_schemas_from_patterns(
|
|||||||
|
|
||||||
|
|
||||||
def _get_coin_by_name(coin_name: str | None) -> coininfo.CoinInfo:
|
def _get_coin_by_name(coin_name: str | None) -> coininfo.CoinInfo:
|
||||||
from apps.common import coininfo
|
|
||||||
from trezor import wire
|
from trezor import wire
|
||||||
|
|
||||||
|
from apps.common import coininfo
|
||||||
|
|
||||||
if coin_name is None:
|
if coin_name is None:
|
||||||
coin_name = "Bitcoin"
|
coin_name = "Bitcoin"
|
||||||
|
|
||||||
|
@ -4,12 +4,14 @@ from trezor.wire import DataError
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import HDNodeType, MultisigRedeemScriptType
|
from trezor.messages import HDNodeType, MultisigRedeemScriptType
|
||||||
|
|
||||||
from apps.common import paths
|
from apps.common import paths
|
||||||
|
|
||||||
|
|
||||||
def multisig_fingerprint(multisig: MultisigRedeemScriptType) -> bytes:
|
def multisig_fingerprint(multisig: MultisigRedeemScriptType) -> bytes:
|
||||||
from trezor.crypto.hashlib import sha256
|
from trezor.crypto.hashlib import sha256
|
||||||
from trezor.utils import HashWriter
|
from trezor.utils import HashWriter
|
||||||
|
|
||||||
from .writers import write_bytes_fixed, write_uint32
|
from .writers import write_bytes_fixed, write_uint32
|
||||||
|
|
||||||
if multisig.nodes:
|
if multisig.nodes:
|
||||||
|
@ -12,10 +12,11 @@ from apps.common.readers import read_compact_size
|
|||||||
from .scripts import read_bip322_signature_proof
|
from .scripts import read_bip322_signature_proof
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import MultisigRedeemScriptType
|
|
||||||
from trezor.enums import InputScriptType
|
|
||||||
from apps.common.coininfo import CoinInfo
|
|
||||||
from trezor.crypto import bip32
|
from trezor.crypto import bip32
|
||||||
|
from trezor.enums import InputScriptType
|
||||||
|
from trezor.messages import MultisigRedeemScriptType
|
||||||
|
|
||||||
|
from apps.common.coininfo import CoinInfo
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
|
|
||||||
# This module implements the SLIP-0019 proof of ownership format, see
|
# This module implements the SLIP-0019 proof of ownership format, see
|
||||||
@ -39,13 +40,11 @@ def generate_proof(
|
|||||||
commitment_data: bytes,
|
commitment_data: bytes,
|
||||||
) -> tuple[bytes, bytes]:
|
) -> tuple[bytes, bytes]:
|
||||||
from trezor.enums import InputScriptType
|
from trezor.enums import InputScriptType
|
||||||
from apps.bitcoin.writers import (
|
|
||||||
write_bytes_fixed,
|
from apps.bitcoin.writers import write_bytes_fixed, write_compact_size, write_uint8
|
||||||
write_compact_size,
|
|
||||||
write_uint8,
|
|
||||||
)
|
|
||||||
from .scripts import write_bip322_signature_proof
|
|
||||||
from . import common
|
from . import common
|
||||||
|
from .scripts import write_bip322_signature_proof
|
||||||
|
|
||||||
flags = 0
|
flags = 0
|
||||||
if user_confirmed:
|
if user_confirmed:
|
||||||
|
@ -38,8 +38,8 @@ def write_input_script_prefixed(
|
|||||||
pubkey: bytes,
|
pubkey: bytes,
|
||||||
signature: bytes,
|
signature: bytes,
|
||||||
) -> None:
|
) -> None:
|
||||||
from trezor.crypto.hashlib import sha256
|
|
||||||
from trezor import wire
|
from trezor import wire
|
||||||
|
from trezor.crypto.hashlib import sha256
|
||||||
|
|
||||||
IST = InputScriptType # local_cache_global
|
IST = InputScriptType # local_cache_global
|
||||||
|
|
||||||
@ -79,6 +79,7 @@ def write_input_script_prefixed(
|
|||||||
|
|
||||||
def output_derive_script(address: str, coin: CoinInfo) -> bytes:
|
def output_derive_script(address: str, coin: CoinInfo) -> bytes:
|
||||||
from trezor.crypto import base58, cashaddr
|
from trezor.crypto import base58, cashaddr
|
||||||
|
|
||||||
from apps.common import address_type
|
from apps.common import address_type
|
||||||
|
|
||||||
if coin.bech32_prefix and address.startswith(coin.bech32_prefix):
|
if coin.bech32_prefix and address.startswith(coin.bech32_prefix):
|
||||||
|
@ -14,8 +14,8 @@ from .scripts import ( # noqa: F401
|
|||||||
from .writers import write_compact_size
|
from .writers import write_compact_size
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import MultisigRedeemScriptType
|
|
||||||
from trezor.enums import InputScriptType
|
from trezor.enums import InputScriptType
|
||||||
|
from trezor.messages import MultisigRedeemScriptType
|
||||||
|
|
||||||
from apps.common.coininfo import CoinInfo
|
from apps.common.coininfo import CoinInfo
|
||||||
|
|
||||||
@ -34,6 +34,7 @@ def write_input_script_prefixed(
|
|||||||
) -> None:
|
) -> None:
|
||||||
from trezor import wire
|
from trezor import wire
|
||||||
from trezor.enums import InputScriptType
|
from trezor.enums import InputScriptType
|
||||||
|
|
||||||
from .multisig import multisig_pubkey_index
|
from .multisig import multisig_pubkey_index
|
||||||
|
|
||||||
if script_type == InputScriptType.SPENDADDRESS:
|
if script_type == InputScriptType.SPENDADDRESS:
|
||||||
|
@ -3,7 +3,7 @@ from typing import TYPE_CHECKING
|
|||||||
from .keychain import with_keychain
|
from .keychain import with_keychain
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import SignMessage, MessageSignature
|
from trezor.messages import MessageSignature, SignMessage
|
||||||
|
|
||||||
from apps.common.coininfo import CoinInfo
|
from apps.common.coininfo import CoinInfo
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
|
@ -5,9 +5,10 @@ from trezor import utils
|
|||||||
from ..keychain import with_keychain
|
from ..keychain import with_keychain
|
||||||
|
|
||||||
if not utils.BITCOIN_ONLY:
|
if not utils.BITCOIN_ONLY:
|
||||||
from . import bitcoinlike, decred, zcash_v4
|
|
||||||
from apps.zcash.signer import Zcash
|
from apps.zcash.signer import Zcash
|
||||||
|
|
||||||
|
from . import bitcoinlike, decred, zcash_v4
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Protocol
|
from typing import Protocol
|
||||||
|
|
||||||
@ -15,18 +16,18 @@ if TYPE_CHECKING:
|
|||||||
SignTx,
|
SignTx,
|
||||||
TxAckInput,
|
TxAckInput,
|
||||||
TxAckOutput,
|
TxAckOutput,
|
||||||
TxAckPrevMeta,
|
|
||||||
TxAckPrevInput,
|
|
||||||
TxAckPrevOutput,
|
|
||||||
TxAckPrevExtraData,
|
TxAckPrevExtraData,
|
||||||
|
TxAckPrevInput,
|
||||||
|
TxAckPrevMeta,
|
||||||
|
TxAckPrevOutput,
|
||||||
TxRequest,
|
TxRequest,
|
||||||
)
|
)
|
||||||
|
|
||||||
from apps.common.coininfo import CoinInfo
|
from apps.common.coininfo import CoinInfo
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
|
|
||||||
from . import approvers
|
|
||||||
from ..authorization import CoinJoinAuthorization
|
from ..authorization import CoinJoinAuthorization
|
||||||
|
from . import approvers
|
||||||
|
|
||||||
TxAckType = (
|
TxAckType = (
|
||||||
TxAckInput
|
TxAckInput
|
||||||
|
@ -17,14 +17,14 @@ from .tx_info import OriginalTxInfo
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.crypto import bip32
|
from trezor.crypto import bip32
|
||||||
from trezor.messages import SignTx, TxInput, TxOutput, TxAckPaymentRequest
|
from trezor.messages import SignTx, TxAckPaymentRequest, TxInput, TxOutput
|
||||||
|
|
||||||
from apps.common.coininfo import CoinInfo
|
from apps.common.coininfo import CoinInfo
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
|
|
||||||
from ..authorization import CoinJoinAuthorization
|
from ..authorization import CoinJoinAuthorization
|
||||||
from .tx_info import TxInfo
|
|
||||||
from .payment_request import PaymentRequestVerifier
|
from .payment_request import PaymentRequestVerifier
|
||||||
|
from .tx_info import TxInfo
|
||||||
|
|
||||||
|
|
||||||
# An Approver object computes the transaction totals and either prompts the user
|
# An Approver object computes the transaction totals and either prompts the user
|
||||||
|
@ -23,23 +23,15 @@ if TYPE_CHECKING:
|
|||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
|
|
||||||
from trezor.crypto import bip32
|
from trezor.crypto import bip32
|
||||||
|
from trezor.messages import PrevInput, PrevOutput, PrevTx, SignTx, TxInput, TxOutput
|
||||||
from trezor.messages import (
|
|
||||||
PrevInput,
|
|
||||||
PrevOutput,
|
|
||||||
PrevTx,
|
|
||||||
SignTx,
|
|
||||||
TxInput,
|
|
||||||
TxOutput,
|
|
||||||
)
|
|
||||||
|
|
||||||
from apps.common.coininfo import CoinInfo
|
from apps.common.coininfo import CoinInfo
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
|
|
||||||
|
from ..writers import Writer
|
||||||
from . import approvers
|
from . import approvers
|
||||||
from .sig_hasher import SigHasher
|
from .sig_hasher import SigHasher
|
||||||
from .tx_info import TxInfo
|
from .tx_info import TxInfo
|
||||||
from ..writers import Writer
|
|
||||||
|
|
||||||
|
|
||||||
# the number of bytes to preallocate for serialized transaction chunks
|
# the number of bytes to preallocate for serialized transaction chunks
|
||||||
@ -110,6 +102,7 @@ class Bitcoin:
|
|||||||
TxRequestDetailsType,
|
TxRequestDetailsType,
|
||||||
TxRequestSerializedType,
|
TxRequestSerializedType,
|
||||||
)
|
)
|
||||||
|
|
||||||
from . import approvers
|
from . import approvers
|
||||||
from .tx_info import TxInfo
|
from .tx_info import TxInfo
|
||||||
|
|
||||||
|
@ -6,13 +6,16 @@ from .bitcoin import Bitcoin
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
|
|
||||||
from trezor.messages import PrevTx, SignTx, TxInput
|
from trezor.messages import PrevTx, SignTx, TxInput
|
||||||
|
|
||||||
from .tx_info import OriginalTxInfo, TxInfo
|
from .tx_info import OriginalTxInfo, TxInfo
|
||||||
|
|
||||||
|
|
||||||
class Bitcoinlike(Bitcoin):
|
class Bitcoinlike(Bitcoin):
|
||||||
async def sign_nonsegwit_bip143_input(self, i_sign: int) -> None:
|
async def sign_nonsegwit_bip143_input(self, i_sign: int) -> None:
|
||||||
from trezor import wire
|
from trezor import wire
|
||||||
|
|
||||||
from .. import multisig
|
from .. import multisig
|
||||||
from ..common import NONSEGWIT_INPUT_SCRIPT_TYPES
|
from ..common import NONSEGWIT_INPUT_SCRIPT_TYPES
|
||||||
|
|
||||||
|
@ -29,22 +29,15 @@ if TYPE_CHECKING:
|
|||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
|
|
||||||
from trezor.crypto import bip32
|
from trezor.crypto import bip32
|
||||||
from trezor.messages import (
|
from trezor.messages import PrevInput, PrevOutput, PrevTx, SignTx, TxInput, TxOutput
|
||||||
SignTx,
|
|
||||||
TxInput,
|
|
||||||
TxOutput,
|
|
||||||
PrevTx,
|
|
||||||
PrevInput,
|
|
||||||
PrevOutput,
|
|
||||||
)
|
|
||||||
|
|
||||||
from apps.common.coininfo import CoinInfo
|
from apps.common.coininfo import CoinInfo
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
|
|
||||||
from .sig_hasher import SigHasher
|
|
||||||
from . import approvers
|
|
||||||
from ..common import SigHashType
|
from ..common import SigHashType
|
||||||
from ..writers import Writer
|
from ..writers import Writer
|
||||||
|
from . import approvers
|
||||||
|
from .sig_hasher import SigHasher
|
||||||
|
|
||||||
|
|
||||||
# Decred input size (without script): 32 prevhash, 4 idx, 1 Decred tree, 4 sequence
|
# Decred input size (without script): 32 prevhash, 4 idx, 1 Decred tree, 4 sequence
|
||||||
@ -213,9 +206,10 @@ class Decred(Bitcoin):
|
|||||||
|
|
||||||
async def step4_serialize_inputs(self) -> None:
|
async def step4_serialize_inputs(self) -> None:
|
||||||
from trezor.enums import DecredStakingSpendType
|
from trezor.enums import DecredStakingSpendType
|
||||||
|
|
||||||
|
from .. import multisig
|
||||||
from ..common import SigHashType, ecdsa_sign
|
from ..common import SigHashType, ecdsa_sign
|
||||||
from .progress import progress
|
from .progress import progress
|
||||||
from .. import multisig
|
|
||||||
|
|
||||||
inputs_count = self.tx_info.tx.inputs_count # local_cache_attribute
|
inputs_count = self.tx_info.tx.inputs_count # local_cache_attribute
|
||||||
coin = self.coin # local_cache_attribute
|
coin = self.coin # local_cache_attribute
|
||||||
|
@ -10,18 +10,19 @@ from . import layout
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Any, Awaitable
|
from typing import Any, Awaitable
|
||||||
from trezor.enums import AmountUnit
|
|
||||||
|
|
||||||
|
from trezor.enums import AmountUnit
|
||||||
from trezor.messages import (
|
from trezor.messages import (
|
||||||
PrevInput,
|
PrevInput,
|
||||||
PrevOutput,
|
PrevOutput,
|
||||||
PrevTx,
|
PrevTx,
|
||||||
SignTx,
|
SignTx,
|
||||||
|
TxAckPaymentRequest,
|
||||||
TxInput,
|
TxInput,
|
||||||
TxOutput,
|
TxOutput,
|
||||||
TxRequest,
|
TxRequest,
|
||||||
TxAckPaymentRequest,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from apps.common.coininfo import CoinInfo
|
from apps.common.coininfo import CoinInfo
|
||||||
from apps.common.paths import Bip32Path
|
from apps.common.paths import Bip32Path
|
||||||
|
|
||||||
|
@ -19,9 +19,9 @@ from ..keychain import address_n_to_name
|
|||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from trezor.enums import AmountUnit
|
||||||
from trezor.messages import TxAckPaymentRequest, TxOutput
|
from trezor.messages import TxAckPaymentRequest, TxOutput
|
||||||
from trezor.ui.layouts import LayoutType
|
from trezor.ui.layouts import LayoutType
|
||||||
from trezor.enums import AmountUnit
|
|
||||||
|
|
||||||
from apps.common.coininfo import CoinInfo
|
from apps.common.coininfo import CoinInfo
|
||||||
from apps.common.paths import Bip32Path
|
from apps.common.paths import Bip32Path
|
||||||
@ -63,9 +63,10 @@ async def confirm_output(
|
|||||||
amount_unit: AmountUnit,
|
amount_unit: AmountUnit,
|
||||||
output_index: int,
|
output_index: int,
|
||||||
) -> None:
|
) -> None:
|
||||||
from . import omni
|
|
||||||
from trezor.enums import OutputScriptType
|
from trezor.enums import OutputScriptType
|
||||||
|
|
||||||
|
from . import omni
|
||||||
|
|
||||||
if output.script_type == OutputScriptType.PAYTOOPRETURN:
|
if output.script_type == OutputScriptType.PAYTOOPRETURN:
|
||||||
data = output.op_return_data
|
data = output.op_return_data
|
||||||
assert data is not None
|
assert data is not None
|
||||||
|
@ -111,6 +111,7 @@ class ScriptTypeChecker(MatchChecker):
|
|||||||
def attribute_from_tx(self, txio: TxInput | TxOutput) -> Any:
|
def attribute_from_tx(self, txio: TxInput | TxOutput) -> Any:
|
||||||
from trezor.enums import InputScriptType
|
from trezor.enums import InputScriptType
|
||||||
from trezor.messages import TxOutput
|
from trezor.messages import TxOutput
|
||||||
|
|
||||||
from ..common import CHANGE_OUTPUT_TO_INPUT_SCRIPT_TYPES
|
from ..common import CHANGE_OUTPUT_TO_INPUT_SCRIPT_TYPES
|
||||||
|
|
||||||
if TxOutput.is_type_of(txio):
|
if TxOutput.is_type_of(txio):
|
||||||
|
@ -16,6 +16,7 @@ def is_valid(data: bytes) -> bool:
|
|||||||
|
|
||||||
def parse(data: bytes) -> str:
|
def parse(data: bytes) -> str:
|
||||||
from ustruct import unpack
|
from ustruct import unpack
|
||||||
|
|
||||||
from trezor.strings import format_amount
|
from trezor.strings import format_amount
|
||||||
|
|
||||||
if not is_valid(data):
|
if not is_valid(data):
|
||||||
|
@ -7,6 +7,7 @@ from .. import writers
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import TxAckPaymentRequest, TxOutput
|
from trezor.messages import TxAckPaymentRequest, TxOutput
|
||||||
|
|
||||||
from apps.common import coininfo
|
from apps.common import coininfo
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
|
|
||||||
@ -28,7 +29,9 @@ class PaymentRequestVerifier:
|
|||||||
from storage import cache
|
from storage import cache
|
||||||
from trezor.crypto.hashlib import sha256
|
from trezor.crypto.hashlib import sha256
|
||||||
from trezor.utils import HashWriter
|
from trezor.utils import HashWriter
|
||||||
|
|
||||||
from apps.common.address_mac import check_address_mac
|
from apps.common.address_mac import check_address_mac
|
||||||
|
|
||||||
from .. import writers # pylint: disable=import-outside-toplevel
|
from .. import writers # pylint: disable=import-outside-toplevel
|
||||||
|
|
||||||
self.h_outputs = HashWriter(sha256())
|
self.h_outputs = HashWriter(sha256())
|
||||||
|
@ -2,7 +2,9 @@ from typing import TYPE_CHECKING
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import SignTx
|
from trezor.messages import SignTx
|
||||||
|
|
||||||
from apps.common.coininfo import CoinInfo
|
from apps.common.coininfo import CoinInfo
|
||||||
|
|
||||||
from .tx_info import OriginalTxInfo
|
from .tx_info import OriginalTxInfo
|
||||||
|
|
||||||
# Checking previous transactions typically requires the following pieces of
|
# Checking previous transactions typically requires the following pieces of
|
||||||
|
@ -10,10 +10,13 @@ from ..writers import (
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Protocol, Sequence
|
from typing import Protocol, Sequence
|
||||||
from ..common import SigHashType
|
|
||||||
from trezor.messages import PrevTx, SignTx, TxInput, TxOutput
|
from trezor.messages import PrevTx, SignTx, TxInput, TxOutput
|
||||||
|
|
||||||
from apps.common import coininfo
|
from apps.common import coininfo
|
||||||
|
|
||||||
|
from ..common import SigHashType
|
||||||
|
|
||||||
class SigHasher(Protocol):
|
class SigHasher(Protocol):
|
||||||
def add_input(self, txi: TxInput, script_pubkey: bytes) -> None:
|
def add_input(self, txi: TxInput, script_pubkey: bytes) -> None:
|
||||||
...
|
...
|
||||||
@ -85,6 +88,7 @@ class BitcoinSigHasher:
|
|||||||
) -> bytes:
|
) -> bytes:
|
||||||
from trezor.crypto.hashlib import sha256
|
from trezor.crypto.hashlib import sha256
|
||||||
from trezor.utils import HashWriter
|
from trezor.utils import HashWriter
|
||||||
|
|
||||||
from .. import scripts
|
from .. import scripts
|
||||||
from ..writers import get_tx_hash
|
from ..writers import get_tx_hash
|
||||||
|
|
||||||
|
@ -5,17 +5,14 @@ from .. import common, writers
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Protocol
|
from typing import Protocol
|
||||||
from trezor.messages import (
|
|
||||||
PrevTx,
|
from trezor.messages import PrevTx, SignTx, TxInput, TxOutput
|
||||||
SignTx,
|
|
||||||
TxInput,
|
|
||||||
TxOutput,
|
|
||||||
)
|
|
||||||
from trezor.utils import HashWriter
|
from trezor.utils import HashWriter
|
||||||
from .sig_hasher import SigHasher
|
|
||||||
|
|
||||||
from apps.common.coininfo import CoinInfo
|
from apps.common.coininfo import CoinInfo
|
||||||
|
|
||||||
|
from .sig_hasher import SigHasher
|
||||||
|
|
||||||
class Signer(Protocol):
|
class Signer(Protocol):
|
||||||
coin: CoinInfo
|
coin: CoinInfo
|
||||||
|
|
||||||
@ -58,10 +55,11 @@ class TxInfoBase:
|
|||||||
def __init__(self, signer: Signer, tx: SignTx | PrevTx) -> None:
|
def __init__(self, signer: Signer, tx: SignTx | PrevTx) -> None:
|
||||||
from trezor.crypto.hashlib import sha256
|
from trezor.crypto.hashlib import sha256
|
||||||
from trezor.utils import HashWriter
|
from trezor.utils import HashWriter
|
||||||
|
|
||||||
from .matchcheck import (
|
from .matchcheck import (
|
||||||
MultisigFingerprintChecker,
|
MultisigFingerprintChecker,
|
||||||
WalletPathChecker,
|
|
||||||
ScriptTypeChecker,
|
ScriptTypeChecker,
|
||||||
|
WalletPathChecker,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Checksum of multisig inputs, used to validate change-output.
|
# Checksum of multisig inputs, used to validate change-output.
|
||||||
|
@ -9,15 +9,18 @@ from ..writers import TX_HASH_SIZE, write_bytes_reversed, write_uint32, write_ui
|
|||||||
from .bitcoinlike import Bitcoinlike
|
from .bitcoinlike import Bitcoinlike
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
from typing import Sequence
|
||||||
|
|
||||||
from trezor.messages import PrevTx, SignTx, TxInput, TxOutput
|
from trezor.messages import PrevTx, SignTx, TxInput, TxOutput
|
||||||
|
|
||||||
from apps.common.coininfo import CoinInfo
|
from apps.common.coininfo import CoinInfo
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
from . import approvers
|
|
||||||
from typing import Sequence
|
|
||||||
from .sig_hasher import SigHasher
|
|
||||||
from .tx_info import OriginalTxInfo, TxInfo
|
|
||||||
from ..common import SigHashType
|
from ..common import SigHashType
|
||||||
from ..writers import Writer
|
from ..writers import Writer
|
||||||
|
from . import approvers
|
||||||
|
from .sig_hasher import SigHasher
|
||||||
|
from .tx_info import OriginalTxInfo, TxInfo
|
||||||
|
|
||||||
_OVERWINTERED = const(0x8000_0000)
|
_OVERWINTERED = const(0x8000_0000)
|
||||||
|
|
||||||
@ -48,6 +51,7 @@ class Zip243SigHasher:
|
|||||||
hash_type: int,
|
hash_type: int,
|
||||||
) -> bytes:
|
) -> bytes:
|
||||||
import ustruct as struct
|
import ustruct as struct
|
||||||
|
|
||||||
from ..scripts import write_bip143_script_code_prefixed
|
from ..scripts import write_bip143_script_code_prefixed
|
||||||
from ..writers import get_tx_hash, write_bytes_fixed
|
from ..writers import get_tx_hash, write_bytes_fixed
|
||||||
|
|
||||||
@ -135,6 +139,7 @@ class ZcashV4(Bitcoinlike):
|
|||||||
|
|
||||||
async def step7_finish(self) -> None:
|
async def step7_finish(self) -> None:
|
||||||
from apps.common.writers import write_compact_size
|
from apps.common.writers import write_compact_size
|
||||||
|
|
||||||
from . import helpers
|
from . import helpers
|
||||||
|
|
||||||
serialized_tx = self.serialized_tx # local_cache_attribute
|
serialized_tx = self.serialized_tx # local_cache_attribute
|
||||||
|
@ -4,7 +4,9 @@ from trezor.wire import DataError
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
|
|
||||||
from apps.common.coininfo import CoinInfo
|
from apps.common.coininfo import CoinInfo
|
||||||
|
|
||||||
from .common import SigHashType
|
from .common import SigHashType
|
||||||
|
|
||||||
|
|
||||||
@ -17,8 +19,8 @@ class SignatureVerifier:
|
|||||||
coin: CoinInfo,
|
coin: CoinInfo,
|
||||||
):
|
):
|
||||||
from trezor import utils
|
from trezor import utils
|
||||||
from trezor.wire import DataError # local_cache_global
|
|
||||||
from trezor.crypto.hashlib import sha256
|
from trezor.crypto.hashlib import sha256
|
||||||
|
from trezor.wire import DataError # local_cache_global
|
||||||
|
|
||||||
from .common import OP_0, OP_1, SigHashType, ecdsa_hash_pubkey
|
from .common import OP_0, OP_1, SigHashType, ecdsa_hash_pubkey
|
||||||
from .scripts import (
|
from .scripts import (
|
||||||
|
@ -1,17 +1,20 @@
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from apps.common.coininfo import CoinInfo
|
|
||||||
from trezor.messages import VerifyMessage, Success
|
|
||||||
from trezor.enums import InputScriptType
|
from trezor.enums import InputScriptType
|
||||||
|
from trezor.messages import Success, VerifyMessage
|
||||||
|
|
||||||
|
from apps.common.coininfo import CoinInfo
|
||||||
|
|
||||||
|
|
||||||
def _address_to_script_type(address: str, coin: CoinInfo) -> InputScriptType:
|
def _address_to_script_type(address: str, coin: CoinInfo) -> InputScriptType:
|
||||||
from trezor.crypto import base58
|
|
||||||
from trezor.wire import DataError
|
|
||||||
from trezor.enums import InputScriptType
|
|
||||||
from trezor import utils
|
from trezor import utils
|
||||||
|
from trezor.crypto import base58
|
||||||
|
from trezor.enums import InputScriptType
|
||||||
|
from trezor.wire import DataError
|
||||||
|
|
||||||
from apps.common import address_type
|
from apps.common import address_type
|
||||||
|
|
||||||
from . import common
|
from . import common
|
||||||
|
|
||||||
# Determines the script type from a non-multisig address.
|
# Determines the script type from a non-multisig address.
|
||||||
@ -49,11 +52,11 @@ def _address_to_script_type(address: str, coin: CoinInfo) -> InputScriptType:
|
|||||||
|
|
||||||
async def verify_message(msg: VerifyMessage) -> Success:
|
async def verify_message(msg: VerifyMessage) -> Success:
|
||||||
from trezor import utils
|
from trezor import utils
|
||||||
from trezor.wire import ProcessError
|
|
||||||
from trezor.crypto.curve import secp256k1
|
from trezor.crypto.curve import secp256k1
|
||||||
from trezor.enums import InputScriptType
|
from trezor.enums import InputScriptType
|
||||||
from trezor.messages import Success
|
from trezor.messages import Success
|
||||||
from trezor.ui.layouts import confirm_signverify, show_success
|
from trezor.ui.layouts import confirm_signverify, show_success
|
||||||
|
from trezor.wire import ProcessError
|
||||||
|
|
||||||
from apps.common import coins
|
from apps.common import coins
|
||||||
from apps.common.signverify import decode_message, message_digest
|
from apps.common.signverify import decode_message, message_digest
|
||||||
|
@ -15,12 +15,7 @@ from apps.common.writers import ( # noqa: F401
|
|||||||
)
|
)
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import (
|
from trezor.messages import PrevInput, PrevOutput, TxInput, TxOutput
|
||||||
PrevInput,
|
|
||||||
PrevOutput,
|
|
||||||
TxInput,
|
|
||||||
TxOutput,
|
|
||||||
)
|
|
||||||
from trezor.utils import HashWriter
|
from trezor.utils import HashWriter
|
||||||
|
|
||||||
from apps.common.writers import Writer
|
from apps.common.writers import Writer
|
||||||
|
@ -12,7 +12,9 @@ from .helpers.utils import get_public_key_hash
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from trezor import messages
|
from trezor import messages
|
||||||
|
|
||||||
from .seed import Keychain
|
from .seed import Keychain
|
||||||
|
|
||||||
|
|
||||||
|
@ -205,8 +205,8 @@ def get_hash_and_supplement(
|
|||||||
protocol_magic: int,
|
protocol_magic: int,
|
||||||
network_id: int,
|
network_id: int,
|
||||||
) -> tuple[bytes, messages.CardanoTxAuxiliaryDataSupplement]:
|
) -> tuple[bytes, messages.CardanoTxAuxiliaryDataSupplement]:
|
||||||
from trezor.enums import CardanoTxAuxiliaryDataSupplementType
|
|
||||||
from trezor import messages
|
from trezor import messages
|
||||||
|
from trezor.enums import CardanoTxAuxiliaryDataSupplementType
|
||||||
|
|
||||||
if parameters := auxiliary_data.cvote_registration_parameters:
|
if parameters := auxiliary_data.cvote_registration_parameters:
|
||||||
(
|
(
|
||||||
|
@ -11,6 +11,7 @@ if TYPE_CHECKING:
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from trezor import messages
|
from trezor import messages
|
||||||
|
|
||||||
from apps.common.cbor import CborSequence
|
from apps.common.cbor import CborSequence
|
||||||
|
|
||||||
from . import seed
|
from . import seed
|
||||||
|
@ -3,19 +3,20 @@ from typing import TYPE_CHECKING
|
|||||||
from . import seed
|
from . import seed
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import CardanoGetAddress, CardanoAddress
|
from trezor.messages import CardanoAddress, CardanoGetAddress
|
||||||
|
|
||||||
|
|
||||||
@seed.with_keychain
|
@seed.with_keychain
|
||||||
async def get_address(
|
async def get_address(
|
||||||
msg: CardanoGetAddress, keychain: seed.Keychain
|
msg: CardanoGetAddress, keychain: seed.Keychain
|
||||||
) -> CardanoAddress:
|
) -> CardanoAddress:
|
||||||
from trezor.messages import CardanoAddress
|
|
||||||
from trezor import log, wire
|
from trezor import log, wire
|
||||||
|
from trezor.messages import CardanoAddress
|
||||||
|
|
||||||
|
from . import addresses
|
||||||
from .helpers.credential import Credential, should_show_credentials
|
from .helpers.credential import Credential, should_show_credentials
|
||||||
from .helpers.utils import validate_network_info
|
from .helpers.utils import validate_network_info
|
||||||
from .layout import show_cardano_address, show_credentials
|
from .layout import show_cardano_address, show_credentials
|
||||||
from . import addresses
|
|
||||||
|
|
||||||
address_parameters = msg.address_parameters # local_cache_attribute
|
address_parameters = msg.address_parameters # local_cache_attribute
|
||||||
|
|
||||||
|
@ -10,8 +10,9 @@ if TYPE_CHECKING:
|
|||||||
async def get_native_script_hash(
|
async def get_native_script_hash(
|
||||||
msg: CardanoGetNativeScriptHash, keychain: seed.Keychain
|
msg: CardanoGetNativeScriptHash, keychain: seed.Keychain
|
||||||
) -> CardanoNativeScriptHash:
|
) -> CardanoNativeScriptHash:
|
||||||
from trezor.messages import CardanoNativeScriptHash
|
|
||||||
from trezor.enums import CardanoNativeScriptHashDisplayFormat
|
from trezor.enums import CardanoNativeScriptHashDisplayFormat
|
||||||
|
from trezor.messages import CardanoNativeScriptHash
|
||||||
|
|
||||||
from . import layout, native_script
|
from . import layout, native_script
|
||||||
|
|
||||||
native_script.validate_native_script(msg.script)
|
native_script.validate_native_script(msg.script)
|
||||||
|
@ -13,7 +13,9 @@ async def get_public_key(
|
|||||||
) -> CardanoPublicKey:
|
) -> CardanoPublicKey:
|
||||||
from trezor import log, wire
|
from trezor import log, wire
|
||||||
from trezor.ui.layouts import show_pubkey
|
from trezor.ui.layouts import show_pubkey
|
||||||
|
|
||||||
from apps.common import paths
|
from apps.common import paths
|
||||||
|
|
||||||
from .helpers.paths import SCHEMA_MINT, SCHEMA_PUBKEY
|
from .helpers.paths import SCHEMA_MINT, SCHEMA_PUBKEY
|
||||||
|
|
||||||
address_n = msg.address_n # local_cache_attribute
|
address_n = msg.address_n # local_cache_attribute
|
||||||
@ -40,8 +42,9 @@ async def get_public_key(
|
|||||||
def _get_public_key(
|
def _get_public_key(
|
||||||
keychain: seed.Keychain, derivation_path: list[int]
|
keychain: seed.Keychain, derivation_path: list[int]
|
||||||
) -> CardanoPublicKey:
|
) -> CardanoPublicKey:
|
||||||
|
from trezor.messages import CardanoPublicKey, HDNodeType
|
||||||
|
|
||||||
from .helpers.utils import derive_public_key
|
from .helpers.utils import derive_public_key
|
||||||
from trezor.messages import HDNodeType, CardanoPublicKey
|
|
||||||
|
|
||||||
node = keychain.derive(derivation_path)
|
node = keychain.derive(derivation_path)
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@ if TYPE_CHECKING:
|
|||||||
CardanoPoolOwner,
|
CardanoPoolOwner,
|
||||||
CardanoTxCertificate,
|
CardanoTxCertificate,
|
||||||
CardanoTxOutput,
|
CardanoTxOutput,
|
||||||
CardanoTxWitnessRequest,
|
|
||||||
CardanoTxWithdrawal,
|
CardanoTxWithdrawal,
|
||||||
|
CardanoTxWitnessRequest,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ from apps.common import cbor
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Any, Generic, TypeVar
|
from typing import Any, Generic, TypeVar
|
||||||
|
|
||||||
from trezor import wire
|
from trezor import wire
|
||||||
from trezor.utils import HashContext
|
from trezor.utils import HashContext
|
||||||
|
|
||||||
|
@ -6,9 +6,10 @@ from . import ADDRESS_KEY_HASH_SIZE, bech32
|
|||||||
from .paths import ACCOUNT_PATH_INDEX
|
from .paths import ACCOUNT_PATH_INDEX
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .. import seed
|
|
||||||
from trezor.wire import ProcessError
|
from trezor.wire import ProcessError
|
||||||
|
|
||||||
|
from .. import seed
|
||||||
|
|
||||||
|
|
||||||
def variable_length_encode(number: int) -> bytes:
|
def variable_length_encode(number: int) -> bytes:
|
||||||
"""
|
"""
|
||||||
@ -104,6 +105,7 @@ def validate_network_info(network_id: int, protocol_magic: int) -> None:
|
|||||||
consistency between various testnets (at least for now).
|
consistency between various testnets (at least for now).
|
||||||
"""
|
"""
|
||||||
from trezor import wire
|
from trezor import wire
|
||||||
|
|
||||||
from . import network_ids, protocol_magics
|
from . import network_ids, protocol_magics
|
||||||
|
|
||||||
is_mainnet_network_id = network_ids.is_mainnet(network_id)
|
is_mainnet_network_id = network_ids.is_mainnet(network_id)
|
||||||
|
@ -5,6 +5,7 @@ from trezor.wire import ProcessError
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from trezor import messages
|
from trezor import messages
|
||||||
|
|
||||||
from apps.common.cbor import CborSequence
|
from apps.common.cbor import CborSequence
|
||||||
@ -13,9 +14,9 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
|
|
||||||
def validate_native_script(script: messages.CardanoNativeScript | None) -> None:
|
def validate_native_script(script: messages.CardanoNativeScript | None) -> None:
|
||||||
|
from . import seed
|
||||||
from .helpers import ADDRESS_KEY_HASH_SIZE
|
from .helpers import ADDRESS_KEY_HASH_SIZE
|
||||||
from .helpers.paths import SCHEMA_MINT
|
from .helpers.paths import SCHEMA_MINT
|
||||||
from . import seed
|
|
||||||
|
|
||||||
INVALID_NATIVE_SCRIPT = ProcessError("Invalid native script")
|
INVALID_NATIVE_SCRIPT = ProcessError("Invalid native script")
|
||||||
|
|
||||||
@ -120,10 +121,12 @@ def _validate_native_script_structure(script: messages.CardanoNativeScript) -> N
|
|||||||
def get_native_script_hash(
|
def get_native_script_hash(
|
||||||
keychain: seed.Keychain, script: messages.CardanoNativeScript
|
keychain: seed.Keychain, script: messages.CardanoNativeScript
|
||||||
) -> bytes:
|
) -> bytes:
|
||||||
from .helpers import SCRIPT_HASH_SIZE
|
|
||||||
from trezor.crypto import hashlib
|
from trezor.crypto import hashlib
|
||||||
|
|
||||||
from apps.common import cbor
|
from apps.common import cbor
|
||||||
|
|
||||||
|
from .helpers import SCRIPT_HASH_SIZE
|
||||||
|
|
||||||
script_cbor = cbor.encode(cborize_native_script(keychain, script))
|
script_cbor = cbor.encode(cborize_native_script(keychain, script))
|
||||||
prefixed_script_cbor = b"\00" + script_cbor
|
prefixed_script_cbor = b"\00" + script_cbor
|
||||||
return hashlib.blake2b(data=prefixed_script_cbor, outlen=SCRIPT_HASH_SIZE).digest()
|
return hashlib.blake2b(data=prefixed_script_cbor, outlen=SCRIPT_HASH_SIZE).digest()
|
||||||
|
@ -10,14 +10,14 @@ from apps.common.seed import get_seed
|
|||||||
from .helpers.paths import BYRON_ROOT, MINTING_ROOT, MULTISIG_ROOT, SHELLEY_ROOT
|
from .helpers.paths import BYRON_ROOT, MINTING_ROOT, MULTISIG_ROOT, SHELLEY_ROOT
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Callable, Awaitable, TypeVar
|
from typing import Awaitable, Callable, TypeVar
|
||||||
|
|
||||||
from apps.common.paths import Bip32Path
|
|
||||||
from apps.common.keychain import MsgOut, Handler
|
|
||||||
|
|
||||||
from trezor import messages
|
from trezor import messages
|
||||||
from trezor.enums import CardanoDerivationType
|
|
||||||
from trezor.crypto import bip32
|
from trezor.crypto import bip32
|
||||||
|
from trezor.enums import CardanoDerivationType
|
||||||
|
|
||||||
|
from apps.common.keychain import Handler, MsgOut
|
||||||
|
from apps.common.paths import Bip32Path
|
||||||
|
|
||||||
CardanoMessages = (
|
CardanoMessages = (
|
||||||
messages.CardanoGetAddress
|
messages.CardanoGetAddress
|
||||||
@ -137,9 +137,10 @@ def derive_and_store_secrets(passphrase: str) -> None:
|
|||||||
|
|
||||||
|
|
||||||
async def _get_keychain_bip39(derivation_type: CardanoDerivationType) -> Keychain:
|
async def _get_keychain_bip39(derivation_type: CardanoDerivationType) -> Keychain:
|
||||||
from apps.common.seed import derive_and_store_roots
|
|
||||||
from trezor.enums import CardanoDerivationType
|
from trezor.enums import CardanoDerivationType
|
||||||
|
|
||||||
|
from apps.common.seed import derive_and_store_roots
|
||||||
|
|
||||||
if not device.is_initialized():
|
if not device.is_initialized():
|
||||||
raise wire.NotInitialized("Device is not initialized")
|
raise wire.NotInitialized("Device is not initialized")
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ from .. import seed
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Type
|
from typing import Type
|
||||||
|
|
||||||
from trezor.messages import CardanoSignTxFinished, CardanoSignTxInit
|
from trezor.messages import CardanoSignTxFinished, CardanoSignTxInit
|
||||||
|
|
||||||
|
|
||||||
@ -11,9 +12,9 @@ if TYPE_CHECKING:
|
|||||||
async def sign_tx(
|
async def sign_tx(
|
||||||
msg: CardanoSignTxInit, keychain: seed.Keychain
|
msg: CardanoSignTxInit, keychain: seed.Keychain
|
||||||
) -> CardanoSignTxFinished:
|
) -> CardanoSignTxFinished:
|
||||||
from trezor.messages import CardanoSignTxFinished
|
|
||||||
from trezor import log, wire
|
from trezor import log, wire
|
||||||
from trezor.enums import CardanoTxSigningMode
|
from trezor.enums import CardanoTxSigningMode
|
||||||
|
from trezor.messages import CardanoSignTxFinished
|
||||||
|
|
||||||
from .signer import Signer
|
from .signer import Signer
|
||||||
|
|
||||||
|
@ -75,11 +75,7 @@ class OrdinarySigner(Signer):
|
|||||||
raise ProcessError("Invalid witness request")
|
raise ProcessError("Invalid witness request")
|
||||||
|
|
||||||
async def _show_witness_request(self, witness_path: list[int]) -> None:
|
async def _show_witness_request(self, witness_path: list[int]) -> None:
|
||||||
from ..helpers.paths import (
|
from ..helpers.paths import SCHEMA_PAYMENT, SCHEMA_STAKING, WITNESS_PATH_NAME
|
||||||
SCHEMA_PAYMENT,
|
|
||||||
SCHEMA_STAKING,
|
|
||||||
WITNESS_PATH_NAME,
|
|
||||||
)
|
|
||||||
|
|
||||||
# super() omitted intentionally
|
# super() omitted intentionally
|
||||||
# We only allow payment, staking or minting paths.
|
# We only allow payment, staking or minting paths.
|
||||||
|
@ -22,9 +22,11 @@ from ..helpers.utils import derive_public_key
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Any, Awaitable, ClassVar
|
from typing import Any, Awaitable, ClassVar
|
||||||
|
|
||||||
from trezor.enums import CardanoAddressType
|
from trezor.enums import CardanoAddressType
|
||||||
from apps.common.paths import PathSchema
|
|
||||||
from apps.common import cbor
|
from apps.common import cbor
|
||||||
|
from apps.common.paths import PathSchema
|
||||||
|
|
||||||
from ..helpers.hash_builder_collection import HashBuilderEmbeddedCBOR
|
from ..helpers.hash_builder_collection import HashBuilderEmbeddedCBOR
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ def check_address_mac(
|
|||||||
|
|
||||||
def get_address_mac(address: str, slip44: int, keychain: Keychain) -> bytes:
|
def get_address_mac(address: str, slip44: int, keychain: Keychain) -> bytes:
|
||||||
from trezor.crypto import hmac
|
from trezor.crypto import hmac
|
||||||
|
|
||||||
from .writers import write_bytes_unchecked, write_compact_size, write_uint32_le
|
from .writers import write_bytes_unchecked, write_compact_size, write_uint32_le
|
||||||
|
|
||||||
# k = Key(m/"SLIP-0024"/"Address MAC key")
|
# k = Key(m/"SLIP-0024"/"Address MAC key")
|
||||||
|
@ -9,6 +9,7 @@ from trezor import log
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Any, Generic, Iterator, TypeVar
|
from typing import Any, Generic, Iterator, TypeVar
|
||||||
|
|
||||||
from trezor.utils import BufferReader
|
from trezor.utils import BufferReader
|
||||||
|
|
||||||
K = TypeVar("K")
|
K = TypeVar("K")
|
||||||
|
@ -6,16 +6,11 @@ from trezor.wire import DataError
|
|||||||
from . import paths, safety_checks
|
from . import paths, safety_checks
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import (
|
from typing import Any, Awaitable, Callable, Iterable, TypeVar
|
||||||
Any,
|
|
||||||
Awaitable,
|
|
||||||
Callable,
|
|
||||||
Iterable,
|
|
||||||
TypeVar,
|
|
||||||
)
|
|
||||||
from typing_extensions import Protocol
|
|
||||||
|
|
||||||
from trezor.protobuf import MessageType
|
from trezor.protobuf import MessageType
|
||||||
|
from typing_extensions import Protocol
|
||||||
|
|
||||||
from .seed import Slip21Node
|
from .seed import Slip21Node
|
||||||
|
|
||||||
T = TypeVar("T")
|
T = TypeVar("T")
|
||||||
|
@ -5,15 +5,8 @@ HARDENED = const(0x8000_0000)
|
|||||||
SLIP25_PURPOSE = const(10025 | HARDENED)
|
SLIP25_PURPOSE = const(10025 | HARDENED)
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import (
|
from typing import Any, Callable, Collection, Container, Iterable, Sequence, TypeVar
|
||||||
Any,
|
|
||||||
Callable,
|
|
||||||
Collection,
|
|
||||||
Container,
|
|
||||||
Iterable,
|
|
||||||
Sequence,
|
|
||||||
TypeVar,
|
|
||||||
)
|
|
||||||
from typing_extensions import Protocol
|
from typing_extensions import Protocol
|
||||||
|
|
||||||
Bip32Path = Sequence[int]
|
Bip32Path = Sequence[int]
|
||||||
|
@ -16,7 +16,7 @@ async def _request_sd_salt(
|
|||||||
if not utils.USE_SD_CARD:
|
if not utils.USE_SD_CARD:
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
from .sdcard import request_sd_salt, SdCardUnavailable
|
from .sdcard import SdCardUnavailable, request_sd_salt
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return await request_sd_salt()
|
return await request_sd_salt()
|
||||||
@ -49,7 +49,7 @@ async def request_pin(
|
|||||||
|
|
||||||
|
|
||||||
async def request_pin_confirm(*args: Any, **kwargs: Any) -> str:
|
async def request_pin_confirm(*args: Any, **kwargs: Any) -> str:
|
||||||
from trezor.ui.layouts import pin_mismatch_popup, confirm_reenter_pin
|
from trezor.ui.layouts import confirm_reenter_pin, pin_mismatch_popup
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
pin1 = await request_pin("Enter new PIN", *args, **kwargs)
|
pin1 = await request_pin("Enter new PIN", *args, **kwargs)
|
||||||
|
@ -9,9 +9,10 @@ from . import mnemonic
|
|||||||
from .passphrase import get as get_passphrase
|
from .passphrase import get as get_passphrase
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .paths import Bip32Path, Slip21Path
|
|
||||||
from trezor.crypto import bip32
|
from trezor.crypto import bip32
|
||||||
|
|
||||||
|
from .paths import Bip32Path, Slip21Path
|
||||||
|
|
||||||
|
|
||||||
class Slip21Node:
|
class Slip21Node:
|
||||||
"""
|
"""
|
||||||
|
@ -4,36 +4,31 @@ if not __debug__:
|
|||||||
halt("debug mode inactive")
|
halt("debug mode inactive")
|
||||||
|
|
||||||
if __debug__:
|
if __debug__:
|
||||||
from storage import debug as storage
|
from typing import TYPE_CHECKING
|
||||||
from storage.debug import debug_events
|
|
||||||
|
|
||||||
import trezorui2
|
import trezorui2
|
||||||
|
from storage import debug as storage
|
||||||
|
from storage.debug import debug_events
|
||||||
from trezor import log, loop, utils, wire
|
from trezor import log, loop, utils, wire
|
||||||
|
from trezor.enums import MessageType
|
||||||
|
from trezor.messages import DebugLinkLayout, Success
|
||||||
from trezor.ui import display
|
from trezor.ui import display
|
||||||
from trezor.wire import context
|
from trezor.wire import context
|
||||||
from trezor.enums import MessageType
|
|
||||||
from trezor.messages import (
|
|
||||||
DebugLinkLayout,
|
|
||||||
Success,
|
|
||||||
)
|
|
||||||
|
|
||||||
from apps import workflow_handlers
|
from apps import workflow_handlers
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.ui import Layout
|
|
||||||
from trezor.messages import (
|
from trezor.messages import (
|
||||||
DebugLinkDecision,
|
DebugLinkDecision,
|
||||||
DebugLinkEraseSdCard,
|
DebugLinkEraseSdCard,
|
||||||
DebugLinkGetState,
|
DebugLinkGetState,
|
||||||
DebugLinkRecordScreen,
|
DebugLinkRecordScreen,
|
||||||
DebugLinkReseedRandom,
|
DebugLinkReseedRandom,
|
||||||
|
DebugLinkResetDebugEvents,
|
||||||
DebugLinkState,
|
DebugLinkState,
|
||||||
DebugLinkWatchLayout,
|
DebugLinkWatchLayout,
|
||||||
DebugLinkResetDebugEvents,
|
|
||||||
)
|
)
|
||||||
|
from trezor.ui import Layout
|
||||||
|
|
||||||
swipe_chan = loop.chan()
|
swipe_chan = loop.chan()
|
||||||
result_chan = loop.chan()
|
result_chan = loop.chan()
|
||||||
@ -194,6 +189,7 @@ if __debug__:
|
|||||||
msg: DebugLinkGetState,
|
msg: DebugLinkGetState,
|
||||||
) -> DebugLinkState | None:
|
) -> DebugLinkState | None:
|
||||||
from trezor.messages import DebugLinkState
|
from trezor.messages import DebugLinkState
|
||||||
|
|
||||||
from apps.common import mnemonic, passphrase
|
from apps.common import mnemonic, passphrase
|
||||||
|
|
||||||
m = DebugLinkState()
|
m = DebugLinkState()
|
||||||
|
@ -10,9 +10,10 @@ async def load_device(msg: LoadDevice) -> Success:
|
|||||||
from trezor.crypto import bip39, slip39
|
from trezor.crypto import bip39, slip39
|
||||||
from trezor.enums import BackupType
|
from trezor.enums import BackupType
|
||||||
from trezor.messages import Success
|
from trezor.messages import Success
|
||||||
from apps.management import backup_types
|
|
||||||
from trezor.wire import UnexpectedMessage, ProcessError
|
|
||||||
from trezor.ui.layouts import confirm_action
|
from trezor.ui.layouts import confirm_action
|
||||||
|
from trezor.wire import ProcessError, UnexpectedMessage
|
||||||
|
|
||||||
|
from apps.management import backup_types
|
||||||
|
|
||||||
mnemonics = msg.mnemonics # local_cache_attribute
|
mnemonics = msg.mnemonics # local_cache_attribute
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.utils import Writer, HashWriter
|
|
||||||
from trezor.messages import EosTxActionAck
|
from trezor.messages import EosTxActionAck
|
||||||
|
from trezor.utils import HashWriter, Writer
|
||||||
|
|
||||||
|
|
||||||
async def process_action(
|
async def process_action(
|
||||||
@ -86,9 +86,10 @@ async def process_action(
|
|||||||
|
|
||||||
async def _process_unknown_action(w: Writer, action: EosTxActionAck) -> None:
|
async def _process_unknown_action(w: Writer, action: EosTxActionAck) -> None:
|
||||||
from trezor.crypto.hashlib import sha256
|
from trezor.crypto.hashlib import sha256
|
||||||
from trezor.utils import HashWriter
|
|
||||||
from trezor.messages import EosTxActionAck, EosTxActionRequest
|
from trezor.messages import EosTxActionAck, EosTxActionRequest
|
||||||
|
from trezor.utils import HashWriter
|
||||||
from trezor.wire.context import call
|
from trezor.wire.context import call
|
||||||
|
|
||||||
from .. import writers
|
from .. import writers
|
||||||
from . import layout
|
from . import layout
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ from ..helpers import eos_asset_to_string, eos_name_to_string
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Iterable
|
from typing import Iterable
|
||||||
|
|
||||||
from trezor.messages import (
|
from trezor.messages import (
|
||||||
EosActionBuyRam,
|
EosActionBuyRam,
|
||||||
EosActionBuyRamBytes,
|
EosActionBuyRamBytes,
|
||||||
@ -254,6 +255,7 @@ async def confirm_action_unknown(action: EosActionCommon, checksum: bytes) -> No
|
|||||||
|
|
||||||
def authorization_fields(auth: EosAuthorization) -> list[PropertyType]:
|
def authorization_fields(auth: EosAuthorization) -> list[PropertyType]:
|
||||||
from trezor.wire import DataError
|
from trezor.wire import DataError
|
||||||
|
|
||||||
from ..helpers import public_key_to_wif
|
from ..helpers import public_key_to_wif
|
||||||
|
|
||||||
fields: list[PropertyType] = []
|
fields: list[PropertyType] = []
|
||||||
|
@ -4,6 +4,7 @@ from apps.common.keychain import auto_keychain
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import EosGetPublicKey, EosPublicKey
|
from trezor.messages import EosGetPublicKey, EosPublicKey
|
||||||
|
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
|
|
||||||
|
|
||||||
@ -11,7 +12,9 @@ if TYPE_CHECKING:
|
|||||||
async def get_public_key(msg: EosGetPublicKey, keychain: Keychain) -> EosPublicKey:
|
async def get_public_key(msg: EosGetPublicKey, keychain: Keychain) -> EosPublicKey:
|
||||||
from trezor.crypto.curve import secp256k1
|
from trezor.crypto.curve import secp256k1
|
||||||
from trezor.messages import EosPublicKey
|
from trezor.messages import EosPublicKey
|
||||||
|
|
||||||
from apps.common import paths
|
from apps.common import paths
|
||||||
|
|
||||||
from .helpers import public_key_to_wif
|
from .helpers import public_key_to_wif
|
||||||
from .layout import require_get_public_key
|
from .layout import require_get_public_key
|
||||||
|
|
||||||
|
@ -3,23 +3,26 @@ from typing import TYPE_CHECKING
|
|||||||
from apps.common.keychain import auto_keychain
|
from apps.common.keychain import auto_keychain
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import EosSignTx, EosSignedTx
|
from trezor.messages import EosSignedTx, EosSignTx
|
||||||
|
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
|
|
||||||
|
|
||||||
@auto_keychain(__name__)
|
@auto_keychain(__name__)
|
||||||
async def sign_tx(msg: EosSignTx, keychain: Keychain) -> EosSignedTx:
|
async def sign_tx(msg: EosSignTx, keychain: Keychain) -> EosSignedTx:
|
||||||
from trezor.wire import DataError
|
|
||||||
from trezor.wire.context import call
|
|
||||||
from trezor.crypto.curve import secp256k1
|
from trezor.crypto.curve import secp256k1
|
||||||
from trezor.crypto.hashlib import sha256
|
from trezor.crypto.hashlib import sha256
|
||||||
from trezor.messages import EosSignedTx, EosTxActionAck, EosTxActionRequest
|
from trezor.messages import EosSignedTx, EosTxActionAck, EosTxActionRequest
|
||||||
from trezor.utils import HashWriter
|
from trezor.utils import HashWriter
|
||||||
|
from trezor.wire import DataError
|
||||||
|
from trezor.wire.context import call
|
||||||
|
|
||||||
from apps.common import paths
|
from apps.common import paths
|
||||||
from .writers import write_uvarint, write_header, write_bytes_fixed
|
|
||||||
from .actions import process_action
|
from .actions import process_action
|
||||||
from .helpers import base58_encode
|
from .helpers import base58_encode
|
||||||
from .layout import require_sign_tx
|
from .layout import require_sign_tx
|
||||||
|
from .writers import write_bytes_fixed, write_header, write_uvarint
|
||||||
|
|
||||||
num_actions = msg.num_actions # local_cache_attribute
|
num_actions = msg.num_actions # local_cache_attribute
|
||||||
|
|
||||||
|
@ -18,12 +18,12 @@ if TYPE_CHECKING:
|
|||||||
EosActionDelegate,
|
EosActionDelegate,
|
||||||
EosActionDeleteAuth,
|
EosActionDeleteAuth,
|
||||||
EosActionLinkAuth,
|
EosActionLinkAuth,
|
||||||
EosActionUnlinkAuth,
|
|
||||||
EosActionNewAccount,
|
EosActionNewAccount,
|
||||||
EosActionRefund,
|
EosActionRefund,
|
||||||
EosActionSellRam,
|
EosActionSellRam,
|
||||||
EosActionTransfer,
|
EosActionTransfer,
|
||||||
EosActionUndelegate,
|
EosActionUndelegate,
|
||||||
|
EosActionUnlinkAuth,
|
||||||
EosActionUpdateAuth,
|
EosActionUpdateAuth,
|
||||||
EosActionVoteProducer,
|
EosActionVoteProducer,
|
||||||
EosAsset,
|
EosAsset,
|
||||||
|
@ -5,6 +5,7 @@ from trezor.wire import DataError
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import TypeVar
|
from typing import TypeVar
|
||||||
|
|
||||||
from typing_extensions import Self
|
from typing_extensions import Self
|
||||||
|
|
||||||
DefType = TypeVar("DefType", EthereumNetworkInfo, EthereumTokenInfo)
|
DefType = TypeVar("DefType", EthereumNetworkInfo, EthereumTokenInfo)
|
||||||
@ -18,6 +19,7 @@ def decode_definition(definition: bytes, expected_type: type[DefType]) -> DefTyp
|
|||||||
from trezor.utils import BufferReader
|
from trezor.utils import BufferReader
|
||||||
|
|
||||||
from apps.common import readers
|
from apps.common import readers
|
||||||
|
|
||||||
from . import definitions_constants as consts
|
from . import definitions_constants as consts
|
||||||
|
|
||||||
# check network definition
|
# check network definition
|
||||||
@ -142,7 +144,7 @@ class Definitions:
|
|||||||
return cls(network, tokens)
|
return cls(network, tokens)
|
||||||
|
|
||||||
def get_token(self, address: bytes) -> EthereumTokenInfo:
|
def get_token(self, address: bytes) -> EthereumTokenInfo:
|
||||||
from .tokens import token_by_chain_address, UNKNOWN_TOKEN
|
from .tokens import UNKNOWN_TOKEN, token_by_chain_address
|
||||||
|
|
||||||
# if we have a built-in definition, use it
|
# if we have a built-in definition, use it
|
||||||
token = token_by_chain_address(self.network.chain_id, address)
|
token = token_by_chain_address(self.network.chain_id, address)
|
||||||
|
@ -3,9 +3,10 @@ from typing import TYPE_CHECKING
|
|||||||
from .keychain import PATTERNS_ADDRESS, with_keychain_from_path
|
from .keychain import PATTERNS_ADDRESS, with_keychain_from_path
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import EthereumGetAddress, EthereumAddress
|
from trezor.messages import EthereumAddress, EthereumGetAddress
|
||||||
|
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
|
|
||||||
from .definitions import Definitions
|
from .definitions import Definitions
|
||||||
|
|
||||||
|
|
||||||
@ -17,7 +18,9 @@ async def get_address(
|
|||||||
) -> EthereumAddress:
|
) -> EthereumAddress:
|
||||||
from trezor.messages import EthereumAddress
|
from trezor.messages import EthereumAddress
|
||||||
from trezor.ui.layouts import show_address
|
from trezor.ui.layouts import show_address
|
||||||
|
|
||||||
from apps.common import paths
|
from apps.common import paths
|
||||||
|
|
||||||
from .helpers import address_from_bytes
|
from .helpers import address_from_bytes
|
||||||
|
|
||||||
address_n = msg.address_n # local_cache_attribute
|
address_n = msg.address_n # local_cache_attribute
|
||||||
|
@ -6,8 +6,10 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
async def get_public_key(msg: EthereumGetPublicKey) -> EthereumPublicKey:
|
async def get_public_key(msg: EthereumGetPublicKey) -> EthereumPublicKey:
|
||||||
from ubinascii import hexlify
|
from ubinascii import hexlify
|
||||||
|
|
||||||
from trezor.messages import EthereumPublicKey, GetPublicKey
|
from trezor.messages import EthereumPublicKey, GetPublicKey
|
||||||
from trezor.ui.layouts import show_pubkey
|
from trezor.ui.layouts import show_pubkey
|
||||||
|
|
||||||
from apps.bitcoin import get_public_key as bitcoin_get_public_key
|
from apps.bitcoin import get_public_key as bitcoin_get_public_key
|
||||||
|
|
||||||
# we use the Bitcoin format for Ethereum xpubs
|
# we use the Bitcoin format for Ethereum xpubs
|
||||||
|
@ -5,6 +5,7 @@ from . import networks
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import EthereumFieldType
|
from trezor.messages import EthereumFieldType
|
||||||
|
|
||||||
from .networks import EthereumNetworkInfo
|
from .networks import EthereumNetworkInfo
|
||||||
|
|
||||||
|
|
||||||
@ -49,6 +50,7 @@ def address_from_bytes(
|
|||||||
|
|
||||||
def bytes_from_address(address: str) -> bytes:
|
def bytes_from_address(address: str) -> bytes:
|
||||||
from ubinascii import unhexlify
|
from ubinascii import unhexlify
|
||||||
|
|
||||||
from trezor import wire
|
from trezor import wire
|
||||||
|
|
||||||
if len(address) == 40:
|
if len(address) == 40:
|
||||||
|
@ -10,8 +10,6 @@ from . import CURVE, definitions, networks
|
|||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Any, Awaitable, Callable, Iterable, TypeVar
|
from typing import Any, Awaitable, Callable, Iterable, TypeVar
|
||||||
|
|
||||||
from apps.common.keychain import Keychain
|
|
||||||
|
|
||||||
from trezor.messages import (
|
from trezor.messages import (
|
||||||
EthereumGetAddress,
|
EthereumGetAddress,
|
||||||
EthereumSignMessage,
|
EthereumSignMessage,
|
||||||
@ -20,10 +18,7 @@ if TYPE_CHECKING:
|
|||||||
EthereumSignTypedData,
|
EthereumSignTypedData,
|
||||||
)
|
)
|
||||||
|
|
||||||
from apps.common.keychain import (
|
from apps.common.keychain import Handler, Keychain, MsgOut
|
||||||
MsgOut,
|
|
||||||
Handler,
|
|
||||||
)
|
|
||||||
|
|
||||||
# messages for "with_keychain_and_network_from_path" decorator
|
# messages for "with_keychain_and_network_from_path" decorator
|
||||||
MsgInAddressN = TypeVar(
|
MsgInAddressN = TypeVar(
|
||||||
|
@ -30,9 +30,10 @@ def require_confirm_tx(
|
|||||||
network: EthereumNetworkInfo,
|
network: EthereumNetworkInfo,
|
||||||
token: EthereumTokenInfo | None,
|
token: EthereumTokenInfo | None,
|
||||||
) -> Awaitable[None]:
|
) -> Awaitable[None]:
|
||||||
from .helpers import address_from_bytes
|
|
||||||
from trezor.ui.layouts import confirm_output
|
from trezor.ui.layouts import confirm_output
|
||||||
|
|
||||||
|
from .helpers import address_from_bytes
|
||||||
|
|
||||||
if to_bytes:
|
if to_bytes:
|
||||||
to_str = address_from_bytes(to_bytes, network)
|
to_str = address_from_bytes(to_bytes, network)
|
||||||
else:
|
else:
|
||||||
@ -92,6 +93,7 @@ async def require_confirm_eip1559_fee(
|
|||||||
|
|
||||||
def require_confirm_unknown_token(address_bytes: bytes) -> Awaitable[None]:
|
def require_confirm_unknown_token(address_bytes: bytes) -> Awaitable[None]:
|
||||||
from ubinascii import hexlify
|
from ubinascii import hexlify
|
||||||
|
|
||||||
from trezor.ui.layouts import confirm_address
|
from trezor.ui.layouts import confirm_address
|
||||||
|
|
||||||
contract_address_hex = "0x" + hexlify(address_bytes).decode()
|
contract_address_hex = "0x" + hexlify(address_bytes).decode()
|
||||||
@ -106,6 +108,7 @@ def require_confirm_unknown_token(address_bytes: bytes) -> Awaitable[None]:
|
|||||||
|
|
||||||
def require_confirm_address(address_bytes: bytes) -> Awaitable[None]:
|
def require_confirm_address(address_bytes: bytes) -> Awaitable[None]:
|
||||||
from ubinascii import hexlify
|
from ubinascii import hexlify
|
||||||
|
|
||||||
from trezor.ui.layouts import confirm_address
|
from trezor.ui.layouts import confirm_address
|
||||||
|
|
||||||
address_hex = "0x" + hexlify(address_bytes).decode()
|
address_hex = "0x" + hexlify(address_bytes).decode()
|
||||||
@ -209,6 +212,7 @@ async def confirm_typed_value(
|
|||||||
array_index: int | None = None,
|
array_index: int | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
from trezor.enums import EthereumDataType
|
from trezor.enums import EthereumDataType
|
||||||
|
|
||||||
from .helpers import get_type_name
|
from .helpers import get_type_name
|
||||||
|
|
||||||
type_name = get_type_name(field)
|
type_name = get_type_name(field)
|
||||||
|
@ -3,12 +3,10 @@ from typing import TYPE_CHECKING
|
|||||||
from .keychain import PATTERNS_ADDRESS, with_keychain_from_path
|
from .keychain import PATTERNS_ADDRESS, with_keychain_from_path
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import (
|
from trezor.messages import EthereumMessageSignature, EthereumSignMessage
|
||||||
EthereumSignMessage,
|
|
||||||
EthereumMessageSignature,
|
|
||||||
)
|
|
||||||
|
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
|
|
||||||
from .definitions import Definitions
|
from .definitions import Definitions
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,8 +8,9 @@ from .helpers import bytes_from_address
|
|||||||
from .keychain import with_keychain_from_chain_id
|
from .keychain import with_keychain_from_chain_id
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
from trezor.messages import EthereumSignTx, EthereumTokenInfo, EthereumTxAck
|
||||||
|
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
from trezor.messages import EthereumSignTx, EthereumTxAck, EthereumTokenInfo
|
|
||||||
|
|
||||||
from .definitions import Definitions
|
from .definitions import Definitions
|
||||||
from .keychain import MsgInSignTx
|
from .keychain import MsgInSignTx
|
||||||
@ -27,14 +28,12 @@ async def sign_tx(
|
|||||||
keychain: Keychain,
|
keychain: Keychain,
|
||||||
defs: Definitions,
|
defs: Definitions,
|
||||||
) -> EthereumTxRequest:
|
) -> EthereumTxRequest:
|
||||||
from trezor.utils import HashWriter
|
|
||||||
from trezor.crypto.hashlib import sha3_256
|
from trezor.crypto.hashlib import sha3_256
|
||||||
|
from trezor.utils import HashWriter
|
||||||
|
|
||||||
from apps.common import paths
|
from apps.common import paths
|
||||||
from .layout import (
|
|
||||||
require_confirm_data,
|
from .layout import require_confirm_data, require_confirm_fee, require_confirm_tx
|
||||||
require_confirm_fee,
|
|
||||||
require_confirm_tx,
|
|
||||||
)
|
|
||||||
|
|
||||||
# check
|
# check
|
||||||
if msg.tx_type not in [1, 6, None]:
|
if msg.tx_type not in [1, 6, None]:
|
||||||
@ -103,8 +102,8 @@ async def handle_erc20(
|
|||||||
msg: MsgInSignTx,
|
msg: MsgInSignTx,
|
||||||
definitions: Definitions,
|
definitions: Definitions,
|
||||||
) -> tuple[EthereumTokenInfo | None, bytes, bytes, int]:
|
) -> tuple[EthereumTokenInfo | None, bytes, bytes, int]:
|
||||||
from .layout import require_confirm_unknown_token
|
|
||||||
from . import tokens
|
from . import tokens
|
||||||
|
from .layout import require_confirm_unknown_token
|
||||||
|
|
||||||
data_initial_chunk = msg.data_initial_chunk # local_cache_attribute
|
data_initial_chunk = msg.data_initial_chunk # local_cache_attribute
|
||||||
token = None
|
token = None
|
||||||
|
@ -8,11 +8,13 @@ from .keychain import with_keychain_from_chain_id
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import (
|
from trezor.messages import (
|
||||||
EthereumSignTxEIP1559,
|
|
||||||
EthereumAccessList,
|
EthereumAccessList,
|
||||||
|
EthereumSignTxEIP1559,
|
||||||
EthereumTxRequest,
|
EthereumTxRequest,
|
||||||
)
|
)
|
||||||
|
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
|
|
||||||
from .definitions import Definitions
|
from .definitions import Definitions
|
||||||
|
|
||||||
|
|
||||||
@ -33,17 +35,19 @@ async def sign_tx_eip1559(
|
|||||||
keychain: Keychain,
|
keychain: Keychain,
|
||||||
defs: Definitions,
|
defs: Definitions,
|
||||||
) -> EthereumTxRequest:
|
) -> EthereumTxRequest:
|
||||||
from trezor.crypto.hashlib import sha3_256
|
|
||||||
from trezor.utils import HashWriter
|
|
||||||
from trezor import wire
|
from trezor import wire
|
||||||
from trezor.crypto import rlp # local_cache_global
|
from trezor.crypto import rlp # local_cache_global
|
||||||
|
from trezor.crypto.hashlib import sha3_256
|
||||||
|
from trezor.utils import HashWriter
|
||||||
|
|
||||||
from apps.common import paths
|
from apps.common import paths
|
||||||
|
|
||||||
from .layout import (
|
from .layout import (
|
||||||
require_confirm_data,
|
require_confirm_data,
|
||||||
require_confirm_eip1559_fee,
|
require_confirm_eip1559_fee,
|
||||||
require_confirm_tx,
|
require_confirm_tx,
|
||||||
)
|
)
|
||||||
from .sign_tx import handle_erc20, send_request_chunk, check_common_fields
|
from .sign_tx import check_common_fields, handle_erc20, send_request_chunk
|
||||||
|
|
||||||
gas_limit = msg.gas_limit # local_cache_attribute
|
gas_limit = msg.gas_limit # local_cache_attribute
|
||||||
|
|
||||||
@ -156,8 +160,8 @@ def _get_total_length(msg: EthereumSignTxEIP1559, data_total: int) -> int:
|
|||||||
def _sign_digest(
|
def _sign_digest(
|
||||||
msg: EthereumSignTxEIP1559, keychain: Keychain, digest: bytes
|
msg: EthereumSignTxEIP1559, keychain: Keychain, digest: bytes
|
||||||
) -> EthereumTxRequest:
|
) -> EthereumTxRequest:
|
||||||
from trezor.messages import EthereumTxRequest
|
|
||||||
from trezor.crypto.curve import secp256k1
|
from trezor.crypto.curve import secp256k1
|
||||||
|
from trezor.messages import EthereumTxRequest
|
||||||
|
|
||||||
node = keychain.derive(msg.address_n)
|
node = keychain.derive(msg.address_n)
|
||||||
signature = secp256k1.sign(
|
signature = secp256k1.sign(
|
||||||
|
@ -9,16 +9,17 @@ from .keychain import PATTERNS_ADDRESS, with_keychain_from_path
|
|||||||
from .layout import should_show_struct
|
from .layout import should_show_struct
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from apps.common.keychain import Keychain
|
|
||||||
from trezor.utils import HashWriter
|
|
||||||
from .definitions import Definitions
|
|
||||||
|
|
||||||
from trezor.messages import (
|
from trezor.messages import (
|
||||||
EthereumSignTypedData,
|
|
||||||
EthereumFieldType,
|
EthereumFieldType,
|
||||||
|
EthereumSignTypedData,
|
||||||
EthereumTypedDataSignature,
|
EthereumTypedDataSignature,
|
||||||
EthereumTypedDataStructAck,
|
EthereumTypedDataStructAck,
|
||||||
)
|
)
|
||||||
|
from trezor.utils import HashWriter
|
||||||
|
|
||||||
|
from apps.common.keychain import Keychain
|
||||||
|
|
||||||
|
from .definitions import Definitions
|
||||||
|
|
||||||
|
|
||||||
@with_keychain_from_path(*PATTERNS_ADDRESS)
|
@with_keychain_from_path(*PATTERNS_ADDRESS)
|
||||||
@ -28,10 +29,12 @@ async def sign_typed_data(
|
|||||||
defs: Definitions,
|
defs: Definitions,
|
||||||
) -> EthereumTypedDataSignature:
|
) -> EthereumTypedDataSignature:
|
||||||
from trezor.crypto.curve import secp256k1
|
from trezor.crypto.curve import secp256k1
|
||||||
|
from trezor.messages import EthereumTypedDataSignature
|
||||||
|
|
||||||
from apps.common import paths
|
from apps.common import paths
|
||||||
|
|
||||||
from .helpers import address_from_bytes
|
from .helpers import address_from_bytes
|
||||||
from .layout import require_confirm_address
|
from .layout import require_confirm_address
|
||||||
from trezor.messages import EthereumTypedDataSignature
|
|
||||||
|
|
||||||
await paths.validate_path(keychain, msg.address_n)
|
await paths.validate_path(keychain, msg.address_n)
|
||||||
|
|
||||||
@ -143,8 +146,8 @@ class TypedDataEnvelope:
|
|||||||
async def _collect_types(self, type_name: str) -> None:
|
async def _collect_types(self, type_name: str) -> None:
|
||||||
"""Recursively collect types from the client."""
|
"""Recursively collect types from the client."""
|
||||||
from trezor.messages import (
|
from trezor.messages import (
|
||||||
EthereumTypedDataStructRequest,
|
|
||||||
EthereumTypedDataStructAck,
|
EthereumTypedDataStructAck,
|
||||||
|
EthereumTypedDataStructRequest,
|
||||||
)
|
)
|
||||||
|
|
||||||
req = EthereumTypedDataStructRequest(name=type_name)
|
req = EthereumTypedDataStructRequest(name=type_name)
|
||||||
|
@ -5,11 +5,11 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
|
|
||||||
async def verify_message(msg: EthereumVerifyMessage) -> Success:
|
async def verify_message(msg: EthereumVerifyMessage) -> Success:
|
||||||
from trezor.wire import DataError
|
|
||||||
from trezor.crypto.curve import secp256k1
|
from trezor.crypto.curve import secp256k1
|
||||||
from trezor.crypto.hashlib import sha3_256
|
from trezor.crypto.hashlib import sha3_256
|
||||||
from trezor.messages import Success
|
from trezor.messages import Success
|
||||||
from trezor.ui.layouts import confirm_signverify, show_success
|
from trezor.ui.layouts import confirm_signverify, show_success
|
||||||
|
from trezor.wire import DataError
|
||||||
|
|
||||||
from apps.common.signverify import decode_message
|
from apps.common.signverify import decode_message
|
||||||
|
|
||||||
|
@ -48,8 +48,8 @@ async def homescreen() -> None:
|
|||||||
|
|
||||||
|
|
||||||
async def lockscreen() -> None:
|
async def lockscreen() -> None:
|
||||||
from apps.common.request_pin import can_lock_device
|
|
||||||
from apps.base import unlock_device
|
from apps.base import unlock_device
|
||||||
|
from apps.common.request_pin import can_lock_device
|
||||||
|
|
||||||
# Only show the lockscreen UI if the device can in fact be locked.
|
# Only show the lockscreen UI if the device can in fact be locked.
|
||||||
if can_lock_device():
|
if can_lock_device():
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import Success
|
from trezor.messages import ApplyFlags, Success
|
||||||
from trezor.messages import ApplyFlags
|
|
||||||
|
|
||||||
|
|
||||||
async def apply_flags(msg: ApplyFlags) -> Success:
|
async def apply_flags(msg: ApplyFlags) -> Success:
|
||||||
import storage.device
|
import storage.device
|
||||||
from storage.device import set_flags
|
from storage.device import set_flags
|
||||||
from trezor.wire import NotInitialized
|
|
||||||
from trezor.messages import Success
|
from trezor.messages import Success
|
||||||
|
from trezor.wire import NotInitialized
|
||||||
|
|
||||||
if not storage.device.is_initialized():
|
if not storage.device.is_initialized():
|
||||||
raise NotInitialized("Device is not initialized")
|
raise NotInitialized("Device is not initialized")
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
import trezorui2
|
||||||
from trezor import utils
|
from trezor import utils
|
||||||
from trezor.enums import ButtonRequestType
|
from trezor.enums import ButtonRequestType
|
||||||
from trezor.ui.layouts import confirm_action, confirm_homescreen, confirm_single
|
from trezor.ui.layouts import confirm_action, confirm_homescreen, confirm_single
|
||||||
from trezor.wire import DataError
|
from trezor.wire import DataError
|
||||||
|
|
||||||
import trezorui2
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import ApplySettings, Success
|
|
||||||
from trezor.enums import SafetyCheckLevel
|
from trezor.enums import SafetyCheckLevel
|
||||||
|
from trezor.messages import ApplySettings, Success
|
||||||
|
|
||||||
|
|
||||||
BRT_PROTECT_CALL = ButtonRequestType.ProtectCall # CACHE
|
BRT_PROTECT_CALL = ButtonRequestType.ProtectCall # CACHE
|
||||||
@ -17,7 +16,7 @@ BRT_PROTECT_CALL = ButtonRequestType.ProtectCall # CACHE
|
|||||||
if utils.INTERNAL_MODEL in ("T1B1", "T2B1"):
|
if utils.INTERNAL_MODEL in ("T1B1", "T2B1"):
|
||||||
|
|
||||||
def _validate_homescreen_model_specific(homescreen: bytes) -> None:
|
def _validate_homescreen_model_specific(homescreen: bytes) -> None:
|
||||||
from trezor.ui import WIDTH, HEIGHT
|
from trezor.ui import HEIGHT, WIDTH
|
||||||
|
|
||||||
try:
|
try:
|
||||||
w, h, is_grayscale = trezorui2.toif_info(homescreen)
|
w, h, is_grayscale = trezorui2.toif_info(homescreen)
|
||||||
@ -31,7 +30,7 @@ if utils.INTERNAL_MODEL in ("T1B1", "T2B1"):
|
|||||||
else:
|
else:
|
||||||
|
|
||||||
def _validate_homescreen_model_specific(homescreen: bytes) -> None:
|
def _validate_homescreen_model_specific(homescreen: bytes) -> None:
|
||||||
from trezor.ui import WIDTH, HEIGHT
|
from trezor.ui import HEIGHT, WIDTH
|
||||||
|
|
||||||
try:
|
try:
|
||||||
w, h, mcu_height = trezorui2.jpeg_info(homescreen)
|
w, h, mcu_height = trezorui2.jpeg_info(homescreen)
|
||||||
@ -63,10 +62,11 @@ def _validate_homescreen(homescreen: bytes) -> None:
|
|||||||
|
|
||||||
async def apply_settings(msg: ApplySettings) -> Success:
|
async def apply_settings(msg: ApplySettings) -> Success:
|
||||||
import storage.device as storage_device
|
import storage.device as storage_device
|
||||||
from apps.common import safety_checks
|
|
||||||
from trezor.messages import Success
|
from trezor.messages import Success
|
||||||
from trezor.wire import ProcessError, NotInitialized
|
from trezor.wire import NotInitialized, ProcessError
|
||||||
|
|
||||||
from apps.base import reload_settings_from_storage
|
from apps.base import reload_settings_from_storage
|
||||||
|
from apps.common import safety_checks
|
||||||
|
|
||||||
if not storage_device.is_initialized():
|
if not storage_device.is_initialized():
|
||||||
raise NotInitialized("Device is not initialized")
|
raise NotInitialized("Device is not initialized")
|
||||||
|
@ -8,14 +8,12 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
async def change_wipe_code(msg: ChangeWipeCode) -> Success:
|
async def change_wipe_code(msg: ChangeWipeCode) -> Success:
|
||||||
from storage.device import is_initialized
|
from storage.device import is_initialized
|
||||||
from trezor.wire import NotInitialized
|
|
||||||
from trezor.ui.layouts import show_success
|
|
||||||
from trezor.messages import Success
|
|
||||||
from trezor import config
|
from trezor import config
|
||||||
from apps.common.request_pin import (
|
from trezor.messages import Success
|
||||||
error_pin_invalid,
|
from trezor.ui.layouts import show_success
|
||||||
request_pin_and_sd_salt,
|
from trezor.wire import NotInitialized
|
||||||
)
|
|
||||||
|
from apps.common.request_pin import error_pin_invalid, request_pin_and_sd_salt
|
||||||
|
|
||||||
if not is_initialized():
|
if not is_initialized():
|
||||||
raise NotInitialized("Device is not initialized")
|
raise NotInitialized("Device is not initialized")
|
||||||
@ -59,8 +57,8 @@ async def change_wipe_code(msg: ChangeWipeCode) -> Success:
|
|||||||
def _require_confirm_action(
|
def _require_confirm_action(
|
||||||
msg: ChangeWipeCode, has_wipe_code: bool
|
msg: ChangeWipeCode, has_wipe_code: bool
|
||||||
) -> Awaitable[None]:
|
) -> Awaitable[None]:
|
||||||
from trezor.wire import ProcessError
|
|
||||||
from trezor.ui.layouts import confirm_action, confirm_set_new_pin
|
from trezor.ui.layouts import confirm_action, confirm_set_new_pin
|
||||||
|
from trezor.wire import ProcessError
|
||||||
|
|
||||||
title = "Wipe code settings"
|
title = "Wipe code settings"
|
||||||
|
|
||||||
@ -93,13 +91,14 @@ def _require_confirm_action(
|
|||||||
|
|
||||||
|
|
||||||
async def _request_wipe_code_confirm(pin: str) -> str:
|
async def _request_wipe_code_confirm(pin: str) -> str:
|
||||||
from apps.common.request_pin import request_pin
|
|
||||||
from trezor.ui.layouts import (
|
from trezor.ui.layouts import (
|
||||||
confirm_reenter_pin,
|
confirm_reenter_pin,
|
||||||
pin_mismatch_popup,
|
pin_mismatch_popup,
|
||||||
wipe_code_same_as_pin_popup,
|
wipe_code_same_as_pin_popup,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from apps.common.request_pin import request_pin
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
code1 = await request_pin("Enter new wipe code")
|
code1 = await request_pin("Enter new wipe code")
|
||||||
if code1 == pin:
|
if code1 == pin:
|
||||||
|
@ -6,10 +6,10 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
async def get_next_u2f_counter(msg: GetNextU2FCounter) -> NextU2FCounter:
|
async def get_next_u2f_counter(msg: GetNextU2FCounter) -> NextU2FCounter:
|
||||||
import storage.device as storage_device
|
import storage.device as storage_device
|
||||||
from trezor.wire import NotInitialized
|
|
||||||
from trezor.enums import ButtonRequestType
|
from trezor.enums import ButtonRequestType
|
||||||
from trezor.messages import NextU2FCounter
|
from trezor.messages import NextU2FCounter
|
||||||
from trezor.ui.layouts import confirm_action
|
from trezor.ui.layouts import confirm_action
|
||||||
|
from trezor.wire import NotInitialized
|
||||||
|
|
||||||
if not storage_device.is_initialized():
|
if not storage_device.is_initialized():
|
||||||
raise NotInitialized("Device is not initialized")
|
raise NotInitialized("Device is not initialized")
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import RebootToBootloader
|
|
||||||
from typing import NoReturn
|
from typing import NoReturn
|
||||||
|
|
||||||
|
from trezor.messages import RebootToBootloader
|
||||||
|
|
||||||
|
|
||||||
async def reboot_to_bootloader(msg: RebootToBootloader) -> NoReturn:
|
async def reboot_to_bootloader(msg: RebootToBootloader) -> NoReturn:
|
||||||
from trezor import io, loop, utils
|
from trezor import io, loop, utils
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import RecoveryDevice
|
from trezor.messages import RecoveryDevice, Success
|
||||||
from trezor.messages import Success
|
|
||||||
|
|
||||||
# List of RecoveryDevice fields that can be set when doing dry-run recovery.
|
# List of RecoveryDevice fields that can be set when doing dry-run recovery.
|
||||||
# All except `dry_run` are allowed for T1 compatibility, but their values are ignored.
|
# All except `dry_run` are allowed for T1 compatibility, but their values are ignored.
|
||||||
@ -23,11 +22,13 @@ async def recovery_device(msg: RecoveryDevice) -> Success:
|
|||||||
from trezor import config, wire, workflow
|
from trezor import config, wire, workflow
|
||||||
from trezor.enums import ButtonRequestType
|
from trezor.enums import ButtonRequestType
|
||||||
from trezor.ui.layouts import confirm_action, confirm_reset_device
|
from trezor.ui.layouts import confirm_action, confirm_reset_device
|
||||||
|
|
||||||
from apps.common.request_pin import (
|
from apps.common.request_pin import (
|
||||||
error_pin_invalid,
|
error_pin_invalid,
|
||||||
request_pin_and_sd_salt,
|
request_pin_and_sd_salt,
|
||||||
request_pin_confirm,
|
request_pin_confirm,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .homescreen import recovery_homescreen, recovery_process
|
from .homescreen import recovery_homescreen, recovery_process
|
||||||
|
|
||||||
dry_run = msg.dry_run # local_cache_attribute
|
dry_run = msg.dry_run # local_cache_attribute
|
||||||
|
@ -15,6 +15,7 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
async def recovery_homescreen() -> None:
|
async def recovery_homescreen() -> None:
|
||||||
from trezor import workflow
|
from trezor import workflow
|
||||||
|
|
||||||
from apps.homescreen import homescreen
|
from apps.homescreen import homescreen
|
||||||
|
|
||||||
if not storage_recovery.is_in_progress():
|
if not storage_recovery.is_in_progress():
|
||||||
@ -25,8 +26,8 @@ async def recovery_homescreen() -> None:
|
|||||||
|
|
||||||
|
|
||||||
async def recovery_process() -> Success:
|
async def recovery_process() -> Success:
|
||||||
from trezor.enums import MessageType
|
|
||||||
import storage
|
import storage
|
||||||
|
from trezor.enums import MessageType
|
||||||
|
|
||||||
wire.AVOID_RESTARTING_FOR = (MessageType.Initialize, MessageType.GetFeatures)
|
wire.AVOID_RESTARTING_FOR = (MessageType.Initialize, MessageType.GetFeatures)
|
||||||
try:
|
try:
|
||||||
@ -41,8 +42,8 @@ async def recovery_process() -> Success:
|
|||||||
|
|
||||||
|
|
||||||
async def _continue_recovery_process() -> Success:
|
async def _continue_recovery_process() -> Success:
|
||||||
from trezor.errors import MnemonicError
|
|
||||||
from trezor import utils
|
from trezor import utils
|
||||||
|
from trezor.errors import MnemonicError
|
||||||
|
|
||||||
# gather the current recovery state from storage
|
# gather the current recovery state from storage
|
||||||
dry_run = storage_recovery.is_dry_run()
|
dry_run = storage_recovery.is_dry_run()
|
||||||
@ -101,8 +102,9 @@ async def _continue_recovery_process() -> Success:
|
|||||||
|
|
||||||
|
|
||||||
async def _finish_recovery_dry_run(secret: bytes, backup_type: BackupType) -> Success:
|
async def _finish_recovery_dry_run(secret: bytes, backup_type: BackupType) -> Success:
|
||||||
from trezor.crypto.hashlib import sha256
|
|
||||||
from trezor import utils
|
from trezor import utils
|
||||||
|
from trezor.crypto.hashlib import sha256
|
||||||
|
|
||||||
from apps.common import mnemonic
|
from apps.common import mnemonic
|
||||||
|
|
||||||
if backup_type is None:
|
if backup_type is None:
|
||||||
@ -136,8 +138,8 @@ async def _finish_recovery_dry_run(secret: bytes, backup_type: BackupType) -> Su
|
|||||||
|
|
||||||
|
|
||||||
async def _finish_recovery(secret: bytes, backup_type: BackupType) -> Success:
|
async def _finish_recovery(secret: bytes, backup_type: BackupType) -> Success:
|
||||||
from trezor.ui.layouts import show_success
|
|
||||||
from trezor.enums import BackupType
|
from trezor.enums import BackupType
|
||||||
|
from trezor.ui.layouts import show_success
|
||||||
|
|
||||||
if backup_type is None:
|
if backup_type is None:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
@ -13,6 +13,7 @@ from .. import backup_types
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
from trezor.enums import BackupType
|
from trezor.enums import BackupType
|
||||||
|
|
||||||
|
|
||||||
@ -40,10 +41,11 @@ async def _confirm_abort(dry_run: bool = False) -> None:
|
|||||||
async def request_mnemonic(
|
async def request_mnemonic(
|
||||||
word_count: int, backup_type: BackupType | None
|
word_count: int, backup_type: BackupType | None
|
||||||
) -> str | None:
|
) -> str | None:
|
||||||
from . import word_validity
|
|
||||||
from trezor.ui.layouts.common import button_request
|
from trezor.ui.layouts.common import button_request
|
||||||
from trezor.ui.layouts.recovery import request_word
|
from trezor.ui.layouts.recovery import request_word
|
||||||
|
|
||||||
|
from . import word_validity
|
||||||
|
|
||||||
await button_request("mnemonic", code=ButtonRequestType.MnemonicInput)
|
await button_request("mnemonic", code=ButtonRequestType.MnemonicInput)
|
||||||
|
|
||||||
words: list[str] = []
|
words: list[str] = []
|
||||||
@ -123,10 +125,11 @@ async def homescreen_dialog(
|
|||||||
info_func: Callable | None = None,
|
info_func: Callable | None = None,
|
||||||
show_info: bool = False,
|
show_info: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
from .recover import RecoveryAborted
|
|
||||||
import storage.recovery as storage_recovery
|
import storage.recovery as storage_recovery
|
||||||
from trezor.wire import ActionCancelled
|
|
||||||
from trezor.ui.layouts.recovery import continue_recovery
|
from trezor.ui.layouts.recovery import continue_recovery
|
||||||
|
from trezor.wire import ActionCancelled
|
||||||
|
|
||||||
|
from .recover import RecoveryAborted
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
dry_run = storage_recovery.is_dry_run()
|
dry_run = storage_recovery.is_dry_run()
|
||||||
|
@ -22,6 +22,7 @@ class ThresholdReached(WordValidityResult):
|
|||||||
|
|
||||||
def check(backup_type: BackupType | None, partial_mnemonic: list[str]) -> None:
|
def check(backup_type: BackupType | None, partial_mnemonic: list[str]) -> None:
|
||||||
from trezor.enums import BackupType
|
from trezor.enums import BackupType
|
||||||
|
|
||||||
from . import recover
|
from . import recover
|
||||||
|
|
||||||
# we can't perform any checks if the backup type was not yet decided
|
# we can't perform any checks if the backup type was not yet decided
|
||||||
|
@ -12,8 +12,7 @@ if __debug__:
|
|||||||
import storage.debug
|
import storage.debug
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import ResetDevice
|
from trezor.messages import ResetDevice, Success
|
||||||
from trezor.messages import Success
|
|
||||||
|
|
||||||
|
|
||||||
BAK_T_BIP39 = BackupType.Bip39 # global_import_cache
|
BAK_T_BIP39 = BackupType.Bip39 # global_import_cache
|
||||||
@ -24,16 +23,14 @@ _DEFAULT_BACKUP_TYPE = BAK_T_BIP39
|
|||||||
|
|
||||||
async def reset_device(msg: ResetDevice) -> Success:
|
async def reset_device(msg: ResetDevice) -> Success:
|
||||||
from trezor import config
|
from trezor import config
|
||||||
from apps.common.request_pin import request_pin_confirm
|
|
||||||
from trezor.ui.layouts import (
|
|
||||||
prompt_backup,
|
|
||||||
confirm_reset_device,
|
|
||||||
)
|
|
||||||
from trezor.crypto import bip39, random
|
from trezor.crypto import bip39, random
|
||||||
from trezor.messages import Success, EntropyAck, EntropyRequest
|
from trezor.messages import EntropyAck, EntropyRequest, Success
|
||||||
from trezor.pin import render_empty_loader
|
from trezor.pin import render_empty_loader
|
||||||
|
from trezor.ui.layouts import confirm_reset_device, prompt_backup
|
||||||
from trezor.wire.context import call
|
from trezor.wire.context import call
|
||||||
|
|
||||||
|
from apps.common.request_pin import request_pin_confirm
|
||||||
|
|
||||||
backup_type = msg.backup_type # local_cache_attribute
|
backup_type = msg.backup_type # local_cache_attribute
|
||||||
|
|
||||||
# validate parameters and device state
|
# validate parameters and device state
|
||||||
@ -177,9 +174,10 @@ async def _backup_slip39_advanced(encrypted_master_secret: bytes) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def _validate_reset_device(msg: ResetDevice) -> None:
|
def _validate_reset_device(msg: ResetDevice) -> None:
|
||||||
from .. import backup_types
|
|
||||||
from trezor.wire import UnexpectedMessage
|
from trezor.wire import UnexpectedMessage
|
||||||
|
|
||||||
|
from .. import backup_types
|
||||||
|
|
||||||
backup_type = msg.backup_type or _DEFAULT_BACKUP_TYPE
|
backup_type = msg.backup_type or _DEFAULT_BACKUP_TYPE
|
||||||
if backup_type not in (
|
if backup_type not in (
|
||||||
BAK_T_BIP39,
|
BAK_T_BIP39,
|
||||||
|
@ -13,6 +13,7 @@ from apps.common.sdcard import ensure_sdcard
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Awaitable
|
from typing import Awaitable
|
||||||
|
|
||||||
from trezor.messages import SdProtect
|
from trezor.messages import SdProtect
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import WipeDevice, Success
|
from trezor.messages import Success, WipeDevice
|
||||||
|
|
||||||
|
|
||||||
async def wipe_device(msg: WipeDevice) -> Success:
|
async def wipe_device(msg: WipeDevice) -> Success:
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import CipherKeyValue, CipheredKeyValue
|
from trezor.messages import CipheredKeyValue, CipherKeyValue
|
||||||
|
|
||||||
# This module implements the SLIP-0011 symmetric encryption of key-value pairs using a
|
# This module implements the SLIP-0011 symmetric encryption of key-value pairs using a
|
||||||
# deterministic hierarchy, see https://github.com/satoshilabs/slips/blob/master/slip-0011.md.
|
# deterministic hierarchy, see https://github.com/satoshilabs/slips/blob/master/slip-0011.md.
|
||||||
|
|
||||||
|
|
||||||
async def cipher_key_value(msg: CipherKeyValue) -> CipheredKeyValue:
|
async def cipher_key_value(msg: CipherKeyValue) -> CipheredKeyValue:
|
||||||
from trezor.wire import DataError
|
|
||||||
from trezor.messages import CipheredKeyValue
|
|
||||||
from trezor.crypto import aes, hmac
|
from trezor.crypto import aes, hmac
|
||||||
|
from trezor.messages import CipheredKeyValue
|
||||||
|
from trezor.ui.layouts import confirm_action
|
||||||
|
from trezor.wire import DataError
|
||||||
|
|
||||||
from apps.common.keychain import get_keychain
|
from apps.common.keychain import get_keychain
|
||||||
from apps.common.paths import AlwaysMatchingSchema
|
from apps.common.paths import AlwaysMatchingSchema
|
||||||
from trezor.ui.layouts import confirm_action
|
|
||||||
|
|
||||||
keychain = await get_keychain("secp256k1", [AlwaysMatchingSchema])
|
keychain = await get_keychain("secp256k1", [AlwaysMatchingSchema])
|
||||||
|
|
||||||
|
@ -60,6 +60,7 @@ async def cosi_commit(msg: CosiCommit) -> CosiSignature:
|
|||||||
from trezor.crypto.curve import ed25519
|
from trezor.crypto.curve import ed25519
|
||||||
from trezor.ui.layouts import confirm_blob, confirm_text
|
from trezor.ui.layouts import confirm_blob, confirm_text
|
||||||
from trezor.wire.context import call
|
from trezor.wire.context import call
|
||||||
|
|
||||||
from apps.common import paths
|
from apps.common import paths
|
||||||
from apps.common.keychain import get_keychain
|
from apps.common.keychain import get_keychain
|
||||||
|
|
||||||
|
@ -1,24 +1,26 @@
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import GetECDHSessionKey, ECDHSessionKey
|
from trezor.messages import ECDHSessionKey, GetECDHSessionKey
|
||||||
|
|
||||||
# This module implements the SLIP-0017 Elliptic Curve Diffie-Hellman algorithm, using a
|
# This module implements the SLIP-0017 Elliptic Curve Diffie-Hellman algorithm, using a
|
||||||
# deterministic hierarchy, see https://github.com/satoshilabs/slips/blob/master/slip-0017.md.
|
# deterministic hierarchy, see https://github.com/satoshilabs/slips/blob/master/slip-0017.md.
|
||||||
|
|
||||||
|
|
||||||
async def get_ecdh_session_key(msg: GetECDHSessionKey) -> ECDHSessionKey:
|
async def get_ecdh_session_key(msg: GetECDHSessionKey) -> ECDHSessionKey:
|
||||||
from trezor.ui.layouts import confirm_address
|
|
||||||
from .sign_identity import (
|
|
||||||
get_identity_path,
|
|
||||||
serialize_identity_without_proto,
|
|
||||||
serialize_identity,
|
|
||||||
)
|
|
||||||
from trezor.wire import DataError
|
|
||||||
from trezor.messages import ECDHSessionKey
|
from trezor.messages import ECDHSessionKey
|
||||||
|
from trezor.ui.layouts import confirm_address
|
||||||
|
from trezor.wire import DataError
|
||||||
|
|
||||||
from apps.common.keychain import get_keychain
|
from apps.common.keychain import get_keychain
|
||||||
from apps.common.paths import AlwaysMatchingSchema
|
from apps.common.paths import AlwaysMatchingSchema
|
||||||
|
|
||||||
|
from .sign_identity import (
|
||||||
|
get_identity_path,
|
||||||
|
serialize_identity,
|
||||||
|
serialize_identity_without_proto,
|
||||||
|
)
|
||||||
|
|
||||||
msg_identity = msg.identity # local_cache_attribute
|
msg_identity = msg.identity # local_cache_attribute
|
||||||
peer_public_key = msg.peer_public_key # local_cache_attribute
|
peer_public_key = msg.peer_public_key # local_cache_attribute
|
||||||
curve_name = msg.ecdsa_curve_name or "secp256k1"
|
curve_name = msg.ecdsa_curve_name or "secp256k1"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import GetEntropy, Entropy
|
from trezor.messages import Entropy, GetEntropy
|
||||||
|
|
||||||
|
|
||||||
async def get_entropy(msg: GetEntropy) -> Entropy:
|
async def get_entropy(msg: GetEntropy) -> Entropy:
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import GetFirmwareHash, FirmwareHash
|
from trezor.messages import FirmwareHash, GetFirmwareHash
|
||||||
from trezor.ui.layouts.common import ProgressLayout
|
from trezor.ui.layouts.common import ProgressLayout
|
||||||
|
|
||||||
_progress_obj: ProgressLayout | None = None
|
_progress_obj: ProgressLayout | None = None
|
||||||
|
|
||||||
|
|
||||||
async def get_firmware_hash(msg: GetFirmwareHash) -> FirmwareHash:
|
async def get_firmware_hash(msg: GetFirmwareHash) -> FirmwareHash:
|
||||||
from trezor.messages import FirmwareHash
|
|
||||||
from trezor.utils import firmware_hash
|
|
||||||
from trezor.ui.layouts.progress import progress
|
|
||||||
from trezor import wire, workflow
|
from trezor import wire, workflow
|
||||||
|
from trezor.messages import FirmwareHash
|
||||||
|
from trezor.ui.layouts.progress import progress
|
||||||
|
from trezor.utils import firmware_hash
|
||||||
|
|
||||||
workflow.close_others()
|
workflow.close_others()
|
||||||
global _progress_obj
|
global _progress_obj
|
||||||
|
@ -5,7 +5,8 @@ from trezor.crypto.hashlib import sha256
|
|||||||
from apps.common import coininfo
|
from apps.common import coininfo
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import IdentityType, SignIdentity, SignedIdentity
|
from trezor.messages import IdentityType, SignedIdentity, SignIdentity
|
||||||
|
|
||||||
from apps.common.paths import Bip32Path
|
from apps.common.paths import Bip32Path
|
||||||
|
|
||||||
# This module implements the SLIP-0013 authentication using a deterministic hierarchy, see
|
# This module implements the SLIP-0013 authentication using a deterministic hierarchy, see
|
||||||
@ -15,6 +16,7 @@ if TYPE_CHECKING:
|
|||||||
async def sign_identity(msg: SignIdentity) -> SignedIdentity:
|
async def sign_identity(msg: SignIdentity) -> SignedIdentity:
|
||||||
from trezor.messages import SignedIdentity
|
from trezor.messages import SignedIdentity
|
||||||
from trezor.ui.layouts import confirm_sign_identity
|
from trezor.ui.layouts import confirm_sign_identity
|
||||||
|
|
||||||
from apps.common.keychain import get_keychain
|
from apps.common.keychain import get_keychain
|
||||||
from apps.common.paths import AlwaysMatchingSchema
|
from apps.common.paths import AlwaysMatchingSchema
|
||||||
|
|
||||||
@ -89,6 +91,7 @@ def serialize_identity_without_proto(identity: IdentityType) -> str:
|
|||||||
|
|
||||||
def get_identity_path(identity: str, index: int, num: int) -> Bip32Path:
|
def get_identity_path(identity: str, index: int, num: int) -> Bip32Path:
|
||||||
from ustruct import pack, unpack
|
from ustruct import pack, unpack
|
||||||
|
|
||||||
from apps.common.paths import HARDENED
|
from apps.common.paths import HARDENED
|
||||||
|
|
||||||
identity_hash = sha256(pack("<I", index) + identity.encode()).digest()
|
identity_hash = sha256(pack("<I", index) + identity.encode()).digest()
|
||||||
@ -103,9 +106,10 @@ def sign_challenge(
|
|||||||
sigtype: str | coininfo.CoinInfo,
|
sigtype: str | coininfo.CoinInfo,
|
||||||
curve: str,
|
curve: str,
|
||||||
) -> bytes:
|
) -> bytes:
|
||||||
from apps.common.signverify import message_digest
|
|
||||||
from trezor.wire import DataError
|
from trezor.wire import DataError
|
||||||
|
|
||||||
|
from apps.common.signverify import message_digest
|
||||||
|
|
||||||
if sigtype == "gpg":
|
if sigtype == "gpg":
|
||||||
data = challenge_hidden
|
data = challenge_hidden
|
||||||
elif sigtype == "signify":
|
elif sigtype == "signify":
|
||||||
|
@ -3,7 +3,7 @@ from typing import TYPE_CHECKING
|
|||||||
from apps.common.keychain import auto_keychain
|
from apps.common.keychain import auto_keychain
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import MoneroGetAddress, MoneroAddress
|
from trezor.messages import MoneroAddress, MoneroGetAddress
|
||||||
|
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
|
|
||||||
|
@ -22,7 +22,8 @@ from apps.common.keychain import auto_keychain
|
|||||||
_GET_TX_KEY_REASON_TX_DERIVATION = const(1)
|
_GET_TX_KEY_REASON_TX_DERIVATION = const(1)
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import MoneroGetTxKeyRequest, MoneroGetTxKeyAck
|
from trezor.messages import MoneroGetTxKeyAck, MoneroGetTxKeyRequest
|
||||||
|
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,10 +10,11 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
@auto_keychain(__name__)
|
@auto_keychain(__name__)
|
||||||
async def get_watch_only(msg: MoneroGetWatchKey, keychain: Keychain) -> MoneroWatchKey:
|
async def get_watch_only(msg: MoneroGetWatchKey, keychain: Keychain) -> MoneroWatchKey:
|
||||||
|
from trezor.messages import MoneroWatchKey
|
||||||
|
|
||||||
from apps.common import paths
|
from apps.common import paths
|
||||||
from apps.monero import layout, misc
|
from apps.monero import layout, misc
|
||||||
from apps.monero.xmr import crypto_helpers
|
from apps.monero.xmr import crypto_helpers
|
||||||
from trezor.messages import MoneroWatchKey
|
|
||||||
|
|
||||||
await paths.validate_path(keychain, msg.address_n)
|
await paths.validate_path(keychain, msg.address_n)
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@ from apps.monero import layout
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import (
|
from trezor.messages import (
|
||||||
|
MoneroKeyImageExportInitAck,
|
||||||
MoneroKeyImageExportInitRequest,
|
MoneroKeyImageExportInitRequest,
|
||||||
MoneroKeyImageSyncFinalAck,
|
MoneroKeyImageSyncFinalAck,
|
||||||
MoneroKeyImageExportInitAck,
|
|
||||||
MoneroKeyImageSyncStepAck,
|
MoneroKeyImageSyncStepAck,
|
||||||
MoneroKeyImageSyncStepRequest,
|
MoneroKeyImageSyncStepRequest,
|
||||||
)
|
)
|
||||||
@ -25,6 +25,7 @@ async def key_image_sync(
|
|||||||
msg: MoneroKeyImageExportInitRequest, keychain: Keychain
|
msg: MoneroKeyImageExportInitRequest, keychain: Keychain
|
||||||
) -> MoneroKeyImageSyncFinalAck:
|
) -> MoneroKeyImageSyncFinalAck:
|
||||||
import gc
|
import gc
|
||||||
|
|
||||||
from trezor.messages import (
|
from trezor.messages import (
|
||||||
MoneroKeyImageSyncFinalAck,
|
MoneroKeyImageSyncFinalAck,
|
||||||
MoneroKeyImageSyncFinalRequest,
|
MoneroKeyImageSyncFinalRequest,
|
||||||
@ -69,11 +70,12 @@ async def _init_step(
|
|||||||
msg: MoneroKeyImageExportInitRequest,
|
msg: MoneroKeyImageExportInitRequest,
|
||||||
keychain: Keychain,
|
keychain: Keychain,
|
||||||
) -> MoneroKeyImageExportInitAck:
|
) -> MoneroKeyImageExportInitAck:
|
||||||
from trezor.messages import MoneroKeyImageExportInitAck
|
|
||||||
from trezor.crypto import random
|
from trezor.crypto import random
|
||||||
|
from trezor.messages import MoneroKeyImageExportInitAck
|
||||||
|
|
||||||
from apps.common import paths
|
from apps.common import paths
|
||||||
from apps.monero.xmr import monero
|
|
||||||
from apps.monero import misc
|
from apps.monero import misc
|
||||||
|
from apps.monero.xmr import monero
|
||||||
|
|
||||||
await paths.validate_path(keychain, msg.address_n)
|
await paths.validate_path(keychain, msg.address_n)
|
||||||
|
|
||||||
@ -99,10 +101,8 @@ def _sync_step(
|
|||||||
progress: ProgressLayout,
|
progress: ProgressLayout,
|
||||||
) -> MoneroKeyImageSyncStepAck:
|
) -> MoneroKeyImageSyncStepAck:
|
||||||
from trezor import log
|
from trezor import log
|
||||||
from trezor.messages import (
|
from trezor.messages import MoneroExportedKeyImage, MoneroKeyImageSyncStepAck
|
||||||
MoneroExportedKeyImage,
|
|
||||||
MoneroKeyImageSyncStepAck,
|
|
||||||
)
|
|
||||||
from apps.monero.xmr import chacha_poly, crypto, key_image
|
from apps.monero.xmr import chacha_poly, crypto, key_image
|
||||||
|
|
||||||
assert s.creds is not None
|
assert s.creds is not None
|
||||||
|
@ -13,10 +13,7 @@ DUMMY_PAYMENT_ID = b"\x00\x00\x00\x00\x00\x00\x00\x00"
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.enums import MoneroNetworkType
|
from trezor.enums import MoneroNetworkType
|
||||||
from trezor.messages import (
|
from trezor.messages import MoneroTransactionData, MoneroTransactionDestinationEntry
|
||||||
MoneroTransactionData,
|
|
||||||
MoneroTransactionDestinationEntry,
|
|
||||||
)
|
|
||||||
|
|
||||||
from .signing.state import State
|
from .signing.state import State
|
||||||
|
|
||||||
@ -150,9 +147,10 @@ async def _require_confirm_output(
|
|||||||
"""
|
"""
|
||||||
Single transaction destination confirmation
|
Single transaction destination confirmation
|
||||||
"""
|
"""
|
||||||
|
from trezor.ui.layouts import confirm_output
|
||||||
|
|
||||||
from apps.monero.xmr.addresses import encode_addr
|
from apps.monero.xmr.addresses import encode_addr
|
||||||
from apps.monero.xmr.networks import net_version
|
from apps.monero.xmr.networks import net_version
|
||||||
from trezor.ui.layouts import confirm_output
|
|
||||||
|
|
||||||
version = net_version(network_type, dst.is_subaddress, payment_id is not None)
|
version = net_version(network_type, dst.is_subaddress, payment_id is not None)
|
||||||
addr = encode_addr(
|
addr = encode_addr(
|
||||||
|
@ -5,13 +5,14 @@ from apps.monero import layout, misc
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import (
|
from trezor.messages import (
|
||||||
MoneroLiveRefreshStepAck,
|
|
||||||
MoneroLiveRefreshStepRequest,
|
|
||||||
MoneroLiveRefreshStartRequest,
|
|
||||||
MoneroLiveRefreshFinalAck,
|
MoneroLiveRefreshFinalAck,
|
||||||
MoneroLiveRefreshStartAck,
|
MoneroLiveRefreshStartAck,
|
||||||
|
MoneroLiveRefreshStartRequest,
|
||||||
|
MoneroLiveRefreshStepAck,
|
||||||
|
MoneroLiveRefreshStepRequest,
|
||||||
)
|
)
|
||||||
from trezor.ui.layouts.common import ProgressLayout
|
from trezor.ui.layouts.common import ProgressLayout
|
||||||
|
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
|
|
||||||
from .xmr.credentials import AccountCreds
|
from .xmr.credentials import AccountCreds
|
||||||
@ -22,6 +23,7 @@ async def live_refresh(
|
|||||||
msg: MoneroLiveRefreshStartRequest, keychain: Keychain
|
msg: MoneroLiveRefreshStartRequest, keychain: Keychain
|
||||||
) -> MoneroLiveRefreshFinalAck:
|
) -> MoneroLiveRefreshFinalAck:
|
||||||
import gc
|
import gc
|
||||||
|
|
||||||
from trezor.enums import MessageType
|
from trezor.enums import MessageType
|
||||||
from trezor.messages import MoneroLiveRefreshFinalAck, MoneroLiveRefreshStepRequest
|
from trezor.messages import MoneroLiveRefreshFinalAck, MoneroLiveRefreshStepRequest
|
||||||
from trezor.wire.context import call_any
|
from trezor.wire.context import call_any
|
||||||
@ -56,9 +58,10 @@ async def _init_step(
|
|||||||
keychain: Keychain,
|
keychain: Keychain,
|
||||||
) -> MoneroLiveRefreshStartAck:
|
) -> MoneroLiveRefreshStartAck:
|
||||||
import storage.cache as storage_cache
|
import storage.cache as storage_cache
|
||||||
from apps.common import paths
|
|
||||||
from trezor.messages import MoneroLiveRefreshStartAck
|
from trezor.messages import MoneroLiveRefreshStartAck
|
||||||
|
|
||||||
|
from apps.common import paths
|
||||||
|
|
||||||
await paths.validate_path(keychain, msg.address_n)
|
await paths.validate_path(keychain, msg.address_n)
|
||||||
|
|
||||||
if not storage_cache.get(storage_cache.APP_MONERO_LIVE_REFRESH):
|
if not storage_cache.get(storage_cache.APP_MONERO_LIVE_REFRESH):
|
||||||
@ -75,8 +78,9 @@ def _refresh_step(
|
|||||||
msg: MoneroLiveRefreshStepRequest,
|
msg: MoneroLiveRefreshStepRequest,
|
||||||
progress: ProgressLayout,
|
progress: ProgressLayout,
|
||||||
) -> MoneroLiveRefreshStepAck:
|
) -> MoneroLiveRefreshStepAck:
|
||||||
from trezor.messages import MoneroLiveRefreshStepAck
|
|
||||||
from trezor import log
|
from trezor import log
|
||||||
|
from trezor.messages import MoneroLiveRefreshStepAck
|
||||||
|
|
||||||
from apps.monero.xmr import chacha_poly, crypto, crypto_helpers, key_image, monero
|
from apps.monero.xmr import chacha_poly, crypto, crypto_helpers, key_image, monero
|
||||||
|
|
||||||
assert s.creds is not None
|
assert s.creds is not None
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
from trezor.enums import MoneroNetworkType
|
||||||
|
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
from apps.common.paths import Bip32Path
|
from apps.common.paths import Bip32Path
|
||||||
|
|
||||||
from trezor.enums import MoneroNetworkType
|
|
||||||
|
|
||||||
from .xmr.crypto import Scalar
|
|
||||||
from .xmr.credentials import AccountCreds
|
from .xmr.credentials import AccountCreds
|
||||||
|
from .xmr.crypto import Scalar
|
||||||
|
|
||||||
|
|
||||||
def get_creds(
|
def get_creds(
|
||||||
@ -45,6 +45,7 @@ def compute_enc_key_host(
|
|||||||
view_key_private: Scalar, tx_prefix_hash: bytes
|
view_key_private: Scalar, tx_prefix_hash: bytes
|
||||||
) -> tuple[bytes, bytes]:
|
) -> tuple[bytes, bytes]:
|
||||||
from trezor.crypto import random
|
from trezor.crypto import random
|
||||||
|
|
||||||
from apps.monero.xmr import crypto_helpers
|
from apps.monero.xmr import crypto_helpers
|
||||||
|
|
||||||
salt = random.bytes(32)
|
salt = random.bytes(32)
|
||||||
|
@ -5,6 +5,7 @@ from apps.monero.layout import MoneroTransactionProgress
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from trezor.messages import MoneroTransactionFinalAck
|
from trezor.messages import MoneroTransactionFinalAck
|
||||||
|
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
from apps.monero.signing.state import State
|
from apps.monero.signing.state import State
|
||||||
|
|
||||||
@ -12,8 +13,10 @@ if TYPE_CHECKING:
|
|||||||
@auto_keychain(__name__)
|
@auto_keychain(__name__)
|
||||||
async def sign_tx(received_msg, keychain: Keychain) -> MoneroTransactionFinalAck:
|
async def sign_tx(received_msg, keychain: Keychain) -> MoneroTransactionFinalAck:
|
||||||
import gc
|
import gc
|
||||||
|
|
||||||
from trezor import log, utils
|
from trezor import log, utils
|
||||||
from trezor.wire.context import get_context
|
from trezor.wire.context import get_context
|
||||||
|
|
||||||
from apps.monero.signing.state import State
|
from apps.monero.signing.state import State
|
||||||
|
|
||||||
state = State()
|
state = State()
|
||||||
@ -48,8 +51,8 @@ async def sign_tx(received_msg, keychain: Keychain) -> MoneroTransactionFinalAck
|
|||||||
async def _sign_tx_dispatch(
|
async def _sign_tx_dispatch(
|
||||||
state: State, msg, keychain: Keychain, progress: MoneroTransactionProgress
|
state: State, msg, keychain: Keychain, progress: MoneroTransactionProgress
|
||||||
) -> tuple:
|
) -> tuple:
|
||||||
from trezor.enums import MessageType
|
|
||||||
from trezor import wire
|
from trezor import wire
|
||||||
|
from trezor.enums import MessageType
|
||||||
|
|
||||||
MESSAGE_WIRE_TYPE = msg.MESSAGE_WIRE_TYPE # local_cache_attribute
|
MESSAGE_WIRE_TYPE = msg.MESSAGE_WIRE_TYPE # local_cache_attribute
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user