Skip to content

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

case OP_INTERNALKEY: {
// OP_INTERNALKEY is only available in Tapscript
if (sigversion == SigVersion::BASE || sigversion == SigVersion::WITNESS_V0) {
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!

return set_error(serror, SCRIPT_ERR_BAD_OPCODE);
}
// Always present in Tapscript
assert(execdata.m_internal_key);
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


def is_op_success(o):
if o in [OP_INTERNALKEY]:
return False
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
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