Commit graph

102 commits

Author SHA1 Message Date
Byron Hambly
fcf66c57af
Merge 962ea5c525 into merged_master (Bitcoin PR bitcoin/bitcoin#28374) 2025-11-06 09:52:16 +02:00
Byron Hambly
4b06261b48
Merge 8247a8db69 into merged_master (Bitcoin PR bitcoin/bitcoin#28154) 2025-08-04 10:11:28 +02:00
Byron Hambly
36e84e800e Merge 357e3f6aa4 into merged_master (Bitcoin PR bitcoin/bitcoin#28025) 2025-07-01 12:06:50 +02:00
Tom Trevethan
c4ef833d9d Merge 2182149dc5 into merged_master (Bitcoin PR bitcoin/bitcoin#26631) 2025-04-02 14:35:02 +00:00
Byron Hambly
2210416134 Merge f301bf52ab into merged_master (Bitcoin PR bitcoin/bitcoin#26257) 2025-04-01 08:27:16 +02:00
Byron Hambly
b4405ba453 Merge e9262ea32a into merged_master (Bitcoin PR bitcoin/bitcoin#26750) 2025-03-31 16:37:52 +02:00
Byron Hambly
f0478dd601 Merge 38d06e1561 into merged_master (Bitcoin PR bitcoin/bitcoin#26383) 2025-03-03 13:44:12 +02:00
Byron Hambly
d78604da4c Merge 2534141e19 into merged_master (Elements PR ElementsProject/elements#1219) 2024-12-02 08:51:39 +02:00
Russell O'Connor
bcd508f409 Add Simplicity Deployment structure 2024-10-07 14:39:10 -04:00
Andrew Chow
962ea5c525
Merge bitcoin/bitcoin#28374: test: python cryptography required for BIP 324 functional tests
c534c08710 [test/crypto] Add FSChaCha20Poly1305 AEAD python implementation (stratospher)
c2a458f1c2 [test/crypto] Add FSChaCha20 python implementation (stratospher)
c4ea5f6288 [test/crypto] Add RFC 8439's ChaCha20Poly1305 AEAD (stratospher)
9fc6e0355e [test/crypto] Add Poly1305 python implementation (stratospher)
fec2ca6c9a [test/crypto] Use chacha20_block function in `data_to_num3072` (stratospher)
0cde60da3a [test/crypto] Add ChaCha20 python implementation (stratospher)
69d3f50ab6 [test/crypto] Add HMAC-based Key Derivation Function (HKDF) (stratospher)
08a4a56cbc [test] Move test framework crypto functions to crypto/ (stratospher)

Pull request description:

  split off from #24748 to keep commits related to cryptography and functional test framework changes separate.

  This PR adds python implementation and unit tests for HKDF, ChaCha20, Poly1305, ChaCha20Poly1305 AEAD, FSChaCha20 and FSChaCha20Poly1305 AEAD.

  They're based on cc177ab7bc/bip-0324/reference.py for easy review.

ACKs for top commit:
  sipa:
    utACK c534c08710
  achow101:
    ACK c534c08710
  theStack:
    re-ACK c534c08710

Tree-SHA512: 08a0a422d2937eadcf0edfede37e535e6bc4c2e4b192441bbf9bc26dd3f03fa3388effd22f0527c55af173933d0b50e5b2b3d36f2b62d0aca3098728ef06970e
2023-11-07 16:48:57 -05:00
Byron Hambly
45f83fd396 Merge bada9636d7 into merged_master (Bitcoin PR bitcoin/bitcoin#24043) 2023-10-13 07:53:59 +00:00
stratospher
08a4a56cbc [test] Move test framework crypto functions to crypto/ 2023-09-10 23:16:39 +05:30
James Dorfman
bb30fa363d Fix feature_taproot functional test which has been failing since
the merge of bitcoin/bitcoin#23394 in 1beaa601b4

Co-authored-by: Sanket Kanjalkar <sanket1729@gmail.com>
2023-08-11 16:39:14 +00:00
Sebastian Falbesoner
83d7cfd542 test: refactor: deduplicate segwitv0 ECDSA signing for tx inputs
Follow-up for #28025.
2023-07-25 22:15:56 +02:00
Sebastian Falbesoner
5cf44275c8 test: refactor: deduplicate legacy ECDSA signing for tx inputs
There are several instances in functional tests and the framework
(MiniWallet, feature_block.py, p2p_segwit.py) where we create a legacy
ECDSA signature for a certain transaction's input by doing the following
steps:
    1) calculate the `LegacySignatureHash` with the desired sighash type
    2) create the actual digital signature by calling `ECKey.sign_ecdsa`
       on the signature message hash calculated above
    3) put the DER-encoded result as CScript data push into
       tx input's scriptSig

Create a new helper `sign_input_legacy` which hides those details and
takes only the necessary parameters (tx, input index, relevant
scriptPubKey, private key, sighash type [SIGHASH_ALL by default]). For
further convenience, the signature is prepended to already existing
data-pushes in scriptSig, in order to avoid rehashing the transaction
after calling the new signing function.
2023-07-03 17:33:41 +02:00
Byron Hambly
1413ea774b Merge 68ca8677e0 into merged_master (Bitcoin PR bitcoin/bitcoin#23716) 2023-06-06 10:11:17 +00:00
Byron Hambly
bd68371fb6 Merge ffdab41f94 into merged_master (Bitcoin PR bitcoin/bitcoin#23474) 2023-05-26 10:32:04 +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
MarcoFalke
2182149dc5
Merge bitcoin/bitcoin#26631: test: add coverage for dust mempool policy (-dustrelayfee setting)
d6fc1d6a33 test: add coverage for dust mempool policy (`-dustrelayfee` setting) (Sebastian Falbesoner)
8a5dbe2879 test: add `CScript` method for checking for witness program (Sebastian Falbesoner)

Pull request description:

  This PR adds missing test coverage for the `-dustrelayfee` setting, which specifies the fee-rate used to define dust. Output scripts for all common types that are treated as standard by default (P2PK, P2(W)PKH, P2(W)SH, P2TR, bare multisig, null data, unknown witness versions v2+) are created and then checked for dust-mempool-policy each via the `testmempoolaccept` RPC: a tx with an output's nValue equal to the dust threshold should be accepted, one with an nValue of just one 1 satoshi below that should be rejected with reason `dust`. This is repeatedly done for a fixed (but obviously somewhat arbitrary) list of different `-dustrelayfee` settings on a single node, including the default and zero (i.e. no dust limit) settings.

  Note that the first commit introduces a necessary `CScript` helper method `IsWitnessProgram` (using PascalCase in Python is likely controversial; in this case the style for the already existing method `GetSigOpCount` was followed, which also refers to a method in the core `CScript` class).

  Some historical information about dust, contributed by pablomartin4btc:
  "The concept of dust was first introduced in https://github.com/bitcoin/bitcoin/pull/2577. This [commit](https://github.com/bitcoin/bitcoin/pull/9380/commits/eb30d1a5b215c6dd3763d7f7948f2dd8cb61f6bf) from https://github.com/bitcoin/bitcoin/pull/9380 introduced the -dustrelayfee option. Previous to that PR, the dust feerate was whatever -minrelaytxfee was set to."

ACKs for top commit:
  LarryRuane:
    ACK d6fc1d6a33
  glozow:
    ACK d6fc1d6a33
  kouloumos:
    ACK d6fc1d6a33

Tree-SHA512: 35ea2b2497dfb466395af5665bb217f7250aa7cab9dc43539a5658ab69a454e3623ff58fce7489fcc1105b37f8cb4840a93cec658c5df1de611732bc6439ccad
2023-01-16 11:36:13 +01:00
Jon Atack
459cb637ac script, test: fix python linter E275 errors with flake8 5.0.4 2023-01-03 10:59:56 -08:00
Hennadii Stepanov
306ccd4927
scripted-diff: Bump copyright headers
-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./
-END VERIFY SCRIPT-

Commits of previous years:
- 2021: f47dda2c58
- 2020: fa0074e2d8
- 2019: aaaaad6ac9
2022-12-24 23:49:50 +00:00
Sebastian Falbesoner
8a5dbe2879 test: add CScript method for checking for witness program
This is needed in the next commit to calculate the dust threshold
for a given output script and min feerate for defining dust.
2022-12-04 03:07:42 +01:00
Pieter Wuille
5d413c8e79 Add feature_taproot case involved invalid internal pubkey 2022-11-21 14:00:43 -05:00
Pieter Wuille
b5f33ac1f8 Simplify wallet_taproot.py functional test 2022-01-12 11:09:41 -05:00
Pieter Wuille
eb0667ea96 Add tests for (sorted)multi_a derivation/signing 2022-01-12 11:09:41 -05:00
Pieter Wuille
5b559dc7ec Swap out hashlib.ripemd160 for own implementation 2021-12-08 14:29:41 -05:00
fanquake
ffdab41f94
Merge bitcoin/bitcoin#23474: test: scripted-diff cleanups after generate* changes
fac23c2114 scripted-diff: Bump copyright headers (MarcoFalke)
fa974f1f14 scripted-diff: Remove redundant sync_all and sync_blocks (MarcoFalke)
fad13991ae test: Properly set sync_fun in NodeNetworkLimitedTest (MarcoFalke)
faeff57709 test: Use 4 spaces for indentation (MarcoFalke)

Pull request description:

  Some cleanups after commit 94db963de5

ACKs for top commit:
  fanquake:
    ACK fac23c2114

Tree-SHA512: 5acfd5bb9679b41969d0fc6fc85801ccadcd6530ea692bac6352668e06fc7a9b0e1db3fd6fba435e84afe983d2eb07bd0a47c8364462bb7110004bd3d102b698
2021-11-16 11:22:06 +08:00
Pieter Wuille
c98c53f20c tests: abstract out precomputed BIP341 signature hash elements 2021-11-12 12:04:20 -05:00
Pieter Wuille
a5bde018b4 tests: give feature_taproot access to sighash preimages 2021-11-12 12:04:20 -05:00
Pieter Wuille
5140825096 tests: add more fields to TaprootInfo 2021-11-12 12:04:20 -05:00
MarcoFalke
fac23c2114
scripted-diff: Bump copyright headers
The previous diff touched most files in ./test/, so bump the headers to
avoid having to touch them again for a bump later.

-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./test/
-END VERIFY SCRIPT-
2021-11-10 11:10:24 +01:00
Andrew Poelstra
6c368ab1a3 Merge a1726c555b into merged_master (Elements PR ElementsProject/elements#1045) 2021-09-21 20:32:03 +00:00
Andrew Poelstra
0907fa0f6f test: support asset issuance in test framework sighashes
Replaces #932
2021-09-19 20:58: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
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
2c5c7eb87b Update tapscript leaf version 2021-08-27 19:24:07 +00:00
sanket1729
937343c75c Add tests for crypto opcodes 2021-08-27 19:24:07 +00:00
sanket1729
3e7b8c6aed Test arithmetic opcodes 2021-08-26 20:28:01 +00:00
sanket1729
6092d94c1d Add tests for introspection 2021-08-26 20:28:01 +00:00
sanket1729
007912eea4 Implement tests for sha256 streaming opcodes 2021-08-26 20:28:01 +00:00
sanket1729
14f93579a5 Add pegins and issuance test 2021-07-01 17:56:44 +00:00
sanket1729
cdd75d4251 Update OP_SUCCESS for elements with allowed opcodes 2021-07-01 17:56:44 +00:00
sanket1729
6c985308d7 Implement Taphash in test framework 2021-07-01 17:56:44 +00:00
Andrew Poelstra
90f1f6650b Merge fbf5d16238 into merged_master (Bitcoin PR #21246) 2021-06-26 01:58:32 +00:00
Andrew Poelstra
323f9bf6cd Merge b401b09355 into merged_master (Bitcoin PR #21107) 2021-06-21 08:23:27 +00:00
Andrew Poelstra
9a27a41c59 Merge cc592a85ea into merged_master (Bitcoin PR #20189) 2021-06-15 23:48:08 +00:00
Andrew Poelstra
2d31b7300e Merge f17e8ba3a1 into merged_master (Bitcoin PR #20207) 2021-06-10 20:35:12 +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
Russell O'Connor
6a0a6e7d05 Correction for VerifyTaprootCommitment comments
According to BIP-341, 'p' is called the taproot *internal* key, not inner key.
2021-03-01 09:01:48 -05:00
Steven Roose
b888f42270
tests: Add test feature_sighash_rangeproof.py 2021-02-22 15:19:10 +00:00