Commit Graph

9138 Commits

Author SHA1 Message Date
Jack Grigg
20abe2083c Extend byte array expansion and compression methods with optional padding 2016-08-16 11:02:04 +12:00
Jack Grigg
caa0348f04 Update Equihash hash generation to match the Zcash spec
Changes:

- floor(512/n)*n/8 bytes of BLAKE2b output is split between floor(512/n)
  adjacent indices, instead of using one hash call per index.

- Parameters with n/(k+1) mod 8 != 0 will expand the BLAKE2b output to byte
  boundaries for colliding, instead of using a longer output and clearing bits.

- The genesis blocks have been regenerated.

- The test vectors have been regenerated.

- The Equihash inputs for the cancellation tests were modified to ensure that
  valid solutions were available to exercise the full solver.
2016-08-16 11:02:04 +12:00
Jack Grigg
881ffbfc87 Add methods for byte array expansion and compression
These methods convert between:

- A byte array of length NL/8, and
- An array of N blocks of ceil(L/8) bytes.
2016-08-16 11:02:00 +12:00
zkbot
d7da4ecc33 Auto merge of #1194 - bitcartel:zc.v0.11.2.z8_issue_1193_fixtest, r=ebfull
Improve speed and accuracy of zcbenchmark validatelargetx

The verification test, in a loop, passes `spending_tx` (a `CMutableTransaction`) to the constructor of `MutableTransactionSignatureChecker`, which immediately uses it to create a non-mutable `CTransaction` object, which is used for the actual verification process.

Since `spending_tx` is not mutated during the verification loop & process, we can instead convert it to a `CTransaction` just once, and use it with `TransactionSignatureChecker`.

This removes the time to create `CTransaction` objects from the benchmark itself.

Results show an improvement in running time to complete the verification phase of the test and consistent times across z7 and z8 releases.

```
Benchmarks on i3 processor:
z7 old 228.67205900 --> z7 new 49.27225200
z7 old 229.90048900 --> z7 new 48.38650700
z8 old 295.77963800 --> z8 new 48.37695100
z8 old 294.32640100 --> z8 new 49.93216100
```
2016-08-14 21:21:58 +00:00
Taylor Hornby
998eea5db6 Disable hardening when building for coverage reports. 2016-08-11 15:15:50 -06:00
Simon
75c2f26887 Update variable. 2016-08-08 00:51:27 -07:00
Simon
822b84b616 Fixes #1193 so that during verification benchmarking it does not
unncessarily create thousands of CTransaction objects.
2016-08-07 23:57:39 -07:00
Simon
a8270035c0 Release process for z8. Issue #1140. 2016-08-06 15:37:24 -07:00
zkbot
0822971120 Auto merge of #1183 - bitcartel:zc.v0.11.2.latest_txid_tests, r=bitcartel
Add gtest for non-malleable txids.

1. Test txid of normal transaction is double sha256 with sigscript input data removed
2. Test txid of coinbase transaction is double sha256 over whole tx

You can run a single test with:
./zcash-gtest --gtest_filter="txid_tests*"
2016-08-06 21:47:23 +00:00
Simon
2a7fde3f42 Add test for non-malleable txids. To run just this test:
./zcash-gtest --gtest_filter="txid_tests*"
2016-08-05 22:54:21 -07:00
Jack Grigg
23acf86791 Ignore duplicate entries after partial recreation 2016-08-06 17:33:38 +12:00
Jack Grigg
a23507d086 Update tests to account for new Equihash parameters 2016-08-06 17:33:23 +12:00
Jack Grigg
ca202e2db1 Change Equihash parameters to n = 200, k = 9 (about 563-700 MiB) 2016-08-06 15:27:27 +12:00
Jack Grigg
30bd297920 Fix bug in IsProbablyDuplicate()
Closes #1179
2016-08-06 15:26:22 +12:00
Jack Grigg
fa19e1b357 Add test showing bug in IsProbablyDuplicate() 2016-08-06 15:23:47 +12:00
Jack Grigg
eeb4177843 Add Equihash support for n = 200, k = 9
Closes #1177
2016-08-06 10:33:14 +12:00
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
zkbot
e5b57a1432 Auto merge of #1173 - str4d:1165-equihash-fix-large-k-ballooning, r=bitcartel
Eliminate some of the duplicates caused by truncating indices

Closes #1165
2016-08-05 17:35:35 +00:00
zkbot
76470978f4 Auto merge of #1172 - str4d:1148-remove-equihash-collision-length-assumption, r=bitcartel
Remove the assumption that n/(k+1) is a multiple of 8

This version works, but generates the initial rows in a way that is probably
not what we want to specify.

Closes #1148
2016-08-05 16:53:28 +00:00
Jack Grigg
036dcbd94a Remove the assumption that n/(k+1) is a multiple of 8.
This version works, but generates the initial rows in a way that is not what we
want to specify. See #1175 for resolving this.

