Commit graph

228 commits

Author SHA1 Message Date
Russell O'Connor
1698454c2a Add Simplicity verification
Unactivated.
2024-10-07 14:39:09 -04:00
Russell O'Connor
96fb8f5d15 Store hash_genesis_block in PrecomputedTransactionData.
This will be used by Simplicity.
2024-10-07 14:39:09 -04:00
Russell O'Connor
52b92b8213 Cherry-pick <https://github.com/bitcoin/bitcoin/pull/27122>
Simplicity needs this fix.
2024-10-07 14:38:13 -04:00
Byron Hambly
a992ccaac2 Merge 196b459920 into merged_master (Bitcoin PR bitcoin/bitcoin#23438) 2023-06-29 08:37:35 +00:00
Byron Hambly
23ffcd4fc8 Merge bd482b3ffe into merged_master (Bitcoin PR bitcoin/bitcoin#24105) 2023-06-21 11:44:35 +00:00
Byron Hambly
47626b5a64 Merge 623745ca74 into merged_master (Bitcoin PR bitcoin/bitcoin#23912) 2023-06-14 15:44:11 +00:00
James Dorfman
72a90148c8 Merge 8b1de78577 into merged_master (Bitcoin PR bitcoin/bitcoin#23413) 2023-06-01 18:51:42 +00:00
Byron Hambly
1beaa601b4 Merge 5ccab7187b into merged_master (Bitcoin PR bitcoin/bitcoin#23394)
- commented out some script tests that need to be fixed
 - commented out feature_taproot.py since it needs significant updates
2023-05-26 09:14:20 +00:00
Byron Hambly
c70b9b1b43 Merge a93e7a4422 into merged_master (Bitcoin PR bitcoin/bitcoin#22748) 2023-04-10 13:22:14 +00:00
James Dorfman
91eba3427c Merge a3791da0e8 into merged_master (Bitcoin PR bitcoin/bitcoin#22428) 2023-03-21 16:20:59 +00:00
roconnor-blockstream
707cf20b12
Fix tapscript comment
In elements tapscript is verison 0xc4
2022-08-12 11:56:15 -04:00
laanwj
196b459920
Merge bitcoin/bitcoin#23438: refactor: Use spans of std::byte in serialize
fa5d2e678c Remove unused char serialize (MarcoFalke)
fa24493d63 Use spans of std::byte in serialize (MarcoFalke)
fa65bbf217 span: Add BytePtr helper (MarcoFalke)

Pull request description:

  This changes the serialize code (`.read()` and `.write()` functions) to take a `Span` instead of a pointer and size. This is a breaking change for the serialize interface, so at no additional cost we can also switch to `std::byte` (instead of using `char`).

  The benefits of using `Span`:
  * Less verbose and less fragile code when passing an already existing `Span`(-like) object to or from serialization

  The benefits of using `std::byte`:
  * `std::byte` can't accidentally be mistaken for an integer

  The goal here is to only change serialize to use spans of `std::byte`. If needed, `AsBytes`,  `MakeUCharSpan`, ... can be used (temporarily) to pass spans of the right type.

  Other changes that are included here:

  * [#22167](https://github.com/bitcoin/bitcoin/pull/22167) (refactor: Remove char serialize by MarcoFalke)
  * [#21906](https://github.com/bitcoin/bitcoin/pull/21906) (Preserve const in cast on CTransactionSignatureSerializer by promag)

ACKs for top commit:
  laanwj:
    Concept and code review ACK fa5d2e678c
  sipa:
    re-utACK fa5d2e678c

Tree-SHA512: 08ee9eced5fb777cedae593b11e33660bed9a3e1711a7451a87b835089a96c99ce0632918bb4666a4e859c4d020f88fb50f2dd734216b0c3d1a9a704967ece6f
2022-01-27 19:19:12 +01:00
Jeremy Rubin
cfa575266b Optimize CHECKSIGADD Script Validation 2022-01-19 15:21:52 -08:00
MarcoFalke
fa24493d63
Use spans of std::byte in serialize
This switches .read() and .write() to take spans of bytes.
2022-01-02 11:40:31 +01:00
Hennadii Stepanov
f47dda2c58
scripted-diff: Bump copyright headers
-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./
-END VERIFY SCRIPT-

Commits of previous years:
* 2020: fa0074e2d8
* 2019: aaaaad6ac9
2021-12-30 19:36:57 +02:00
Pieter Wuille
11daf6ceb1 More Span simplifications
Based on suggestions by MarcoFalke <falke.marco@gmail.com>
2021-11-29 17:59:44 -05:00
Pieter Wuille
f1c33ee4ac tests: implement BIP341 test vectors 2021-11-12 12:05:00 -05:00
Andrew Poelstra
ba8273ac94 lint: fix non-pylint linter errors
Includes fixing all the spelling mistakes that are our fault,
but not those present upstream in Core.
2021-10-15 00:20:20 +00:00
Andrew Poelstra
6c368ab1a3 Merge a1726c555b into merged_master (Elements PR ElementsProject/elements#1045) 2021-09-21 20:32:03 +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
483cb768f1 Merge 904054ffcb into merged_master (Elements PR ElementsProject/elements#1032) 2021-09-05 21:51:07 +00:00
Andrew Poelstra
6387aaf765 Merge feee029d29 into merged_master (Elements PR ElementsProject/elements#1020)
Messy merge conflicts because this PR backported some ad-hoc stuff from
upstream while keeping a few things that upstream deleted. Hopefully
reviewing is easier than doing this in the first place, since ultimately
all I did was delete code from one side or another of the conflicts.
(Ok, I also changed some boost optional stuff to std::optional, and had
to patch up a test file for test framework changes.)

When reviewing the detailed crypto, bear in mind that taptweaks, like all
hashes are the kind of crypto that cannot be subtly wrong -- it will either
fail very hard or be correct. And we have independent implementations in
C++ and Python that cross-check each other, si it's unlikely to be the former.
2021-09-05 13:42:34 +00:00
Andrew Poelstra
cf8ced903b Merge 0b8174b1fe into merged_master (Elements PR ElementsProject/elements#1023) 2021-09-05 02:42:13 +00:00
Andrew Poelstra
7d1c77f0a1 Merge 1ba24fe9b3 into merged_master (Elements PR ElementsProject/elements#1002)
This forward-ports the new Taproot sighash but does not fix a couple
22-blocked TODOs related to the MissingDataBehavior enum. Should be fixed
in a followup commit.

One nontrivial change I had to make was feeding the genesis hash to SignTransaction
(the "global" one in script/sign.cpp) so that it could correctly compute
the sighash at signing time.
2021-09-04 22:14:42 +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
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
Pieter Wuille
2f0190320d Avoid temporary vectors/uint256s in VerifyTaprootCommitment
As XOnlyPubKey has a Span-based constructor, that can be used directly
without needing to first convert the byte sequence into a vector, only
to convert that to a uint256, which only then can then be passed as a
span to the constructor.
2021-08-20 14:30:59 -04:00
sanket1729
2612017031 Address post merge feedback for Taphash 2021-08-17 16:25:00 +00:00
Andrew Poelstra
29a49051ba Merge e1a13f12e1 into merged_master (Bitcoin PR bitcoin/bitcoin#18096) 2021-07-29 16:18:42 +00:00
Andrew Poelstra
a503005be7 Merge 567670bec5 into merged_master (Bitcoin PR bitcoin/bitcoin#22166) 2021-07-28 14:42:42 +00:00
Andrew Poelstra
0afcb6d978 Merge 5c2e2afe99 into merged_master (Bitcoin PR bitcoin/bitcoin#21365)
This introduces Taproot wallet support. I fixed all the merge conflicts
and ensured that the tests pass, but this is still using the old sighash
(before Russell/Sanket/I redid it) so is not actually production ready.
Will be fixed when we bring Elements #1002 in.
2021-08-03 20:43:53 +00:00
Andrew Poelstra
3ffb9aa14f Merge c7dd9ff71b into merged_master (Bitcoin PR bitcoin/bitcoin#22051)
Does the bare minimum to introduce Taproot wallet support with CT; just
adds a CPubKey blinding_pubkey to the taproot destination variant and
updates some visitors.

In future when we define blech32 we will need to make sure we are using
that encoding and using the pubkey.
2021-07-21 23:15:57 +00:00
sanket1729
007910388b [Refactor] Rename scriptPubKey -> exec_script
Rename misleading scriptPubKey in ExecuteWitnessScript() function to
correctly relfect what is being executed.
2021-07-19 03:16:00 -07:00
Andrew Poelstra
3850e85010 Merge 32f1f021bf into merged_master (Bitcoin PR bitcoin/bitcoin#21817) 2021-07-07 02:29:25 +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
MarcoFalke
e1a13f12e1
Merge bitcoin/bitcoin#18096: doc: IsFinalTx comment about nSequence & OP_CLTV
f9e37f33ce doc: IsFinalTx comment about nSequence & OP_CLTV (Yuval Kogman)

Pull request description:

  It's somewhat surprising that a transaction's `nLockTime` field is ignored
  when all `nSequence` fields are final, so this change aims to clarify this
  behavior and cross reference relevant details of `OP_CHECKLOCKTIMEVERIFY`.

ACKs for top commit:
  MarcoFalke:
    ACK f9e37f33ce

Tree-SHA512: 88460dacbe4b8115fb1948715f09b21d4f34ba1da9e88d52f0b774a969f845e9eddc5940e7fee66eacdd3062dc40d6d44c3f282b0e5144411fd47eb2320b44f5
2021-06-30 09:43:21 +02:00
Andrew Poelstra
9645faf781 Merge bd65a76b9d into merged_master (Bitcoin PR #21330) 2021-06-30 01:43:54 +00:00
Andrew Poelstra
90f1f6650b Merge fbf5d16238 into merged_master (Bitcoin PR #21246) 2021-06-26 01:58:32 +00:00
Pieter Wuille
29e5dd1a5b consensus refactor: extract ComputeTapleafHash, ComputeTaprootMerkleRoot 2021-06-18 11:23:17 -07:00
Andrew Poelstra
e5cb4cb00e Merge f13e03cda2 into merged_master (Bitcoin PR #20584) 2021-06-16 20:58:56 +00:00
Pieter Wuille
ce9353164b Permit full precomputation in PrecomputedTransactionData
At verification time, the to be precomputed data can be inferred from
the transaction itself. For signing, the necessary witnesses don't
exist yet, so just permit precomputing everything in that case.
2021-06-12 12:25:28 -07:00
Pieter Wuille
e77a2839b5 Use HandleMissingData also in CheckSchnorrSignature 2021-06-12 12:25:28 -07:00