Commit graph

662 commits

Author SHA1 Message Date
Andrew Poelstra
7a3cbda848 sign.cpp: turn on SIGHASH_SCRIPT_RANGEPROOF when checking already-existing signatures
Currently when a user uses `signrawtransaction` on a transaction that is
already partially signed with SIGHASH_RANGEPROOF signatures, the existing
signatures will be deleted because they are not recognized as valid. This
makes it impossible to collabratively sign transactions using this RPC.
Fix this.
2021-09-19 14:18:13 +00:00
Andrew Poelstra
ab5b376b72 SignatureHash: fix rangeproof hash for SIGHASH_RANGEPROOF
The logic for computing the uncached version of the sighash changed during
the 0.21 rebase, such that it no longer matched the cached version. As the
changed hash is used during signing (not verification!), this was not a
forking change (and our existing functional test would have caught such a
forking change since it uses Python to independently compute the hash).
But it still broke signing.

Test in next commit.
2021-09-19 14:08:56 +00:00
Andrew Poelstra
4aad8c1a14 script: cache transaction weight per-transaction
This is an O(N) operation so we want to make sure that we're not recomputing
it every time we hit the INSPECTTXWEIGHT opcode.
2021-09-03 19:37:20 +00:00
Andrew Poelstra
68961ca60e Make consensus checking of tweaks in pubkey.* Taproot-specific
That results in a much safer interface (making the tweak commit
to the key implicitly using a fixed tag means it can't be used for
unrelated tweaking).

https://github.com/bitcoin/bitcoin/pull/22051 (5/9)
We actually preserve the "unrelated tweaking" method so we can
use it in OP_TWEAKVERIFY
2021-08-27 19:24:07 +00:00
sanket1729
2c5c7eb87b Update tapscript leaf version 2021-08-27 19:24:07 +00:00
sanket1729
7193636d09 Add crypto opcodes 2021-08-27 19:24:06 +00:00
sanket1729
4b9032209a Implement arithmetic opcodes 2021-08-26 20:28:01 +00:00
sanket1729
9346a8495e Implement transaction introspection opcodes 2021-08-26 20:28:01 +00:00
sanket1729
97b53e0b89 Cache Input/Output ScriptPubkeys sha256 2021-08-26 20:28:01 +00:00
sanket1729
61b5152d44 Expose transaction data via BaseSignatureChecker 2021-08-26 20:28:01 +00:00
sanket1729
2df8e99813 Implement Streaming SHA256 opcodes
Co-authored-by: roconnor-blockstream  <roconnor@blockstream.com>
2021-08-26 20:28:01 +00:00
sanket1729
2612017031 Address post merge feedback for Taphash 2021-08-17 16:25:00 +00:00
Andrew Poelstra
1ba24fe9b3
Merge ElementsProject/elements#1002: Implement Taproot Sighash
14f93579a5 Add pegins and issuance test (sanket1729)
edf8455fe4 Fix bug in CAssetIssuance decoding (sanket1729)
cdd75d4251 Update OP_SUCCESS for elements with allowed opcodes (sanket1729)
4618097ab4 Implement taphash for elements (sanket1729)
6c985308d7 Implement Taphash in test framework (sanket1729)
a26f6fead6 Expose only blockchain hash twice in header (sanket1729)
afb9e7b727 taproot: feed genesis hash and parent pegged asset to sighash function (Andrew Poelstra)

Pull request description:

ACKs for top commit:
  apoelstra:
    ACK 14f93579a5

