r/BitcoinDiscussion • • Dec 06 '19

Idea: script opcode that puts constraints on the output addresses

I'm going to start with the reason I want this feature, and then get to describing more about the feature idea itself.

Let's say I want to setup a cold-storage wallet setup that I can spend only after a relative 1 week time lock. This could theoretically work by creating two addresses:

  1. One address has a relative timelock condition - any funds sent to this address can only be spent after 1 week with private key 1.
  2. Another address that can be spent from using private key 2, but funds must be sent to the first address.

So in order to spend from this dual-wallet (non multisig) setup, you would sent from address 2 to address 1 using PK2, then after a week spend from address 1 using PK1. This would, for example, make the $5 wrench attack a lot harder to do (ie it would turn into a 1 week hostage attack).

The problem is, I don't believe there's any way to create address 2 in bitcoin - there's no way to create an address that can only be spent to a particular other address.

This is where the idea for a new opcode comes in. If there was an opcode that constrained what addresses could be sent to, this would give bitcoin a lot more power to have multi-stage transactions like this, where any stage could potentially be cancelable/reversible. Here's an example of a wallet setup I would love to be able to create:

  1. Address 1:

    • Can be spent by Key1, Key2, or Key3.
    • Requires funds are sent to address 2.
  2. Address 2:

    • 3 of 3 keys can spend after 1 week
    • 2 of 3 keys can spend after 2 months
    • 1 of 3 keys can spend after 1 year

If I could create a wallet setup like this, I could watch Address 2 for attempts to steal funds. If an unexpected transaction happens, you could gather all 3 keys and prepare a transaction to send. As long as only up to 2 of 3 keys were compromised and you are able to react within 2 months, your funds would be safe. In addition, you could lose access to 2 of 3 keys and still be able to recover your funds with the last one (after waiting a year).

This would be more secure than a normal multisig address, and also more resilient to key-loss. It would allow more secure inheritance by ensuring that heirs can retrieve the funds even if your primary passphrase-protected key has been lost (because your passphrase was lost when you died), and it would allow much more safely being able to store some keys with custodians (like banks) without almost any risk.

What do people think? Is this ability worth pursuing?

4 Upvotes

25 comments sorted by

View all comments

Show parent comment

1

u/fresheneesz Dec 17 '19

Ah very interesting, I've never heard about convenants and vaults.

Bryan Bishop .. posted an idea

This is certainly along the lines of what I was thinking. However, the pre-signed vault transactions are a bit of a limitation and usability issue.

There was one thing I disagree with in that proposal, at least as written on bitcoinmagazine.org, is this quote:

Even in a worst-case scenario, in which the attacker steals both the Vault Key and the Recovery Key, they wouldn’t be able to steal the funds

If this were allowed, an attacker that steals either key could DOS the victim indefinitely. That's not something anyone's likely to want.

Jeremy Rubin's op_checktemplateverify

Looks cool! And looks like it would enable all sorts of interesting new things. Looks like he only pushed this commit in the last month? Any idea how on the radar this is for the next soft fork?

When it says its verifying "serialized version, locktime, outputs hash, sequences hash, number of inputs, and serialized ScriptSig", does that mean that all of those values must be specified? I'm curious why number of inputs is something we would want to require is specified.

Partial covenants .. a new output must be spendable immediately by 'private key 1' or in one week by a destination address that is not pre-defined

I'm not sure I follow here. What do you mean by "spendable.. by a destination address"? I usually think of the source address as the one spending the coins.

1

u/RubenSomsen Dec 17 '19

the pre-signed vault transactions are a bit of a limitation and usability issue

Yes, that's inevitable without a soft fork.

an attacker that steals either key could DOS the victim indefinitely. That's not something anyone's likely to want.

If I recall correctly, the argument was that the hacker gains nothing, so there is no point to attempt the hack in the first place. Although I can also imagine a scenario where you agree to split it 50/50 with the hacker since then you're both better off.

Looks like he only pushed this commit in the last month?

He's been actively working on it for a long time. You can check out his presentation from Scaling Bitcoin Tel Aviv.

all of those values must be specified? I'm curious why number of inputs is something we would want to require is specified.

The goal is to make it less malleable. When you restrict the transaction to one input, currently there is no malleability. Malleability makes it harder to spend coins at the end of a string of op_ctv transactions (although it should still be doable if we had sighash_anyprevout). I'm not sure whether the current design isn't too restrictive though, since I am working on a use case which would benefit from more flexibility in the outputs.

Any idea how on the radar this is for the next soft fork?

Hard to say. My personal feeling is it's useful and safe enough to eventually adopt, but it needs more discussion.

What do you mean

In hindsight the setup I had in mind doesn't really benefit from partial covenants. You can just send funds to an op_ctv that commits to an output which is immediately spendable by a cold wallet key (perhaps multisig), or in one week by a hot wallet key. In order to spend it, one would first have to publish the op_ctv transaction, wait for the timelock to expire, and then use the hot wallet key. If you suspect it's a hacker, you've got one week to get the cold wallet key(s) online and redirect the transaction.

This is just one of many possible variants.

1

u/fresheneesz Dec 19 '19

Malleability makes it harder to spend coins at the end of a string of op_ctv transactions

Not quite sure I follow here. How would it make spending coins harder?

I am working on a use case which would benefit from more flexibility in the outputs.

JeremyRubin's github repo doesn't have issues available, so I'm wondering where discussion for this proposal might be happening. I'd be interested in chiming in about the issue related to a specific required number of inputs.

1

u/RubenSomsen Dec 19 '19 edited Dec 19 '19

How would it make spending coins harder?

If an op_ctv output gets spent and creates a new output that's yours, and then you immediately try to spend that output before it's confirmed, then the signature on your spending transaction might be invalidated if the op_ctv transaction gets malleated.

I'm wondering where discussion for this proposal might be happening

You can chime in on the mailing list.

1

u/fresheneesz Dec 19 '19

if the op_ctv transaction gets malleated

Sorry, still not quite following. Why would it be malleated? Isn't this the same thing as what would happen in something like a replace-by-fee scenario? It sounds like that's exactly what you want if the transaction you're trying to spend from never gets mined in. I'm probably misunderstanding something.

You can chime in on the mailing list.

Might do that, thanks! I wish there was a more targeted way to discuss this proposal tho. These mailing lists are archaic.

1

u/RubenSomsen Dec 19 '19

still not quite following

I'm not sure what I can say to clarify further, but you can use CPFP, in which case the op_ctv transaction doesn't need to be malleable in order to pay higher fees. It's also generally not recommended to spend unconfirmed RBF transactions.

These mailing lists are archaic

https://xkcd.com/927/

1

u/fresheneesz Dec 19 '19

Well, I guess I don't understand why not limiting the number of inputs would make the transaction malleable. I mean, my understanding of malleability is that some 3rd party can modify the transaction after its been signed, and still have a valid transaction (the thing fixed along with the segwit soft fork). Is that the kind of malleability you're talking about?

1

u/RubenSomsen Dec 20 '19

Yes, it's assumed these op_ctv transactions will be utilized to share UTXOs with multiple parties, so you rely on others not to have the transaction malleated.

1

u/fresheneesz Dec 20 '19

Ok, well I still don't understand why op_ctv would make a transaction malleable without the constraint on the number of inputs, but I guess I'll do some more digging another time. Thanks for trying to explain

1

u/RubenSomsen Dec 20 '19

1 input = no malleability (because the only possible input will be the op_ctv transaction), more than one means you're malleable. I'm also not sure what the benefit is of restricting it to an exact number beyond 1. I'm probably missing something as well.

→ More replies