Commit graph

252 commits

Author SHA1 Message Date
Russell O'Connor
31d94775b3 Update to latest Simplicity
The main difference is that there is now explicit simplicity deallocation functions to go with the allocation functions in the API.
There are some minor changes to error message text.
The deserialization code is now automatically generated.
The are some other minor internal changes.
2025-02-04 12:14:25 -05:00
Christian Lewe
508836028e Asset tests: Check script error
Compare the expected script error, parsed from JSON, with the actual
error that VerifyScript returns. If the JSON does not include an
expected error, then skip this check.
2024-10-07 14:39:10 -04:00
Russell O'Connor
4ca2411795 Asset tests: Parse Elements script errors
Take the existing function to parse script errors and extend it to parse
Elements errors. SCRIPT_ERR_ERROR_COUNT is not included because it is a
pseudo error.
2024-10-07 14:39:10 -04:00
Russell O'Connor
bcd508f409 Add Simplicity Deployment structure 2024-10-07 14:39:10 -04:00
James Dorfman
08010b821f test: fix failing schnorr sig creation in bip341_keypath_test_vectors 2023-11-09 06:31:49 +00:00
Byron Hambly
69e09aa2ea
fix: comment out unused variable until tests are fixed 2023-09-07 16:06:03 +02:00
Byron Hambly
8dbf577aaa Merge cfc10a5dd6 into merged_master (Elements PR #1232) 2023-07-03 13:48:57 +00:00
Byron Hambly
4988afcbc2 Merge 3ace3a17c9 into merged_master (Bitcoin PR bitcoin/bitcoin#20744) 2023-06-30 07:38:29 +00:00
Byron Hambly
a992ccaac2 Merge 196b459920 into merged_master (Bitcoin PR bitcoin/bitcoin#23438) 2023-06-29 08:37:35 +00:00
Byron Hambly
6bd5dfb3bd Merge d87a37a4ab into merged_master (Bitcoin PR bitcoin/bitcoin#24167) 2023-06-28 16:52:04 +00:00
Byron Hambly
47626b5a64 Merge 623745ca74 into merged_master (Bitcoin PR bitcoin/bitcoin#23912) 2023-06-14 15:44:11 +00:00
Byron Hambly
5cbd44f1c8
test: re-enable and fix script assets test
Re-enables and fixes the script_assets_test by changing feature_taproot.py to include the genesis block hash when dumping the json tests.

Requires the json file from https://github.com/ElementsProject/qa-assets/pull/1

Co-authored-by: Andrew Poelstra <apoelstra@wpsoftware.net>
2023-06-05 16:43:06 +02:00
Byron Hambly
e4003da763 Merge b7e63306e8 into merged_master (Bitcoin PR bitcoin/bitcoin#23687) 2023-06-02 12:06:39 +00:00
James Dorfman
72a90148c8 Merge 8b1de78577 into merged_master (Bitcoin PR bitcoin/bitcoin#23413) 2023-06-01 18:51:42 +00:00
James Dorfman
84d20582c4 Merge fd1c9e26d3 into merged_master (Bitcoin PR bitcoin/bitcoin#23653) 2023-06-01 17:20:28 +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
James Dorfman
ab7a42420a Merge e826b22da2 into merged_master (Bitcoin PR bitcoin/bitcoin#22275) 2023-04-10 19:25:44 +00:00
James Dorfman
400c44abcc Merge 9faa4b68db into merged_master (Bitcoin PR #22232) 2023-03-16 04:51:52 +00:00
Kiminuo
41d7166c8a
refactor: replace boost::filesystem with std::filesystem
Warning: Replacing fs::system_complete calls with fs::absolute calls
in this commit may cause minor changes in behaviour because fs::absolute
no longer strips trailing slashes; however these changes are believed to
be safe.

Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2022-02-03 18:35:52 +08: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
fanquake
5e8975e269
fs: consistently use fsbridge for fopen() 2022-01-26 22:08:29 +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
31ba1af74a Remove unused (and broken) functionality in SpanReader
This removes the ability to set an offset in the SpanReader constructor,
as the current code is broken. All call sites use pos=0, so it is actually
unused. If future call sites need it, SpanReader{a, b, c, d} is equivalent
to SpanReader{a, b, c.subspan(d)}.

It also removes the ability to deserialize from SpanReader directly from
the constructor. This too is unused, and can be more idiomatically
simulated using (SpanReader{a, b, c} >> x >> y >> z) instead of
SpanReader{a, b, c, x, y, z}.
2021-12-06 16:18:14 -05:00
MarcoFalke
8b1de78577
Merge bitcoin/bitcoin#23413: Replace MakeSpan helper with Span deduction guide
11daf6ceb1 More Span simplifications (Pieter Wuille)
568dd2f839 Replace MakeSpan helper with Span deduction guide (Pieter Wuille)

Pull request description:

  C++17 supports [user-defined deduction guides](https://en.cppreference.com/w/cpp/language/class_template_argument_deduction), allowing class constructors to be invoked without specifying class template arguments. Instead, the code can contain rules to infer the template arguments from the constructor argument types.

  This alleviates the need for the `MakeSpan` helper. Convert the existing MakeSpan rules into deduction rules for `Span` itself, and replace all invocations of `MakeSpan` with just `Span` ones.

ACKs for top commit:
  MarcoFalke:
    re-ACK 11daf6ceb1 Only change is removing a hunk in the tests 🌕

Tree-SHA512: 10f3e82e4338f39d9b7b407cd11aac7ebe1e9191b58e3d7f4e5e338a4636c0e126b4a1d912127c7446f57ba356c8d6544482e47f97901efea6a54fffbfd7895f
2021-12-03 10:44:37 +01:00
Pieter Wuille
2c35a93b3c Generalize/simplify VectorReader into SpanReader 2021-12-02 14:47:17 -05:00
Pieter Wuille
568dd2f839 Replace MakeSpan helper with Span deduction guide 2021-11-29 17:58:53 -05:00
Pieter Wuille
f1c33ee4ac tests: implement BIP341 test vectors 2021-11-12 12:05:00 -05: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
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
sanket1729
2df8e99813 Implement Streaming SHA256 opcodes
Co-authored-by: roconnor-blockstream  <roconnor@blockstream.com>
2021-08-26 20:28:01 +00:00
Pieter Wuille
d8f4b976d5 Remove default nHashTypeIn arguments to MutableTransactionSignatureCreator
These were unused except in tests, and were also overlooked when changing
SIGHASH_ALL -> SIGHASH_DEFAULT.
2021-08-20 14:29:23 -04:00
Andrew Poelstra
9ea813efb8 Merge 4a26705761 into merged_master (Bitcoin PR bitcoin/bitcoin#21902) 2021-07-09 00:08:06 +00:00
Andrew Poelstra
3850e85010 Merge 32f1f021bf into merged_master (Bitcoin PR bitcoin/bitcoin#21817) 2021-07-07 02:29:25 +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 Poelstra
9645faf781 Merge bd65a76b9d into merged_master (Bitcoin PR #21330) 2021-06-30 01:43:54 +00:00
MarcoFalke
fa621ededd
refactor: Pass script verify flags as uint32_t
They are cast to unsigned anyway when calling VerifyScript,
bitcoinconsensus_verify_script*, or CountWitnessSigOps.
2021-06-14 08:02:45 +02:00
MarcoFalke
fa4bbd306e
refactor: Remove useless extern keyword 2021-05-10 09:09:24 +02:00
MarcoFalke
fac30eec42
refactor: Replace &foo[0] with foo.data() 2021-05-04 06:55:31 +02:00
Andrew Poelstra
ee5d4e3256 ci: temporarily disable qa-assets unit tests
These "pass" locally but in CI they download pre-signed transactions
from https://github.com/bitcoin-core/qa-assets/ which we need to
fork and recreate.

Essentially these files are the output of the Taproot functional
test (which passes), so I am not too worried about actual failures
here. But we should wait until after the Taproot sighash is finalized
to recreate these assets.
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
Pieter Wuille
3820090bd6 Make all SignatureChecker explicit about missing data
Remove the implicit MissingDataBehavior::ASSERT_FAIL in the
*TransationSignatureChecker constructors, and instead specify
it explicit in all call sites:
* Test code uses ASSERT_FAIL
* Validation uses ASSERT_FAIL (through CachingTransactionSignatureChecker)
  (including signet)
* libconsensus uses FAIL, matching the existing behavior of the
  non-amount API (and the extended required data for taproot validation
  is not available yet)
* Signing code uses FAIL
2021-03-15 17:29:39 -07:00
Steven Roose
691040a63d
Add SIGHASH_RANGEPROOF support 2021-02-22 15:19:09 +00:00
Andrew Poelstra
76437996fb Merge 88776c2926 into merged_master (Bitcoin PR #20245) 2020-12-02 03:12:26 +00:00
Andrew Poelstra
5ca702b5d9 Merge 152ddb3197 into merged_master (Bitcoin PR #20180) 2020-12-01 06:29:15 +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
54f2d85914 Merge 34eb236258 into merged_master (Bitcoin PR #19326) 2020-11-27 00:39:12 +00:00
Andrew Poelstra
11afdcc66a Merge 9ccaee1d5e into merged_master (Bitcoin PR #19004) 2020-11-26 01:08:51 +00:00
Andrew Poelstra
ba95deb36c Merge 19032c750c into merged_master (Bitcoin PR #18612) 2020-11-26 01:08:27 +00:00