Skip to content

BIP449: OP_TWEAKADD#1944

Open
JeremyRubin wants to merge 14 commits into
bitcoin:masterfrom
JeremyRubin:optweakadd
Open

BIP449: OP_TWEAKADD#1944
JeremyRubin wants to merge 14 commits into
bitcoin:masterfrom
JeremyRubin:optweakadd

Conversation

@JeremyRubin
Copy link
Copy Markdown
Contributor

@JeremyRubin JeremyRubin commented Aug 22, 2025

Opening this PR for feedback & discussion on the specification for OP_TWEAKADD.

Mailing list post: https://groups.google.com/g/bitcoindev/c/-_geIB25zrg/m/bDpv822yAAAJ

Comment thread bip-XXXX.md Outdated
kash831

This comment was marked as off-topic.

Copy link
Copy Markdown
Member

@murchandamus murchandamus left a comment

Choose a reason for hiding this comment

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

I had a first glance at this. Looks interesting. A few sections look still a bit bullet point heavy and I would hope to see them expanded a bit.

Comment thread bip-XXXX.md Outdated
Comment thread bip-XXXX.md Outdated
Comment thread bip-XXXX.md Outdated
Comment thread bip-XXXX.md Outdated
Copy link
Copy Markdown
Member

@murchandamus murchandamus left a comment

Choose a reason for hiding this comment

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

Hey, this hasn’t seen any activity in a while and is still marked as a draft pull request. What is the status of this?
If this is ready for another editor review, please mark the pull request as Ready for Review. It would also be welcome if it got some review from third parties.

Comment thread bip-XXXX.md Outdated
@murchandamus murchandamus changed the title BIP Draft OP_TWEAKADD BIP Draft: OP_TWEAKADD Feb 28, 2026
@murchandamus murchandamus added the PR Author action required Needs updates, has unaddressed review comments, or is otherwise waiting for PR author label Feb 28, 2026
@JeremyRubin JeremyRubin marked this pull request as ready for review February 28, 2026 07:57
@JeremyRubin
Copy link
Copy Markdown
Contributor Author

I think it's fine to come out of draft.

Copy link
Copy Markdown
Member

@murchandamus murchandamus left a comment

Choose a reason for hiding this comment

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

The Rationale still seems a bit brief to me, but I would expect that it would be backfilled with the responses to the questions and issues raised as this proposal gets more review. Would be great if some other covenant researchers took a look at it. Otherwise the idea generally seems well described.

cc: @brandonblack, @ajtowns, @roconnor-blockstream, @moonsettler, @Roasbeef for some likely candidates to take a look.

Comment thread bip-XXXX.md Outdated
Comment thread bip-XXXX.md Outdated
- Infinity outputs are rejected to avoid invalid keys.
- Functionality is narrowly scoped to Taproot-style tweaks, avoiding arbitrary EC arithmetic.
- Push opcode rather than verification opcode for script compactness.
- Argument order to permit tweak from witness onto fixed key without OP_SWAP.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Argument order to permit tweak from witness onto fixed key without OP_SWAP

This sentence is not clear to me. Perhaps it could use more context.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

see the email thread https://groups.google.com/g/bitcoindev/c/-_geIB25zrg

so OP_TWEAKADD can be either be <tweak> <key> or <key> <tweak>.

we use:

<key> OP_TWEAKADD

because we assume that commonly keys will come from the script, and tweaks will come from the witness.

This avoids an op_SWAP in most cases shown in the email examples.

Comment thread bip-XXXX.md Outdated
This is a soft-fork change which is tapscript-only. Un-upgraded nodes will continue
to treat unknown tapscript opcode as OP_SUCCESSx.

A future upgrade, such as an OP_CAT or OP_TAPTREE opcode, can prepare a tweak for a
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is OP_TAPTREE? I don’t think I’ve seen that one before.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Stand-in for "some opcode that can work with taproot trees".

@murchandamus murchandamus added Needs number assignment and removed PR Author action required Needs updates, has unaddressed review comments, or is otherwise waiting for PR author labels Feb 28, 2026
@moonsettler
Copy link
Copy Markdown
Contributor

moonsettler commented Feb 28, 2026

Without any additional opcodes the supported use cases seem to be:

  1. prove order of signing (not sure what this can be used for, maybe some penalty based lightning construct?)
  2. reveal private key to a pubkey (user can swap out of a covenant pool by atomically forfeiting a private key?)

Also along with #1974 TA could be used instead of the annex for data availability, by tweaking the internal key with the data required to reconstruct the script for that state.

Something like <sig> <da> | SHA256 INTERNALKEY TWEAKADD TEMPLATEHASH SWAP CSFS

@murchandamus
Copy link
Copy Markdown
Member

Let’s refer to this as BIP 449. Please update the BIP and Assigned headers in the Preamble, rename the file, and add a table entry to the README file for your proposal.

@murchandamus murchandamus changed the title BIP Draft: OP_TWEAKADD BIP449: OP_TWEAKADD Mar 5, 2026
@JeremyRubin
Copy link
Copy Markdown
Contributor Author

Thanks for the assignment!

