Commit Graph

81 Commits

Author SHA1 Message Date
Jochen Hoenicke 1bc1bb1e77 Less paranoid change outputs.
- Allow change to be on the main chain (see spesmilo/electrum#3920).
- Allow more than one output to the Trezor, but don't treat it as change.
2018-02-20 16:39:16 +01:00
Saleem Rashid ba5b44d0c5 emulator: Initial commit 2017-12-18 20:09:59 +01:00
Saleem Rashid 6e25e0b363 coins: Use curve_info instead of HasherType 2017-12-10 20:53:44 +01:00
Saleem Rashid 268e7de109 Update trezor-crypto 2017-12-10 20:53:44 +01:00
Saleem Rashid a1e911aa4c transaction: Do not hardcode HASHER_SHA2 2017-12-10 20:53:44 +01:00
Saleem Rashid 54b0869535 signing: Use Hasher instead of SHA256_CTX 2017-12-09 16:28:40 +01:00
Tomas Susanka cfe8a98c68 signing segwit change output typo 2017-11-25 01:06:46 +01:00
Jochen Hoenicke e1fa7af1da Byte-precise size estimate for fees
Fixes issue #232.

It assumes largest possible signature size for all inputs.  For segwit
multisig it can be .25 bytes off due to difference between segwit
encoding (varint) vs. non-segwit encoding (op_push) of the multisig script.
2017-11-14 13:39:17 +01:00
Jochen Hoenicke b8bca1c444 Fix segwit forkid signatures 2017-11-13 22:20:08 +01:00
Jochen Hoenicke a8bc3cb6bd Remove add_hash_type fields.
The 4 byte hash_type/forkid is part of the signed message, but not
part of the transaction.  Instead of hacking it into the transaction,
add it after the transaction when computing the signature.
2017-11-13 22:20:08 +01:00
Saleem Rashid d39e4be1c8 signing: Use force_bip143 instead of has_forkid 2017-11-13 22:20:08 +01:00
Saleem Rashid b6f11c9f93 signing: Add signing_hash_type function
This also enables SIGHASH_FORKID for SegWit
2017-11-13 22:20:08 +01:00
Jochen Hoenicke 97581928de
Enable Segwit Bech32 addresses
Increase the size of the addresses in protobuf.
Fix layout2.c to handle longer addresses.
Add a field bech32_prefix to coins.h
Adapted the coins-gen script.
Added bech32 support in signing.c and transaction.c
2017-11-05 19:28:07 +01:00
Jochen Hoenicke b5fa8a266a New CoinInfo separated from protobuf structures
Having CoinType using the protobuf structures has several disadvantages.
- We always need to change trezor-common if we need a new field (like
  bech32 prefix)
- Every time Trezor initializes it sends all this information out and
  nobody cares.
- The protobuf structures add storage overhead due to their fixed size.

I also removed most of the `has_` fields except for forkid:
- `has_segwit` was merged with segwit
- `has_coin_shortcut` can be replaced by test for NULL if necessary.

The fields were reordered for better padding.
2017-11-05 19:23:34 +01:00
Pavol Rusnak 18d8cb3c56
add project website (trezor.io) to license header 2017-11-05 17:47:23 +01:00
Jochen Hoenicke a24e8a0484 Remove magic constants
Use defines for wallet depth and change chain.  Updated some comments
to clarify what is checked.
2017-11-03 19:12:41 +01:00
Jochen Hoenicke 4805f27e8c Fix checking change address
There was a signed/unsigned problem: size_t is unsigned, but we use
-1 to indicate mismatch.  The problem was that when checking the input
address path, it still did this unintentionally when a mismatch was
detected, forbidding to sign with mismatched inputs, even when there
is no change address.

We now use 1 for mismatch.  Also we don't allow change address anymore
if the inputs have a path of length 1.  This simplifies the code a bit.
2017-11-03 19:12:41 +01:00
Jochen Hoenicke 98e617d874
startup: use custom reset_handler
+ group confidential data in one place
+ zero all SRAM where needed
2017-08-16 13:52:01 +02:00
Jochen Hoenicke 3440ead4c9
Fix multisig for BCC 2017-07-30 22:58:26 +02:00
Jochen Hoenicke 5f6948e66b
Remove progress update 2017-07-30 22:57:44 +02:00
Jochen Hoenicke 3c75d28c78 Check input bip32 path again on second pass. 2017-07-30 22:51:18 +02:00
Jochen Hoenicke 6b615ce405 No quadratic hashing for hardfork
Don't hash the whole transaction if forkid is set.  Instead use the
same codepath as for segwit.

Rename segwit_to_spend to authorized_amount and use it for forkid
amount and segwit amount validity checks.

Removed some duplicated code.
2017-07-30 22:51:18 +02:00
Saleem Rashid 979a6ef266 signing: Skip TX_META with SIGHASH_FORKID 2017-07-30 22:51:18 +02:00
Saleem Rashid a34554b091 signing: Add SIGHASH_FORKID support 2017-07-30 22:51:18 +02:00
Pavol Rusnak 3d7d0f0734
use C99 for loop where possible 2017-07-23 22:20:51 +02:00
Pavol Rusnak c6fd70b471
gettext: mark localizable strings as proof-of-concept 2017-06-18 22:47:32 +02:00
Pavol Rusnak 00f6312a81
rename failures, unify strings where possible 2017-06-18 21:19:21 +02:00
Pavol Rusnak 317363f84c
enable mixing of segwit and non-segwit inputs 2017-05-19 17:40:57 +02:00
Pavol Rusnak 391e3940e5
refactor fee computation, but keep ceil logic 2017-05-15 12:08:54 +02:00
Pavol Rusnak 24ac52079f
disable native segwit for now 2017-05-13 01:05:10 +02:00
Pavol Rusnak 49f44d296c
refactor signing_check_output 2017-05-13 00:45:11 +02:00
Pavol Rusnak 1ecbca8338
signing: add option to enable/disable mixing of segwit/non-segwit inputs 2017-05-09 23:26:18 +02:00
Pavol Rusnak 261b8d5e41
multisig: allow mismatched change addresses, show them as non-change 2017-05-06 19:52:49 +02:00
Pavol Rusnak e31e55e505
simplify bip32 change logic 2017-05-05 15:12:47 +02:00
Pavol Rusnak b1995bb8d1
remove segwit warning, don't enable segwit on coins that don't have segwit=true in definition 2017-05-04 18:54:54 +02:00
Pavol Rusnak 4183b6cbbc
update logic for change addresses (address_n length 1 is allowed now) 2017-05-04 18:16:45 +02:00
Jochen Hoenicke d70ac623a4 Small bugfixes in signing
Segwit progress bar fixed.
Call `signing_abort` instead of `layoutHome` on all errors
The second `compile_output` does not work for user button and cannot
return -1.
2017-04-08 22:39:49 +02:00
Jochen Hoenicke 420471889d Refactored signing method.
Put larger pieces of codes into functions of their own.
No changes to this code.
2017-04-08 21:59:51 +02:00
Jochen Hoenicke 9d9377438c Fix missing returns after signing_abort 2017-04-08 20:33:27 +02:00
Jochen Hoenicke e5c9b361d3 Better error message for segwit without amount 2017-04-08 20:29:58 +02:00
Jochen Hoenicke 7b1381766f
Change address support for segwit.
Rewrote change address support for segwit.
Also checks the bip32 path of change address.
2017-03-29 20:59:01 +02:00
Jochen Hoenicke 8e84a6716c Merge master into segwit 2017-01-06 16:55:12 +01:00
Jochen Hoenicke 52da2fc5e7
Segwit: Fix problems introduced by rebase 2017-01-04 18:41:26 +01:00
Pavol Rusnak 1763a5b647
use new hdnode_private_ckd_cached API 2016-12-12 12:17:48 +01:00
Pavol Rusnak 810d478f4c
check return values of ecdsa_sign calls 2016-11-08 15:48:44 +01:00
Jochen Hoenicke 2950588271
Fix segwit multisig.
Tested, see f41cbedd8becee05a830f418d13aa665125464547db5c7a6cd28f21639fe1228
and c9348040bbc2024e12dcb4a0b4806b0398646b91acf314da028c3f03dd0179fc
on testnet
2016-11-05 22:47:21 +01:00
Jochen Hoenicke 895da908e0
Simplified InputScriptType
Distinguish between single signature and multisig via has_multisig.
2016-11-05 22:47:21 +01:00
Jochen Hoenicke 388750f2d1
Support for P2SH compatible segwit 2016-11-05 22:47:21 +01:00
Jochen Hoenicke b7b9891cb4
Signing for Segnet Transaction works
see segnet4 txid:
aa434a6ef4fcf350e319bacbd725fa7446f797cb3ed0cd0582826a49d3351ffa
2016-11-05 22:47:21 +01:00
Jochen Hoenicke e5000fb196
segwit sign (completely untested) 2016-11-05 22:47:18 +01:00