Tree-SHA512: f0a3f6ef9f8958bc948cc42375600767f39aadc0dac096fe8e7823dc69ddc4204360e504af7801d05bb19ae4e6ace6a271842531c192e330167381cf2690c856
2021-07-07 20:58:41 +00:00
sanket1729
cdd75d4251 Update OP_SUCCESS for elements with allowed opcodes 2021-07-01 17:56:44 +00:00
sanket1729
4618097ab4 Implement taphash for elements 2021-07-01 17:56:44 +00:00
sanket1729
a26f6fead6 Expose only blockchain hash twice in header 2021-07-01 17:56:44 +00:00
Andrew Poelstra
afb9e7b727 taproot: feed genesis hash and parent pegged asset to sighash function 2021-07-01 17:56:44 +00:00
Andrew Chow
5b5c5efbbb Implement operator< for KeyOriginInfo and CExtPubKey 2021-06-22 13:54:50 -04:00
Andrew Chow
fad29bafd3 moveonly: Move (Un)Serialize(To/From)Vector, (De)SerializeHDKeypaths to psbt module
SerializeToVector, UnserializeFromVector, DeserializeHDKeypaths, and SerializeHDKeypaths
were in sign.h where PSBT was originally implemented. Since all of the PSBT serialization
has moved to its own file, these functions should follow.
2021-06-22 13:54:50 -04:00
Andrew Chow
e882a3a32d Types are compact size uints 2021-06-03 15:44:19 -04:00
Andrew Poelstra
fec99efb8f fix invalid memory access that I added when merging descriptor wallets
Thanks, ubsan + fuzzer!
2021-03-26 17:33:05 +00:00
Andrew Poelstra
e5ecee8d2d reduce cache sizes so that default maxsigcache size is same as Bitcoin
Bitcoin allocates 32M for signature caching by default, split
between a signature cache and a script validity cache (see
Core #10192). Since 0.14 we have added an additional 32M for
rangeproof caching *and* an additional 32M for surjectionproof
caching.

These cache entries cost a bit over 32 bytes, so these are room
for a million entries....or 4Gb of rangeproofs and 300M of
surjection proofs.

Presumably we did not intend to triple memory usage relative to
Core to deal with some champagne problem in which our mempool is
overfilled ten times with pure rangeproofs. So put the total
default cache size back to 32M. This should have no performance
hit under realistic circumstances and should reduce CI OOM failures.

On my system we now use 50M rather than 110M during the fedpeg
test; we still use 18M that Core does not by having three additional
global secp contexts (one in blind.cpp, one in pegins.cpp, one in
confidential_validation.cpp) but we can settle that in a future
commit.
2021-03-26 17:33:05 +00:00
Andrew Poelstra
68bfd70b43 ci: various linter / CI compiler error fixes
Includes changing TRUE to OP_TRUE for anyone-can-spend output name,
to avoid symbol conflict on win64 builds, which is really obnoxious.
2021-03-26 17:33:04 +00:00
Andrew Poelstra
22cf380984 Merge a993a7c675 into merged_master (Elements PR #960)
Several conflicts in the C++ code related to the new `flags` parameter
to `CheckSignature` and the corresponding function being renamed upstream
to `CheckSignatureECDSA`.

Several conflicts in the test harness as Steven sorta pulled the new
upstream ECKey module into the Python code, and the actual upstream
code was slightly different. Also needed to update the feature_taproot
code to always use the non-RANGEPROOF sighash since dynafed is not
enabled in the Taproot test.

Also had to pull the `set_wif` method out of `ECKey` and inline it because
otherwise it triggers a "circular inclusion" error between script.py (which
would pull in `base58_to_bytes` from address.py) and address.py (which now
pulls in some taproot EC related stuff from script.py).

Noticed that #960 does not test the "sighash rangeproof flag set but no
witnesses" case.
2021-03-25 23:46:21 +00:00
Steven Roose
691040a63d
Add SIGHASH_RANGEPROOF support 2021-02-22 15:19:09 +00:00
Andrew Poelstra
ce4acf6ba9 Merge 5d644778da into merged_master (Bitcoin PR #20169) 2020-12-01 05:40:44 +00:00
Andrew Poelstra
e765fc93ea Merge 3caee16946 into merged_master (Bitcoin PR #19953)
Taproot :D
2020-12-01 02:54:57 +00:00
Andrew Poelstra
369ebdda10 Merge 4f5ae52738 into merged_master (Bitcoin PR #20006) 2020-11-30 02:35:18 +00:00
Andrew Poelstra
07d50b2951 Merge c95784e3d3 into merged_master (Bitcoin PR #20016) 2020-11-29 22:31:43 +00:00
Andrew Poelstra
5c01234dcb Merge f8462a6d27 into merged_master (Bitcoin PR #19601) 2020-11-28 12:18:11 +00:00
Andrew Poelstra
3ca887d480 Merge d052f5e6b7 into merged_master (Bitcoin PR #16841) 2020-11-27 21:29:55 +00:00
Andrew Poelstra
e8b23b0198 Merge 4d4bd5ed74 into merged_master (Bitcoin PR #17204) 2020-11-27 19:53:57 +00:00
Andrew Poelstra
419fd4f90d Merge b75f2ad72d into merged_master (Bitcoin PR #19660) 2020-11-27 04:05:36 +00:00
Andrew Poelstra
54f2d85914 Merge 34eb236258 into merged_master (Bitcoin PR #19326) 2020-11-27 00:39:12 +00:00
Andrew Poelstra
10dd44bce4 Merge 31d2b4098a into merged_master (Bitcoin PR #19508) 2020-11-26 18:36:10 +00:00
Andrew Poelstra
473dea4c7b Merge 01f857a1c9 into merged_master (Bitcoin PR #19428) 2020-11-26 01:09:17 +00:00
Andrew Poelstra
0ffac0f3a2 Merge dbadf746e2 into merged_master (Bitcoin PR #19333) 2020-11-26 01:09:15 +00:00
Andrew Poelstra
dc44b27189 Merge d3a5dbfd1f into merged_master (Bitcoin PR #19114) 2020-11-26 01:09:14 +00:00
Andrew Poelstra
b431cfa2d7 Merge 532b134cb0 into merged_master (Bitcoin PR #19373) 2020-11-26 01:09:12 +00:00
Andrew Poelstra
fa10c4dfe5 Merge bd331bd745 into merged_master (Bitcoin PR #17938)
Also re-`static`'d a method in src/script/standard.cpp which we had made globally
visible for some historical reason, but which I noticed diffing that file against
upstream.
2020-11-26 01:09:10 +00:00
Andrew Poelstra
f60e6990c7 Merge 5f72ddb7ee into merged_master (Bitcoin PR #18863) 2020-11-26 01:09:09 +00:00
Andrew Poelstra
2468108f7b Merge b8740d6737 into merged_master (Bitcoin PR #18468) 2020-11-26 01:09:07 +00:00
Andrew Poelstra
195eb8a243 Merge 4ede05d421 into merged_master (Bitcoin PR #18758) 2020-11-26 01:08:58 +00:00
Andrew Poelstra
4d1d393cd6 Merge 9e8bd217cd into merged_master (Bitcoin PR #13204) 2020-11-26 01:08:56 +00:00
Andrew Poelstra
11afdcc66a Merge 9ccaee1d5e into merged_master (Bitcoin PR #19004) 2020-11-26 01:08:51 +00:00
Andrew Poelstra
4678564918 Merge cffbf1eb9a into merged_master (Bitcoin PR #19073) 2020-11-26 01:08:51 +00:00
Andrew Poelstra
f89b990b78 Merge 448bdff263 into merged_master (Bitcoin PR #18317) 2020-11-26 01:08:46 +00:00
Andrew Poelstra
530a413055 Merge 219c55da75 into merged_master (Bitcoin PR #16710) 2020-11-26 01:08:42 +00:00
Andrew Poelstra
7c5fd66303 Merge eb2ffbb7c1 into merged_master (Bitcoin PR #18914) 2020-11-26 01:08:41 +00:00
Andrew Poelstra
9ea76b54aa Merge 68ef9523d1 into merged_master (Bitcoin PR #18413) 2020-11-26 01:08:36 +00:00