@murchandamus re rationale/motivation, see the email thread. https://groups.google.com/g/bitcoindev/c/-_geIB25zrg

@murchandamus
Copy link
Copy Markdown
Member

murchandamus commented Mar 16, 2026

You’re welcome. My point was that the relevant information from the email thread and the pull request discussions should be added to your document, so that your document contains the relevant context and is self-explanatory.

Could you please also update the BIP and Assigned headers in the Preamble, rename the file, and add a table entry to the README file for your proposal?

@murchandamus murchandamus added the PR Author action required Needs updates, has unaddressed review comments, or is otherwise waiting for PR author label Mar 16, 2026
@moonsettler
Copy link
Copy Markdown
Contributor

It's really thin on the motivation.

Enables script-level key evolutions

Is probably the most vague way possible to describe what it does in a practical sense in tapscript and possibly in restored script.

@JeremyRubin
Copy link
Copy Markdown
Contributor Author

I think I made all the requested edits. I also added a use case on how to use TWEAKADD for PAIRCOMMIT @moonsettler would appreciate your review on that in particular that my design is sound, was a little tricky.

Copy link
Copy Markdown
Member

@murchandamus murchandamus left a comment

Choose a reason for hiding this comment

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

Thanks for the update

@murchandamus murchandamus removed the PR Author action required Needs updates, has unaddressed review comments, or is otherwise waiting for PR author label Mar 24, 2026
@moonsettler
Copy link
Copy Markdown
Contributor

I think I made all the requested edits. I also added a use case on how to use TWEAKADD for PAIRCOMMIT @moonsettler would appreciate your review on that in particular that my design is sound, was a little tricky.

Looks good to me.

@jonatack jonatack self-assigned this Apr 24, 2026
Copy link
Copy Markdown
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

Looks good AFAICS.

Comment thread bip-0449.md
```
## Abstract

This proposal defines a new tapscript opcode, `OP_TWEAKADD`, that takes an x-only public key and a 32-byte integer `t` on the stack and pushes the x-only public key corresponding to `P + t*G`, where `P` is the lifted point for the input x-coordinate and `G` is the secp256k1 generator. The operation mirrors the Taproot tweak used by BIP340 signers and enables simple, verifiable key modifications inside script without revealing private keys or relying on hash locks.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

takes an x-only public key

@JeremyRubin regarding the following question by @Roasbeef in https://groups.google.com/g/bitcoindev/c/-_geIB25zrg/m/AlKbHMl9BgAJ, perhaps I missed it but didn't see it addressed in the ML thread, unsure if the BIP was updated somewhat in response.

First, why accept only x-only keys?

From the PoV of Bitcoin Script today, they aren't used anywhere within the
execution environment. They also add some complexity to protocols that need
to accept them as input for further manipulation. They are indeed used for
Taproot output public keys, but those keys don't ever make their way down
into Script as an op code argument.

The musig2 BIP originally accepted x-only keys as input, but was switched to
instead accept normal compressed public keys in version v0.8.0 [1]. The
switch over enabled some simplifications in the BIP, as it enabled
eliminating one of the accumulator variables. For more details, see the
discussion that led to this change [2].

This comment from Tim resonates with my experience wrangling with bugs
introduced by improper/implicit handling of x-only keys over the years:

> Sigh yeah, x-only keys save a byte on chain but it seems the price we pay
> is a high engineering complexity. I think it's fair to say that noone had
> really anticipated this [1].

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@Roasbeef followed up himself with

https://groups.google.com/g/bitcoindev/c/-_geIB25zrg/m/ypVpdVKZAQAJ

Allowing parity-bearing public keys would not be encoding-malleable for full points, but it would undermine the x-only canonicalization property. If both the point sign and tweak are witness-controllable, (P, t) and (-P, n−t) yield the same x-only result, creating a new witness malleability vector.

Also, depending on how we add the parity argument, we might want to have OP_IKEY compatibility, making this a more sweeping change.

@Roasbeef himself has a separate proposal for EC Ops that better solve for that use case. TWEAKADD attempts to be maximally faithful to what taproot does.

Comment thread bip-0449.md
Status: Draft
Type: Specification
Assigned: 2026-03-05
License: BSD-3-Clause
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could add the Requires header stating the BIPs that this one depends on (340, maybe 341)

Requires: 340

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not sure I understand the Requires header well enough to add it.

I would assume it would be only meaningful with respect to BIPs that are not currently consensus-active?

Comment thread bip-0449.md Outdated
[dependencies]
secp256k1 = "0.29"
hex = "0.4"
bitcoin_hashes = "0.16.0"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

cargo run worked fine

for info, when I made the suggested cargo updates

-secp256k1 = "0.29"
+secp256k1 = "0.31.1"
 hex = "0.4"
-bitcoin_hashes = "0.16.0"
+bitcoin_hashes = "0.20.0"

the code looks like it would need to be updated for API changes in secp256k1.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i.e. cargo asked if you'd like to update? but it worked fine without?

Probably need a bip repo wide policy wrt that...

otherwise examples will constantly go stale against cargo suggestions for newer versions.

Co-authored-by: Jon Atack <jon@atack.com>
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.

5 participants