1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-10-19 22:40:58 +00:00
Commit Graph

297 Commits

Author SHA1 Message Date
Andrew Kozlik
a635876807 test(core): Add multisig unit tests for TxWeightCalculator. 2021-11-13 13:33:46 +01:00
Andrew Kozlik
9b579094c0 fix(core): Fix TxWeightCalculator.
- Refactor TxWeightCalculator to count inputs and outputs itself.
- Fix witness data weight by adding the weight of the witness stack item count
  for each input in segwit transactions and removing the weight of the
  nonsensical extra inputs count.
- Get multisig pubkey count from multisig.nodes or multisig.pubkeys like in
  multisig_get_pubkeys().
- Fix size of multisig script length encoding in segwit (varint vs. OP_PUSH).
- Improve comments.
2021-11-13 13:33:46 +01:00
Andrew Kozlik
381e8bc85a feat(core): Implement the BIP-341 common signature message computation. 2021-11-13 13:33:46 +01:00
Andrew Kozlik
99e4ed6f42 chore(core): Support script_pubkey parameter for Bitcoin inputs. 2021-11-13 13:33:46 +01:00
matejcik
72924a016f tests(core): add unit tests for Icarus and Icarus-Trezor, fix failing tests 2021-11-10 13:57:57 +01:00
grdddj
73238135d6 feat(core/ethereum): EIP-712
Based on original contribution by Max Kupriianov <xlab@hey.com>

Implemented EIP-712 typed data signatures in Ethereum app.

Add eth_abi into pyproject deps

device test for EIP 712

fixed hex decoding for address

fixup! fixed hex decoding for address

code quality, more pythonic code, removing unused imports

running black and isort on changed files

trezorctl file input for EIP 712 data signing

fixup! code quality, more pythonic code, removing unused imports

fixup! fixup! code quality, more pythonic code, removing unused imports

necessary changes after rebase to master

unit tests for sign_typed_data.py

new protobuf messages, working for nonarray types

simplified and verified solution for our simple data

support for simple arrays, without their confirmation

reverting protobuf value messages to bytes, appropriate changes

showing arrays in Trezor, code quality improvements

data validation on Trezor, minor improvements

using custom types for storing type data instead of dicts, addressing feedback from review

moving helper functions to its own file, tests for decode_data

additional overall tests

support for arrays of structs

adding support for metamask_v4_compat variable

using HashWriter object to collect the final hash continously

minor improvements in code quality

validate_field_type function

streaming values from client without saving them, missing UI

prototype of streamed UI using confirm_properties

accounting for bytes in data, more data types in integration tests

rebase on master, using f-strings

minor fixes and improvements from code review

StructHasher class for the whole hashing process

mypy and style changes

asking users whether to show structs and arrays

protobuf descriptions to fix make defs_check

unifying comments, mypy fix

unit tests for StructHasher class

UI fixtures, skipping device tests for T1

addressing majority of code review comments about code quality and structure

changing file structure - layouts, helpers, sign_typed_data

decode_data renaming and docstring, renaming unit test file

using tuples instead of lists in elifs

layout improvements

excluding core/src/apps/common/confirm.py file from the PR

True/False returning layout with Show more button

code review layout improvements

