Closes #1168. In that ticket I decided the optimization flags for dependencies are out of scope, i.e. we go with whatever the upstream package maintainer chose.
zkbot [Tue, 23 Aug 2016 02:11:30 +0000 (02:11 +0000)]
Auto merge of #1262 - ebfull:compressed-proofs, r=ebfull
Implement zkSNARK compression
Implement zkSNARK compression.
The serialization format of zkSNARKs has now been specified in our protocol specification. G1/G2 elements are now compressed into 33 byte and 65 byte formats, repsectively. `MONTGOMERY_OUTPUT` is enabled everywhere to make proving/verifying keys load faster and be consistent with the MPC.
Proofs are now 296 bytes. This PR also updates the proving and verifying keys.
Closes #1103. Closes #471.
See also https://github.com/zcash/libsnark/pull/3 and https://github.com/zcash/libsnark/pull/4
Jack Grigg [Sun, 14 Aug 2016 03:04:13 +0000 (15:04 +1200)]
Store the Equihash solution in minimal representation in the block header
The genesis blocks and miner tests have been regenerated, because changing the
block header serialisation format changes the block hash, and thus validity.
The Equihash solutions have been removed from the bloom test inputs for
simplicity (block validity is not checked there; only a valid serialisation is
necessary).
`nMinPingUsecTime` was left uninitialized in CNode.
The correct initialization for a minimum-until-now is int64_t's max value, so initialize it to that.
Thanks @MarcoFalke for noticing.
Jack Grigg [Sat, 13 Aug 2016 13:14:09 +0000 (01:14 +1200)]
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.
zkbot [Sun, 14 Aug 2016 21:21:58 +0000 (21:21 +0000)]
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.
zkbot [Sat, 6 Aug 2016 21:47:23 +0000 (21:47 +0000)]
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*"
zkbot [Fri, 5 Aug 2016 19:31:52 +0000 (19:31 +0000)]
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).
zkbot [Wed, 3 Aug 2016 23:11:44 +0000 (23:11 +0000)]
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.
zkbot [Mon, 1 Aug 2016 21:16:53 +0000 (21:16 +0000)]
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?