Skip to content

Implement BIP 349 validation (OP_INTERNALKEY)#86

Merged
ajtowns merged 3 commits intobitcoin-inquisition:29.xfrom
instagibbs:2025-08-ikey-inq-29
Sep 16, 2025
Merged

Implement BIP 349 validation (OP_INTERNALKEY)#86
ajtowns merged 3 commits intobitcoin-inquisition:29.xfrom
instagibbs:2025-08-ikey-inq-29

Conversation

@instagibbs
Copy link

No description provided.

@instagibbs instagibbs force-pushed the 2025-08-ikey-inq-29 branch from f7e77ab to 24fb948 Compare August 19, 2025 14:08
@ajtowns ajtowns added this to the 29.x milestone Aug 27, 2025
@ajtowns ajtowns changed the title (29.x) BIP349 OP_INTERNALKEY Implement BIP 349 validation (OP_INTERNALKEY) Aug 27, 2025
Copy link

@ajtowns ajtowns Aug 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert(sigversion != BASE && sigversion != WITNESS_V0) ?
assert(flags & SCRIPT_VERIFY_INTERNALKEY) ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert(sigversion != BASE && sigversion != WITNESS_V0)

I don't believe this is correct; added test that fails with this change.

assert(flags & SCRIPT_VERIFY_INTERNALKEY)

This ends up being true post-activation, but I don't think would be prior?

We could add OP_INTERNALKEY to the disabled opcode area ala OP_CAT?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe this is correct; added test that fails with this change.

Right; disabled opcodes are checked beforehand so can have an assert, but everything needs to duplicate the set_error from the default: section. 👍

assert(flags & SCRIPT_VERIFY_INTERNALKEY)

This ends up being true post-activation, but I don't think would be prior?

Prior to activation, in the taproot case, it should be treated as OP_SUCCESS and this code shouldn't be reachable (CheckTapscriptOpSuccess will hit op_success_check via INQ_SUCCESS_OPCODES and either flags & discourage will force an error, or !(flags & enable) will force a success).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah right, if I leave in the script context gating, it will be fine!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert(sigversion == TAPSCRIPT) in that case?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess binana.json should be generating these too.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created an issue, #93. Wasn't obvious to me how to sensibly make these functions depend on info in ../data/binana.json (or if that should get changed to binana.py like invalid_txs.py, or something else).

@instagibbs instagibbs force-pushed the 2025-08-ikey-inq-29 branch 2 times, most recently from ed3c785 to ab73a28 Compare August 27, 2025 16:53
@instagibbs
Copy link
Author

note to self to add pre-activation tests ala 76f9913 once other PR has settled

@instagibbs
Copy link
Author

instagibbs commented Sep 8, 2025

Looks like we're running out of script flags for this PR. SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_CHECK_TEMPLATE_VERIFY_HASH collides with the generated SCRIPT_VERIFY_DISCOURAGE_INTERNALKEY, causing standardness fun.

edit: will review bitcoin#32998

@instagibbs
Copy link
Author

rebased on 64 bit flags work, added pre-activation test for IK

Copy link

@benthecarman benthecarman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack 4287a3a


def spenders_internalkey_active():

secs = [generate_privkey() for _ in range(8)]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit you're generating 8 keys here but only using [0] and [1]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will touch if I do anything else

@ajtowns ajtowns merged commit 7e49d15 into bitcoin-inquisition:29.x Sep 16, 2025
18 checks passed
arminsabouri pushed a commit to arminsabouri/bitcoin that referenced this pull request Nov 30, 2025
c40dbbb test: Move `script_assets_tests` into its own suite (Hennadii Stepanov)

