Commit Graph

81 Commits

Author SHA1 Message Date
zkbot 95277e0311 Auto merge of #1144 - bitcartel:zc.v0.11.2.z7_tx_malleability_gettxid, r=bitcartel
A fix for transaction malleability

This PR fixes transaction malleability by not including the sigscript of transaction inputs and joinsplit sigs when hashing the txid.

This PR supercedes PR #1101 which was a minimal solution based on a new serialization flag.

This PR introduces GetTxid() to distinguish between getting a transaction id and the double sha256 hash.

The key changes are:
- Adding GetTxid() method to CTransaction which makes a copy of the transaction, clearing out the sigscript and joinsplitsig fields, before hashing.
- Verifying that every call to GetHash() actually wants a txid, and replacing with GetTxid().
- Renaming GetHash() to GetSerializeHash()
  - Rationale: In future, upstream code we want to merge will use GetHash() but we don't know the intent.  We should check to see if the intent is to receive a txid (most likely) in which case we replace with GetTxid(), or if upstream actually wants a double hash of the transaction we can use GetSerializeHash().
- Updated genesis data in chainparams.cpp

Note that coinbase transactions are excluded as they need the sigscript hashed to help avoid duplicate txids per BIP34:
  - This modification is related to a question from @ebfull on PR #1101 - "Can we think of a way this change allows us to construct two transactions with the same txid which can simultaneously appear in the blockchain? My guess is it would be possible to construct a coinbase transaction of such a form... this surely breaks invariants."

This PR Passes all tests in test_bitcoin (test data was updated in bloom_tests, miner_tests and script_tests).
2016-08-05 19:31:52 +00:00
Jack Grigg f7478de67f Add thread parameter to solveequihash benchmark
Closes #1147
2016-08-05 15:05:38 +12:00
Simon eae3794152 Update deprecation message for zcraw api. 2016-07-27 21:40:26 -07:00
Simon 10d2c57c0d Replace calls to GetHash() with GetTxid() for transaction objects.
Where the caller intends to receive a transaction id and not a double
SHA256 hash.
2016-07-26 17:13:03 -07:00
Simon a24a2e1144 Inform user that zcraw... rpc calls are being deprecated. 2016-07-24 10:05:20 -07:00
zkbot b83061544f Auto merge of #1116 - ebfull:performance-check-valid-pour-fix, r=ebfull
Introduce `zcsamplejoinsplit` for creating a raw joinsplit description

We need this to generate joinsplits for use in the performance measurements. The current measurements for *memory usage* of verification are wrong now that we're computing the joinsplit before verifying: https://speed.z.cash/timeline/?exe=1&base=1%2B9&ben=memory+verifyjoinsplit&env=1&revs=50&equid=off&quarts=on&extr=on

This PR fixes that.
2016-07-20 00:03:46 +00:00
Taylor Hornby 67f0243533 Remove in-band error signalling from SignatureHash, fixing the SIGHASH_SINGLE bug. 2016-07-19 16:36:35 -06:00
Sean Bowe 1737627c4e Introduce `zcsamplejoinsplit` for creating a raw joinsplit description, and use it to construct the joinsplit for the performance tests that verify joinsplits. 2016-07-19 15:49:11 -06:00
Sean Bowe 22de160219 Fixes for indentation and local variable names. 2016-07-18 10:07:29 -06:00
Daira Hopwood 4bc00dc141 Bucket -> note.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2016-07-18 10:06:18 -06:00
Sean Bowe b7e4abd6f7 Rename some usage of 'pour'. 2016-07-18 10:06:18 -06:00
Sean Bowe 8675d94b63 Rename vpour to vjoinsplit. 2016-07-18 10:06:18 -06:00
Sean Bowe a8c68ffe99 Rename CPourTx to JSDescription. 2016-07-18 10:06:18 -06:00
Sean Bowe 35f82c35fe Rename samplepour to samplejoinsplit 2016-07-11 11:33:14 -06:00
Sean Bowe 2fbbde597c Always check valid joinsplits during performance tests, and avoid recomputing them every time we change the circuit. 2016-07-09 14:31:43 -06:00
Sean Bowe 9c45b501ad Make `validatelargetx` test more accurate, reduce block size limit to 1MB for now. 2016-07-06 12:07:50 -06:00
Jack Grigg f5edc37f3f Add performance tests for creating and validating a MAX_BLOCK_SIZE transaction 2016-06-21 13:48:04 +12:00
Sean Bowe 0d6864e465 Added encoding for Zcash spending keys. 2016-06-15 16:03:57 -06:00
Sean Bowe e104fcddf8 Use base58check to encode Zcash payment addresses, such that the first two bytes are "zc". 2016-06-15 14:59:05 -06:00
Sean Bowe 320f2cc7e0 Switch to Ed25519 for cryptographic binding of joinsplits to transactions. 2016-05-30 11:05:55 -06:00
Taylor Hornby a138f81404 Implement signature verification in CheckTransaction 2016-05-30 11:05:43 -06:00
Taylor Hornby 6aae9d1a55 Sign JoinSplit transactions 2016-05-30 11:05:31 -06:00
Sean Bowe ccb439c510 Protect-style joinsplits should anchor to the latest root for now, until #604 is resolved. 2016-05-12 16:44:49 -06:00
Sean Bowe 2dc3599271 Transplant of libzcash. 2016-05-12 16:44:47 -06:00
Sean Bowe 2140639309 Remove scriptPubKey/scriptSig from CPourTx, and add randomSeed. 2016-05-12 16:44:30 -06:00
Sean Bowe 5961dcb6da Change ciphertext length to match protocol spec, and refactor the use of constants. 2016-05-05 21:02:03 -06:00
zkbot 92f3c6082a Auto merge of #889 - ebfull:new-imt-redux, r=ebfull
Implement and integrate new Incremental Merkle Tree

This supersedes #823.

----

This is an implementation of a new incremental merkle tree with

* no memory safety issues
* a more sensible internal design
* better space efficiency (tree representation, witnessing)
* simpler API

It is intended that this tracks the behavior of the previous tree, which it does, as verified by tests. I even wrote a little circuit for testing that all the paths work.

This PR also integrates the tree into the codebase and deprecates the old tree in almost all of our code. (I left it alone in `zerocashTest` but everything else has been changed.)

This change is compatible with the testnet but you will need to clear your *local* blockchain data out since the serialized representation of the merkle tree is now different.

Closes #517, Closes #519, Closes #591, Closes #460, Closes #473
2016-05-03 17:33:27 +00:00
Sean Bowe 6c36a9fe03 NoteEncryption implementation and integration, removal of ECIES and crypto++ dependencies. 2016-04-28 16:25:12 -06:00
Sean Bowe 1760b3cd88 Deprecate the old tree and remove old tree tests from the test suite. 2016-04-28 16:07:52 -06:00
Sean Bowe 434f328446 Integrate new incremental merkle tree implementation into consensus. 2016-04-28 16:07:52 -06:00
Taylor Hornby a1cd1a27ac Add verify equihash benchmark 2016-04-11 10:03:31 -06:00
Taylor Hornby d44feea44c Add JoinSplit verification benchmarks 2016-04-11 10:03:17 -06:00
Taylor Hornby bf8def9749 Add equihash solving benchmarks 2016-04-11 10:02:59 -06:00
Taylor Hornby 6962bb3df0 Add automated performance measurement system. 2016-04-11 08:15:25 -06:00
Sean Bowe 9ce86bec59 Remove type check on zcrawpour which is not necessary and causes errors with the RPC. 2016-01-20 14:53:27 -07:00
Nathan Wilcox 8cb250885c Replace magic 2s in rpcwallet and change > to != for arity checks. Replace magic 2's with named constants in test cases. 2016-01-19 14:36:18 -07:00
Nathan Wilcox f15b9549dc Implement online help for zcraw* commands. 2016-01-19 14:36:18 -07:00
Sean Bowe cf47198370 Fixed a couple incremental merkle tree bugs breaking consistency checks. 2016-01-19 14:36:10 -07:00
Sean Bowe a8ac403db0 Added mapAnchors consensus rules, finished zcrawpour/zcrawreceive.
Some specifics on consensus changes:
* Transactions must be anchored to a real anchor in the chain.
* Anchors are pushed and popped during ConnectBlock/DisconnectBlock as appropriate.
* DisconnectTip triggers evictions, under some circumstances, of transactions in the
  mempool which are anchored to roots that are no longer valid.
* Commitments append to the tree at the current best root during ConnectBlock.
2016-01-19 14:36:04 -07:00
Sean Bowe 730790f7a4 Added primitive zcrawkeygen/zcrawpour implementations 2016-01-19 14:36:04 -07:00
Veres Lajos 45bfa137ef PARTIAL: typofixes (found by misspell_fixer)
Upstream: 9f68ed6b6d1a9c6436ce37913666165f2b180ee3 (PR #6539)
2015-09-22 00:43:15 +00:00
Wladimir J. van der Laan 7ff9d122e4 Make sure LogPrintf strings are line-terminated
Fix the cases where LogPrint[f] was accidentally called without line
terminator, which resulted in concatenated log lines.

(see e.g. #6492)
2015-09-22 00:43:11 +00:00
Cory Fields 60457d3c2f locking: fix a few small issues uncovered by -Wthread-safety
- rpcwallet: No need to lock twice here
- openssl: Clang doesn't understand selective lock/unlock here. Ignore it.
- CNode: Fix a legitimate (though very unlikely) locking bug.
2015-09-22 00:43:10 +00:00
Philip Kaufmann daf956b7b1
fix crash on shutdown when e.g. changing -txindex and abort action
- fixes #3136
- the problem is related to Boost path and a static initialized internal
  pointer
- using a std::string in CDBEnv::EnvShutdown() prevents the problem
- this removes the boost::filesystem::path path field from CDBEnv

Github-Pull: #6282
Rebased-From: 0ce30eaa36295447c6e7f8d16a05798c746fe28a
2015-06-23 10:12:11 +02:00
Tom Harding c9fd9078ce
Fix getbalance *
Chance "getbalance *" not to use IsTrusted.  The method and result
now match the "getbalance <specific-account>" behavior. In
particular, "getbalance * 0" now works.

Also fixed a comment -- GetGalance has required 1 confirmation
for many years, and the default "getbalance *" behavior matches
that.

Github-Pull: #6276
Rebased-From: 7d6a85ab5b1dc96e0f3f6f835f27bb81ba2af919
2015-06-15 09:03:25 +02:00
Peter Todd 75a4d512cf
Fix off-by-one error w/ nLockTime in the wallet
Previously due to an off-by-one error the wallet ignored
nLockTime-by-height transactions that would be valid in the next block
even though they are accepted into the mempool. The transactions
wouldn't show up until confirmed, nor would they be included in the
unconfirmed balance. Similar to the mempool behavior fix in 665bdd3b,
the wallet code was calling IsFinalTx() directly without taking into
account the fact that doing so tells you if the transaction could have
been mined in the *current* block, rather than the next block.

To fix this we strip IsFinalTx() of non-consensus-critical
functionality, removing the default arguments, and add CheckFinalTx() to
check if a transaction will be final in the next block.

Github-Pull: #6183
Rebased-From: 28bf06236d3b385e95fe26a7a742395b30efd6ee
2015-06-01 12:35:49 +02:00
Wladimir J. van der Laan c7c9af381c
Merge pull request #5669
da29ecb Consensus: MOVEONLY: Move CValidationState from main consensus/validation (jtimon)
27afcd8 Consensus: Refactor: Decouple CValidationState from main::AbortNode() (Cory Fields)
2015-05-27 15:00:02 +02:00
Alex Morcos 2457dc43ac Change default nTxConfirmTarget to 2 2015-05-18 09:01:30 +02:00
Wladimir J. van der Laan 77ed59df4d wallet: Introduce constant for `-txconfirmtarget` default 2015-05-18 09:00:24 +02:00
Wladimir J. van der Laan 97ccfdca8a
Merge pull request #6137
a5baba5 minor: remove unneeded bool in CWalletDB::Recover (Philip Kaufmann)
2015-05-16 09:37:01 +02:00