forgotten br_type argument to should_show_more
2021-11-02 14:27:01 +01:00
grdddj
082b7ecd91 feat(core): plural function supports "key/keys" string
Previously function did not work for words ending with "y" and vowel before that
2021-11-02 14:27:01 +01:00
grdddj
b1a3618c17 refactor(core/ethereum): rename address.py to helpers.py 2021-11-02 14:27:01 +01:00
matejcik
1d72085b5c feat(core): implement conversion from timestamp to datetime 2021-10-29 11:00:30 +02:00
Pavol Rusnak
7e64ccbaf9 feat(core): add BIP-350 test cases to test_trezor.crypto.bech32 2021-10-18 13:36:05 +02:00
Pavol Rusnak
a45e103875 fix(core): remove 3 BIP-173 test cases from test_trezor.crypto.bech32
because they encode segwit program > 0 and these should no longer
be encoded with Bech32 but rather with Bech32m
2021-10-18 13:36:05 +02:00
Pavol Rusnak
9aa07c7f96 feat(core): update bech32.py to support Bech32m 2021-10-18 13:36:05 +02:00
amadejpapez
85ba7c12ba style(all): use f-strings for formatting
[no changelog]
2021-10-13 11:53:17 +02:00
gabrielkerekes
1f33ab420d feat(cardano): update transaction signing for multisig 2021-10-11 15:16:24 +02:00
gabrielkerekes
21281d7cf4 feat(cardano): add support for script addresses derivation 2021-10-11 15:16:24 +02:00
gabrielkerekes
dd9652cd07 feat(cardano): add get-native-script-hash call 2021-10-11 15:16:24 +02:00
matejcik
b666895303 feat(core/rust): catch, handle and propagate uPy exceptions 2021-09-21 12:43:31 +02:00
matejcik
e80077e0a4 feat(core/ethereum): enable type-checking for Ethereum app 2021-09-10 15:09:03 +02:00
matejcik
0c2863fc8d feat(core/ethereum): use TokenInfo object instead of tuples 2021-09-10 15:09:03 +02:00
matejcik
96ed53cc1c refactor(core,legacy): remove Wanchain special handling
now that Wanchain has proper chainID and we don't need to detect it by
magic.

[no changelog]
2021-09-10 15:09:03 +02:00
matejcik
639406b01f feat(all): make chain_id mandatory 2021-09-10 15:09:03 +02:00
Martin Milata
f37ca13f1a refactor(core): disable SD, SBU, fatfs for T1 build 2021-08-20 12:22:13 +02:00
gabrielkerekes
28f0f60295 feat(cardano): update tests for streamed tx signing 2021-08-20 11:50:13 +02:00
gabrielkerekes
b0c8590f00 feat(cardano): streamed transaction signing 2021-08-20 11:50:13 +02:00
Martin Milata
574dcbc8a3 refactor(core): convert apps.common to layouts 2021-08-04 15:03:11 +02:00
Pavol Rusnak
f740515c85 fix(core,crypto): add more test cases from bip-173 2021-07-21 11:20:11 +02:00
matejcik
cf15dce326 refactor(core/ethereum): improve API of the rlp module 2021-07-19 13:59:28 +02:00
Andrew Kozlik
3e9f8a32ac fix(core): Fix insufficient BIP-32 path checks.
- Disable testnet coins from accessing Bitcoin paths.

