Reduce unnecessary hashing in signrawtransaction#8118
Merged
laanwj merged 1 commit intobitcoin:masterfrom Jun 7, 2016
Merged
Conversation
Member
|
utACK bd0f413 |
1 similar comment
Contributor
|
utACK bd0f413 |
Contributor
|
utACK bd0f413 |
Contributor
|
Probably worth noting, from my searches, it appears that |
Member
|
utACK bd0f413
Good observation, I suppose it could be moved, or maybe the use there could be avoided too and then removed. |
laanwj
added a commit
that referenced
this pull request
Jun 7, 2016
bd0f413 Reduce unnecessary hashing in signrawtransaction (Jonas Nick)
codablock
pushed a commit
to codablock/dash
that referenced
this pull request
Dec 22, 2017
bd0f413 Reduce unnecessary hashing in signrawtransaction (Jonas Nick)
zkbot
added a commit
to zcash/zcash
that referenced
this pull request
Feb 8, 2018
Overwinter SignatureHash Implements zcash/zips#129. Includes code cherry-picked from the following upstream PRs: - bitcoin/bitcoin#7276 - bitcoin/bitcoin#7976 - bitcoin/bitcoin#8118 - bitcoin/bitcoin#8149 - Only amount validation and SignatureHash commits. - bitcoin/bitcoin#6915 - Only the rework of `mempool.check()` calls that the next PR depends on. - bitcoin/bitcoin#8346 - bitcoin/bitcoin#8524 Part of #2254. Closes #1408 and #2584.
zkbot
added a commit
to zcash/zcash
that referenced
this pull request
Feb 19, 2018
Overwinter SignatureHash Implements zcash/zips#129. Includes code cherry-picked from the following upstream PRs: - bitcoin/bitcoin#7276 - bitcoin/bitcoin#7976 - bitcoin/bitcoin#8118 - bitcoin/bitcoin#8149 - Only amount validation and SignatureHash commits. - bitcoin/bitcoin#6915 - Only the rework of `mempool.check()` calls that the next PR depends on. - bitcoin/bitcoin#8346 - bitcoin/bitcoin#8524 Part of #2074 and #2254. Closes #1408 and #2584.
zkbot
added a commit
to zcash/zcash
that referenced
this pull request
Feb 20, 2018
Overwinter SignatureHash Implements ZIP 143. Includes code cherry-picked from the following upstream PRs: - bitcoin/bitcoin#7276 - bitcoin/bitcoin#7976 - bitcoin/bitcoin#8118 - bitcoin/bitcoin#8149 - Only amount validation and SignatureHash commits. - bitcoin/bitcoin#8346 - bitcoin/bitcoin#8524 Part of #2074 and #2254. Closes #1408 and #2584.
zkbot
added a commit
to zcash/zcash
that referenced
this pull request
Feb 20, 2018
Overwinter SignatureHash Implements ZIP 143. Includes code cherry-picked from the following upstream PRs: - bitcoin/bitcoin#7276 - bitcoin/bitcoin#7976 - bitcoin/bitcoin#8118 - bitcoin/bitcoin#8149 - Only amount validation and SignatureHash commits. - bitcoin/bitcoin#8346 - bitcoin/bitcoin#8524 Part of #2074 and #2254. Closes #1408 and #2584.
andvgal
pushed a commit
to energicryptocurrency/gen2-energi
that referenced
this pull request
Jan 6, 2019
bd0f413 Reduce unnecessary hashing in signrawtransaction (Jonas Nick)
random-zebra
added a commit
to PIVX-Project/PIVX
that referenced
this pull request
Aug 5, 2020
d1d15c8 Fix missing sigverion in main_test.cpp CreateDummyScriptSigWithKey. (furszy) a034daf Rename to PrecomputedTransactionData (furszy) b4b181b Unit test for sighash caching (furszy) 2ef3872 Report non-mandatory script failures correctly. (furszy) 446d340 Precompute sighashes (furszy) dfd24eb Update wallet_txn_close.py test: (furszy) a5170f0 BIP143: Signing logic. (furszy) d2dd547 BIP143: Verification logic. (furszy) dccc3c6 Refactor script validation to observe amounts (furszy) daf044a Reduce unnecessary hashing in signrawtransaction (furszy) Pull request description: Base work for the new transaction digest algorithm for signature verification on PIVX Sapling transactions. Essentially, an implementation of BIP143 + few more good commits that found down the rabbit hole. Back ports: * bitcoin#7276 * bitcoin#7976 * bitcoin#8118 * bitcoin#8149 (only amount validation and SignatureHash commits). * bitcoin#6088 (only the dummy signature one - will be removed once #1663 get merged -). * bitcoin#6379 * bitcoin#8524 Next step over this area (need 1553 merged to be able to push it) is the further specialization of BIP143 into our custom implementation of ZIP143 (with a different digest algorithm definition using our tx data and hash personalization). ACKs for top commit: Fuzzbawls: utACK d1d15c8 random-zebra: ACK d1d15c8 and merging... Tree-SHA512: 7665cccf095c5bce0b18ef7ab8fcf7bede9304993b48f1af9c352c568861dec728d1d68671aab857b73d46567678492c4b97c24644a15f3f29fc4d723b183522
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When calling
CombineSignaturesandVerifyScriptinside signrawtransaction with aCMutableTransaction, the tx is converted into aCTransactionwhich requires hashing.Because both
CombineSignaturesandVerifyScriptaccept thescriptSigcreated bySignSignatureseparately from the transaction we can instead convert the mutable tx toCTransactiononce and use that one.Results:
1000 inputs, 75kB before signing: 2.86s vs. 4.88s
Signature concatenation of three 250kB transactions with 1000 inputs: 8.638s vs. 19.142s
There still remains some unnecessary hashing, but fixing this requires a larger refactor:
SignSignaturerequires aCMutableTransactionbecause it changes the scriptSig in place. But it also immediately creates aCTransaction(costly) for aTransactionSignatureChecker. Using aMutableTransactionSignatureCheckeris not an option because it immediately converts the mutable transaction to aCTransaction. Instead, theTransactionSignatureCheckershould be able to deal withCMutableTransactionwithout rehashing.