Co-author: Daira Hopwood <daira@jacaranda.org>
2016-08-06 02:40:07 +12:00
Jack Grigg
649be423f8 Fix previous commit 2016-08-06 02:03:08 +12:00
Jack Grigg
6609813753 Simplify optional parameters 2016-08-06 00:36:33 +12:00
Jack Grigg
3c3ef34505 Add missing assert 2016-08-05 22:24:04 +12:00
Jack Grigg
e999c1e339 Simplify IsProbablyDuplicate() 2016-08-05 22:17:40 +12:00
Jack Grigg
3c654f38eb Eliminate probably duplicates in final round
This is more likely to eliminate valid solutions than doing so in intermediate
rounds, but the probability is still very low.
2016-08-05 18:15:34 +12:00
Jack Grigg
6b4f4475a5 Use fixed-size array in IsProbablyDuplicate to avoid stack protector warning 2016-08-05 17:18:47 +12:00
Jack Grigg
d4af3dd5fd Eliminate some of the duplicates caused by truncating indices 2016-08-05 17:09:30 +12:00
Jack Grigg
f7478de67f Add thread parameter to solveequihash benchmark
Closes #1147
2016-08-05 15:05:38 +12:00
Simon
fbd90518e3 Use -O1 opimitization flag when building libzcash.
Continuation of #1064 and related to #1168.
2016-08-03 22:41:28 -07:00
zkbot
9cc43696ec Auto merge of #1086 - zcash:daira-simplify-readme-title, r=bitcartel
README.md: simplify the title, drop "Core"

We only have one public tree.
2016-08-04 01:33:43 +00:00
zkbot
abd4c16ae9 Auto merge of #1064 - ThisIsNotOfficialCodeItsJustForks:t915-enable-security-hardening, r=bitcartel
Verify security hardening features are turned on
2016-08-03 23:57:05 +00:00
zkbot
1f7e1f68c6 Auto merge of #1157 - ThisIsNotOfficialCodeItsJustForks:t761-run-tests-under-valgrind, r=nathan-at-least
[WIP] Add more commands to run unit tests under valgrind.

This runs both zcash-gtest and test_bitcoin under valgrind. There's a corresponding PR to the buildbot config https://github.com/Electric-Coin-Company/bbotzc/pull/23. Closes #761.
2016-08-03 23:11:44 +00:00
zkbot
a40d70f464 Auto merge of #1160 - str4d:1131-remove-hardfork, r=bitcartel
Remove hardfork from special testnet difficulty rules

Closes #1131
2016-08-03 17:56:32 +00:00
zkbot
19b49de082 Auto merge of #1158 - bitcartel:zc.v0.11.2.latest_1126_trycatch, r=ebfull
Extend try catch block around call to libsnark verifier

As discussed in #1126.

@daira Per your [comment](https://github.com/zcash/zcash/pull/1126#issuecomment-234714939):

> I would like assertion errors during tests to cause a test failure (unless the test explicitly expects them). Can we split this into verify and verify_internal, where the former does the try/catch around a call to verify_internal, and the latter is called by verification unit tests?

Did you mean move everything inside the extended try/catch to verify_internal, or just the call to r1cs_ppzksnark_verifier_strong_IC?
2016-08-01 21:16:53 +00:00
Simon
74cd8821c7 Remove GetSerializeHash() method. 2016-07-29 23:28:34 -07:00
zkbot
4714ea145b Auto merge of #1146 - str4d:1143-equihash-solution-callback, r=ebfull
Equihash: Pass each obtained solution to a callback for immediate checking

Closes #1143
2016-07-30 02:59:12 +00:00
Jack Grigg
4a0bdc9020 Fix bug in 'generate' RPC method that caused it to fail with high probability 2016-07-30 01:28:17 +12:00
Jack Grigg
9e0713f47f Remove hardfork from special testnet difficulty rules
Closes #1131
2016-07-29 21:46:27 +12:00
Simon
d81c31f5fb Extend try catch block around calls to libsnark, per discussion in #1126. 2016-07-29 00:02:22 -07:00
Simon
c63af91a78 Update comment. 2016-07-28 18:44:00 -07:00
Simon
3979881fc5 Fix comment. 2016-07-28 16:40:01 -07:00
Taylor Hornby
88325d8abb Add more commands to run unit tests under valgrind. 2016-07-28 14:43:36 -06:00
zkbot
b2e956be01 Auto merge of #1137 - bitcartel:zc.v0.11.2.latest_deprecate_zcraw_api, r=ebfull
zcash-cli: Label zcraw... rpc commands as being deprecated

These RPC calls will be removed from 1.0, so let's mark them as deprecated.
2016-07-28 17:25:52 +00:00
Simon
eae3794152 Update deprecation message for zcraw api. 2016-07-27 21:40:26 -07:00
Simon
92f7426d19 Make txid const. 2016-07-27 12:14:44 -07:00
Simon
0ccb650b5a Update genesis block hashes and test data. 2016-07-27 00:55:48 -07:00
Simon
90a9019387 Fix issue where a coinbase tx should have it's sigscript hashed
to avoid duplicate txids, as discussed in BIP34 and BIP30.
2016-07-27 00:52:27 -07:00
Simon
2481bab2b8 Revert "Set nLockTime in CreateNewBlock() so coinbase txs do not have the same txid."
This reverts commit 29306269f4.
2016-07-27 00:41:26 -07:00
Jack Grigg
51eb5273f5 Equihash: Pass each obtained solution to a callback for immediate checking
Closes #1143
2016-07-27 19:15:49 +12:00
Simon
07e6d5b025 Refactor GetTxid() into UpdateTxid() to match coding style of hash member variable.
UpdateTxid() is called alongside UpdateHash() when a CTransaction is
deserialized or constructed.  GetTxid() now returns a const reference.
2016-07-26 17:13:03 -07:00