- Restrict BIP-45 paths to Bitcoin and coins with strong replay protection.
2021-06-30 18:25:58 +02:00
gabrielkerekes
3cd2182b69 feat(core): introduce OrderedMap into CBOR serialisation
Items of an OrderedMap are included in CBOR as they come without sorting them in any way.
2021-06-24 08:22:39 +02:00
matejcik
3c4eb04346 feat(core/monero): cache Monero testing chain between runs 2021-06-23 11:51:18 +02:00
matejcik
52c34c7364 fix(core): allow caching empty values (fixes #1659) 2021-06-11 12:32:13 +02:00
gabrielkerekes
597402eab8 refactor(core/cardano): decouple address parameters validation 2021-06-08 15:02:24 +02:00
matejcik
1382246977 fix(core/tests): fix equality testing for new message types 2021-06-08 09:55:19 +02:00
Jan Pochyla
a8623c4b59 refactor(core): fix imports and use new protobuf API in apps 2021-06-08 09:55:19 +02:00
Jan Pochyla
02aa14fc04 refactor(core): Switch to new Protobuf API 2021-06-08 09:55:19 +02:00
matejcik
f1a54f2108 refactor(core): remove more global imports 2021-05-06 13:14:21 +02:00
matejcik
b5c1b37a56 chore(core/tests): bump heap size for core unit tests 2021-05-06 13:14:21 +02:00
matejcik
aaa3ce6117 fix(core/bitcoin): fix CoinJoin authorization with new cache 2021-05-06 13:14:21 +02:00
matejcik
f3db4f2dd3 refactor(core): defragment PathSchema memory usage 2021-05-06 13:14:21 +02:00
matejcik
3cdb09c294 refactor(core): modify cache to preallocate all its data
also get rid of expensive "wire" import
2021-05-06 13:14:21 +02:00
Martin Milata
720eaa3abd ci: run monero tests on hardware 2021-04-06 22:06:12 +02:00
Rafael Korbas
a9b8b0e119 feat(core/cardano): chunked serialization of signed transaction 2021-03-26 11:15:19 +01:00
Andrew Kozlik
25411e22c9 test(core): Add unit test for modtrezorconfig counter. 2021-03-26 10:54:56 +01:00
Andrew Kozlik
2836bfc64c fix(core): Improve error handling and range checking in modtrezorconfig. 2021-03-26 10:54:56 +01:00
Andrew Kozlik
3084d1196d feat(core): Support 50 digit PIN and wipe code. 2021-03-25 14:24:41 +01:00
Rafael Korbas
74ed5b7018 feat(core/cardano): Implement bech32 asset ids based on CIP-0014 2021-03-18 09:53:33 +01:00
Andrew Kozlik
6de20a7dcd chore(core/bitcoin): Add DecredApprover. 2021-03-17 12:16:08 +01:00
JoeGruff
e3ea32a986 multi: Add decred staking.
Add two new input and four output script types.

Decred ticket purchases consist of a stake submission, op returns, and
change addresses. Although change addresses are allowed by consensus,
they are no longer used in practice and so have been given the
restrictions of a null pubkey and no value. Stake scripts are almost
identical to p2pkh or p2sh except for an extra opcode in front. Inputs
are currently only used in the form of one input three outputs with the
first output, or stake submission, paying to a public key hash, or with
two inputs and five outputs with the stake submission paying to a
multisig script hash. The op returns are directed to the user in the
case of one and the voting service provider and user in the case of two.

One of the sstx commitment for a ticket must pay back to the trezor
wallet. This is checked and an error is thrown if we don't find the
expected public key hash.

Because this adds the ability to create new types of outputs once the
ticket votes, two new input script types are also needed. A successful
vote will lead to a stake generation script that must be spent, and an
unsuccessful vote will lead to a revocation script that must be spent.
If we allowed stake change scripts to have a valid pubkey, that too
would require another op code, but we disallow those for output.
2021-03-17 12:16:08 +01:00
Rafael Korbas
3197741795 fix(core/Cardano): account index validation in _should_hide_output() 2021-02-25 16:41:12 +01:00
Andrew Kozlik
e5741ac308 chore(core): Use BufferReader for CBOR decoding. 2021-02-10 23:20:56 +01:00
Andrew Kozlik
ac939c94aa fix(core/tezos): Implement strict length checking.
(cherry picked from commit e7f44ebee8)
2021-02-10 16:37:26 +01:00
matejcik
2231fe6842 feat(core): make protobuf.dump_uvarint more reusable
(cherry picked from commit 6acc1cd6ab)
2021-02-10 16:37:26 +01:00
Martin Milata
f1382bf892 refactor(core): model-dependent UI component directories
They now live under trezor.ui.components.tt. Later
trezor.ui.components.t1 will be added and application code will be
rewritten to not use them directly in order to work on both TT and T1.
2021-02-10 13:57:19 +01:00
matejcik
ccd241fe55 feat(core/cardano): enable typing for Cardano app 2021-02-10 10:56:52 +01:00
Pavol Rusnak
7f0e939359 feat(core): implement amount_unit for AuthorizeCoinJoin and SignTx 2021-01-22 14:07:36 +01:00
Pavol Rusnak
f3d5de15ef refactor(core): turn SECP256K1_ZKP into a firmware feature flag 2021-01-22 14:06:29 +01:00
matejcik
e23e35332d tests(core): add test cases for Span 2021-01-11 16:47:59 +01:00
Martin Milata
db5b65a420 perf(core): enable rendering of substrings to avoid slicing 2021-01-11 16:47:59 +01:00
Rafael Korbas
edf9b4ee85 Refactor mnemonic_to_entropy to not (misleadingly) return checksum 2020-12-19 20:17:16 +01:00
Martin Milata
ee64b65b26 refactor(core): call super().__init__() in subclasses 2020-11-30 14:48:08 +01:00
matejcik
4628c774aa feat(core): re-allow unknown Ethereum networks, using Ethereum or Testnet paths (fixes #1335) 2020-11-20 18:55:35 +01:00
matejcik
e6a1bf840f fix(core): do not subclass range
micropython on real hw dislikes it for some reason

also it's completely unnecessary
2020-11-13 16:01:35 +01:00
Pavol Rusnak
50fdd183c2
ci: enable editorconfig checks, fix whitespace issues 2020-11-11 14:43:50 +01:00
matejcik
eadf8ab25f chore(core/tests): update unit tests for new APIs, drop unnecessary ones 2020-11-05 14:30:11 +01:00
matejcik
7fe5c804ff feat(core): implement BIP-32 path schemas 2020-11-05 14:30:11 +01:00
Andrew Kozlik
4a0c5c371a feat(core): In apps.bitcoin implement replacement transaction flow. 2020-10-23 15:07:15 +02:00
Andrew Kozlik
bd3fe1d789 chore(core): In apps.bitcoin create a separate class for transaction information. 2020-10-23 15:07:15 +02:00
Andrew Kozlik
5fc491c597 chore(core): In apps.bitcoin move BIP143 hashing back to a separate class. 2020-10-23 15:07:15 +02:00
Martin Milata
9ed25a718a ci: handle full dependencies in shell.nix
Handling of full dependencies (multiple python versions, Monero tests)
was moved from Dockerfile to shell.nix.

The Python packages are installed from the pinned nixpkgs revision and
do not depend on channel state at the time of docker build anymore.

The Monero test binary is now downloaded using fetchurl which fails the
build if checksum doesn't match.
2020-10-15 15:59:20 +02:00
Pavol Rusnak
d8534b5ee6
perf(core/extmod): replace HMAC Python implementation with C
We keep Python implementation of HMAC for Monero in
core/src/apps/monero/xmr/crypto/__init__.py
2020-10-12 16:33:13 +02:00
matejcik
0eed360037 chore: make tx type names shorter
as suggested by @andrewkozlik:
TxAckInputType -> TxInput
TxAckOutputType -> TxOutput
TxAckPrevTxType -> PrevTx
TxAckPrevInputType -> PrevInput
TxAckPrevOutputType -> PrevOutput
2020-09-23 16:00:10 +02:00
matejcik
8b2e46eb2d chore(core): update unit tests to kwargs usage and new TxAck subtypes 2020-09-23 16:00:10 +02:00
matejcik
90ee5f3d38 feat!: implement protobuf required fields and default values
BREAKING CHANGE: this makes arguments to protobuf constructors
keyword-only, and arguments corresponding to required fields are now
mandatory
2020-09-23 16:00:10 +02:00
Martin Milata
cff4955f93 core: implement SafetyChecks.PromptTemporarily
Also reword safety checks confirmation dialogs.
2020-09-18 09:02:40 +02:00
Andrew Kozlik
9774c99e90 core/tests: Fix unit tests for streamimg prev_tx after confirmation. 2020-09-04 14:36:39 +02:00
Tomas Susanka
b99b8b3df3 Merge remote-tracking branch 'origin/release/2020-09' 2020-09-03 13:17:23 +02:00
matejcik
e0583dd5cb all: use a specific error code for "invalid session" 2020-08-28 15:37:06 +02:00
matejcik
4909821f35 core: implement EndSession 2020-08-28 15:37:06 +02:00
Andrew Kozlik
02da5b7593 core/bitcoin: Show warning if nLockTime is set but ineffective due to all nSequence values being 0xffffffff. 2020-08-21 21:30:15 +02:00
Pavol Rusnak
0620911e46 core: allow spending coins from Bitcoin paths if the coin ...
has implemented strong replay protection via SIGHASH_FORKID
2020-08-21 11:49:03 +02:00
Andrew Kozlik
791a74aeb2 core/tests: Add unit tests for CoinJoinApprover and CoinJoinAuthorization. 2020-08-04 17:32:44 +02:00
Andrew Kozlik
472e853f0a core/tests: Fix unit tests to work with BasicApprover in sign_tx. 2020-08-04 17:32:44 +02:00
matejcik
c3afb93837 core/tests: improve test harness (fixes #1157) 2020-08-04 10:27:44 +02:00
Pavol Rusnak
063aba910d core: rename emulator to trezor-emu-core 2020-07-30 15:27:34 +02:00
Martin Milata
d955e3f1e5 core: rename class Overwintered to Zcashlike 2020-07-30 15:14:18 +02:00
Martin Milata
10387e1869 core: drop zcash v3 tx signing support 2020-07-30 15:14:18 +02:00
Gabriel Kerekeš
d2c1624602 Cardano shelley update 2/3 (#1112) 2020-07-27 13:11:23 +02:00
gabrielkerekes
e1615e60ec Update Cardano to support Shelley era 1/3
Update protobuf

- Previous transactions don't need to be sent anymore, because fee is
  included in the transaction now. Thus transactions_count can be
  removed from CardanoSignTx message and the CardanoTxAck and
  CardanoTxRequest messages can be removed altogether.
- CardanoTxInputType.type is unused so remove it

Add NULL (None type) serialisation to CBOR

- Transaction metada must either have a valid structure or CBOR NULL
  must be used (if metadata is empty) - it can't be simply left out.

Add protocol_magics file

- Just to have a nicer way of representing protocol magics

Update transaction signing

- Previous transactions no longer need to be requested
- Output building is simplified, since fee doesn't need to be calculated
- Remove transaction class since it is no longer needed (only functions
  remained)
- Reorder functions so it reads top to bottom

Add protocol magic to byron address on testnet

- This has always been a part of the spec, but it hasn't been
  implemented before, because it wasn't really needed.

Update trezorlib

Update tests

- Transaction messages are no longer required
- Expected values are different since tx format changed
- Common values in test cases have been extracted

Remove unused file

- Progress was used when receiving previous transactions

Add CRC check to output address validation
2020-07-27 13:04:49 +02:00
matejcik
b741560997 core/bitcoin: drop unused validate_path_for_bitcoin_public_key 2020-07-24 16:37:58 +02:00
matejcik
58f460627f core/tests: add unit tests for new functionality 2020-07-24 16:37:58 +02:00
matejcik
a461853cf6 core/tests: fix bitcoin unit tests 2020-07-24 16:37:58 +02:00
matejcik
7befdd07e4 core/tests: update unit tests 2020-07-24 14:09:31 +02:00
matejcik
3514a31bc9 core: make USB codec resilient to OOM conditions 2020-07-24 14:09:31 +02:00
matejcik
0a758b8181 core/tests: add synchronous protobuf tests 2020-07-24 14:09:31 +02:00
Martin Milata
fd117a0c9f core: raise error on auto-lock value out of range 2020-07-22 21:38:42 +02:00
Pavol Rusnak
57ae902aed
core/monero: don't download test binary even if hash is different 2020-07-03 15:18:38 +02:00
Pavol Rusnak
5d666376f0
core/monero: update tests binary 2020-07-03 15:18:38 +02:00
Andrew Kozlik
791ff3fe06 core/tests: Add unit tests for SLIP-0019 proofs of ownership. 2020-07-03 11:17:19 +02:00
Andrew Kozlik
d48a372ca7 core/sign_tx: Implement support for signed external inputs. 2020-07-03 11:17:19 +02:00
Andrew Kozlik
3b6c1e5e6b core/crypto: Add functions for verifying DER encoded signatures. 2020-07-03 11:17:19 +02:00