Pull request description:

  This PR ensures that the `script_assets_tests` test case is explicitly reported as "Skipped" when it is not run, making it clearer when running the test suite with `ctest`:

  - on the master branch @ 9355578:
  ```
  $ env -u DIR_UNIT_TEST_DATA ctest --test-dir build -j 16 -R "^script_"
  Internal ctest changing into directory: /home/hebasto/git/bitcoin/build
  Test project /home/hebasto/git/bitcoin/build
      Start 87: script_tests
      Start 83: script_p2sh_tests
      Start 85: script_segwit_tests
      Start 86: script_standard_tests
      Start 84: script_parse_tests
  1/5 Test bitcoin-inquisition#84: script_parse_tests ...............   Passed    0.11 sec
  2/5 Test bitcoin-inquisition#86: script_standard_tests ............   Passed    0.11 sec
  3/5 Test bitcoin-inquisition#85: script_segwit_tests ..............   Passed    0.12 sec
  4/5 Test bitcoin-inquisition#83: script_p2sh_tests ................   Passed    0.12 sec
  5/5 Test bitcoin-inquisition#87: script_tests .....................   Passed    0.36 sec

  100% tests passed, 0 tests failed out of 5

  Total Test time (real) =   0.37 sec
  ```
  - with this PR:
  ```
  $ env -u DIR_UNIT_TEST_DATA ctest --test-dir build -j 16 -R "^script_"
  Internal ctest changing into directory: /home/hebasto/git/bitcoin/build
  Test project /home/hebasto/git/bitcoin/build
      Start 83: script_assets_tests
      Start 88: script_tests
      Start 84: script_p2sh_tests
      Start 86: script_segwit_tests
      Start 87: script_standard_tests
      Start 85: script_parse_tests
  1/6 Test bitcoin-inquisition#85: script_parse_tests ...............   Passed    0.11 sec
  2/6 Test bitcoin-inquisition#83: script_assets_tests ..............***Skipped   0.12 sec
  3/6 Test bitcoin-inquisition#86: script_segwit_tests ..............   Passed    0.11 sec
  4/6 Test bitcoin-inquisition#87: script_standard_tests ............   Passed    0.11 sec
  5/6 Test bitcoin-inquisition#84: script_p2sh_tests ................   Passed    0.12 sec
  6/6 Test bitcoin-inquisition#88: script_tests .....................   Passed    0.36 sec

  100% tests passed, 0 tests failed out of 6

  Total Test time (real) =   0.37 sec

  The following tests did not run:
   83 - script_assets_tests (Skipped)
  $ env DIR_UNIT_TEST_DATA=/home/hebasto/git/bitcoin/qa-assets/unit_test_data ctest --test-dir build -j 16 -R "^script_"
  Internal ctest changing into directory: /home/hebasto/git/bitcoin/build
  Test project /home/hebasto/git/bitcoin/build
      Start 83: script_assets_tests
      Start 88: script_tests
      Start 84: script_p2sh_tests
      Start 86: script_segwit_tests
      Start 87: script_standard_tests
      Start 85: script_parse_tests
  1/6 Test bitcoin-inquisition#85: script_parse_tests ...............   Passed    0.11 sec
  2/6 Test bitcoin-inquisition#87: script_standard_tests ............   Passed    0.11 sec
  3/6 Test bitcoin-inquisition#86: script_segwit_tests ..............   Passed    0.11 sec
  4/6 Test bitcoin-inquisition#84: script_p2sh_tests ................   Passed    0.12 sec
  5/6 Test bitcoin-inquisition#88: script_tests .....................   Passed    0.35 sec
  6/6 Test bitcoin-inquisition#83: script_assets_tests ..............   Passed    1.58 sec

  100% tests passed, 0 tests failed out of 6

  Total Test time (real) =   1.58 sec
  ```

ACKs for top commit:
  maflcko:
    re-ACK c40dbbb 👈
  ajtowns:
    ACK c40dbbb
  achow101:
    ACK c40dbbb

Tree-SHA512: 25713e1c3b507b6f2a5fecc7b1ea285a6642b906c248769238a58fc0df48489ac5f7606778f9e3653b407b7f1d06563e1554d04321303b350c80eb888500cc5d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants