Re: [bitcoin-dev] Bitcoin vaults with anti-theft recovery/clawback mechanisms

2019-08-12 Thread Praveen Baratam via bitcoin-dev
Bryan,

This is very similar to *CoinVault - Secure Depository and Secure Exchange*
technologies that I have shared with you all.
ᐧ

On Wed, Aug 7, 2019 at 7:23 PM Bryan Bishop via bitcoin-dev <
bitcoin-dev@lists.linuxfoundation.org> wrote:

> Hi,
>
> I have a proposal for implementing bitcoin vaults in a way that does not
> require any soft-forks or other software upgrades, although it could
> benefit
> from SIGHASH_NOINPUT which I'll describe later.
>
> I call them pre-signed vaults.
>
> Vault definition
> 
>
> Here, a vault is defined as a transaction setup scheme that binds both the
> user
> and the attacker to always using a public observation and delay period
> before a
> weakly-secured hot key is allowed to arbitrarily spend coins. This is the
> same
> definition previously used[1]. During the delay period, there is an
> opportunity
> to initiate recovery/clawback which can either trigger deeper cold storage
> parameters or at least reset the delay period to start over again for the
> same
> keys.
>
> One of the important components of this is the delete-the-key pre-signed
> transaction concept, where only a single transaction is (pre)signed before
> deleting the key. This is basically an emulation of a covenant and
> enforces a
> certain outcome.
>
> Background and motivation
> =
>
> I was looking at Eyal and Sirer's 2016 vaults paper [1], and I saw this
> headscratcher:
>
> > Vault transactions use a delay mechanism. We note that vault transactions
> > cannot be implemented with existing timing mechanisms such as
> > CHECKLOCKTIMEVERIFY opcode or transaction locktime.
>
> This was probably written before the introduction of
> OP_CHECKSEQUENCEVERIFY.
> Still, a viable construction would have more steps than just using OP_CSV.
> They
> were probably not thinking about what those steps might be, because in the
> context of the paper they were proposing a bitcoin vault implemented using
> recursive consensus-enforced covenants via a new opcode, which obviously
> cannot
> be deployed without an upgrade fork. Covenants have been discussed for
> years,
> but require new opcodes or other consensus-enforcement changes.
>
> Relative locktimes are useful here because there is no knowledge as to
> when the
> transactions might be broadcasted in the future. The delays need to be
> relative
> to after the transaction is included in the blockchain, not to setup
> initialization time.
>
> Also, from [2]:
>
> > We show that a [vault transaction] mechanism is currently not possible
> in all
> > cryptocurrencies [...] Bitcoin's scripting language requires support for
> > covenants.
>
> I haven't seen any previous proposal for how to implement recursive bitcoin
> vaults without a fork and without a covenant. After asking around, I am
> pretty
> sure this is somewhat novel. The closest I guess is [3].
>
> Vaults are particularly interesting as a bitcoin cold storage security
> mechanism because they enable a publicly observable delay period during
> which
> time a user could be alerted by a watchtower that a thief might be in the
> process of stealing their coins, and then the user may take some actions to
> place the coins back into the vault before the relative timelock expires.
> There
> seems to be no way to get this notification or observation period without a
> vault construction. It might have been assumed it required a covenant.
>
> Having a vault construction might go a long way to discourage would-be
> attackers, on principle that the attacker might be incapable of recovering
> their cost-of-attack because the recovery mechanism can lock up the coins
> indefinitely. Griefing or denial-of-service would still be possible, of
> course,
> but with multisig there might be some ways to put a halt to that as well.
> I am
> working under the assumption that the attacker knows that the user is a
> vault
> user.
>
> Vaults
> ==
>
> The idea is to have a sequence of pre-generated pre-signed transactions
> that
> are generated in a certain way. The basic components are a vaulting
> transaction
> that locks coins into a vault, a delayed-spend transaction which is the
> only
> way to spend from a vault, and a re-vaulting transaction which can
> recover/clawback coins from the delayed-spend transaction. The security of
> this
> scheme is enforced by pre-signing transactions and deleting private keys,
> or
> with the help of SIGHASH_NOINPUT then there's another scheme where private
> keys
> are provably never known. This enforces that there's only a specific set of
> possible outcomes at every step of the vault.
>
> Some examples of what the set of broadcasted transactions might look like
> in
> regular usage:
>
> coins -> VT -> DST -> exit via hot wallet key
> coins -> VT -> DST -> RVT
> coins -> VT -> DST -> RVT -> DST -> ...
> coins -> VT -> ... -> RVT998 -> nuclear abort
>
> where:
> VT = vault transaction
> DST = delayed-spend transaction
> RVT = 

Re: [bitcoin-dev] OP_LOOKUP_OUTPUT proposal

2019-08-12 Thread Lloyd Fournier via bitcoin-dev
Hello Runchao and ZmnSCPxj,

I think we can simplify the explanation here by not using joint signatures
and payment channel like constructions. ZmnSCPxj's more complex
construction could be more dynamic and practical in some settings but at
least for me it gets in the way of capturing how this relatively simple
idea works.
Here's my attempt at distilling the idea:

Step 0: Alice and Bob negotiate the parameters (timeouts, refund/redeem
pubkeys, the collateral amounts and inputs/outputs for the WTJ-HTLC)

=== Step 1 ===
 Alice signs and broadcasts the BTC-HTLC and sends signature(s) on her
input(s) to the WJT-HLTC to Bob.
Note:
1. She does not need to wait for the BTC-HTLC to confirm before she sends
her signature(s).
2. There is no benefit to Alice in delaying at this point

=== Step 2 ===
Upon receiving Alice's input signature(s) and seeing the BTC-HTLC with
sufficient confirmations, Bob completes the transaction by supplying his
own signature(s) and broadcasts it.

Note:
1. Bob's ability to delay at this point shouldn't be considered an option.
Alice may withdraw her offer by double spending her one of her inputs to
the WTJ-HTLC. Alice's ability to cancel the offer and take back BTC after
the timeout proves there is no option (options cannot be cancelled)
2. In this plain construction Alice should cancel promptly (if she doesn't
see the WTJ-HTLC within the next 1 or 2 blocks for example)
3. You could even extend this protocol  to specify that Bob send signatures
on his inputs the WTJ-HTLC immediately to Alice. If he refuses Alice can
cancel within a second or two.

=== Step 3 ===
Upon seeing the WTJ-HTLC get sufficient confirmations, Alice takes the
funds (including her collateral back) by revealing the secret.

Note:
1. If she doesn't redeem the HTLC she loses her collateral. Assuming the
loss of the collateral overwhelms any gain she could experience from the
delaying her decision and she operates in her own financial interest she
redeems it immediately.

Step 4 is as usual.

At each step there is no unfair advantage to either party (at least if we
idealise the blockchains somewhat and assume that neither party can
influence which transactions get into which block etc etc).

ZmnSCPxj,

Thanks for continuing to spread this idea!
I'm still not sure about your "two hashes" approach to lightning but I hope
to get to the bottom of it soon by describing how I think it should work
more formally somewhere. Will post to lightning-dev when I do :)

LL

On Mon, Aug 12, 2019 at 4:06 PM ZmnSCPxj via bitcoin-dev <
bitcoin-dev@lists.linuxfoundation.org> wrote:

> Good morning Runchao,
>
>
> Sent with ProtonMail Secure Email.
>
> ‐‐‐ Original Message ‐‐‐
> On Monday, August 12, 2019 11:19 AM, Runchao Han 
> wrote:
>
> > Good morning ZmnSCPxj,
> >
> > Sorry for the ambiguity of my last email. It was Sunday and I wrote it
> in 1 min on my bed. Let me elaborate what we are thinking of here.
> >
> > ## Analysis on the protocol from Fournier et al.
> >
> > In this protocol, Bob participates in the swap following the steps below:
> >
> > 1. Alice and Bob creates a payment channel on WJT blockchain.
> > 2. Bob creates the WJT transaction using the joint account of Alice and
> Bob, including 1) Bob's input of 1,000,000 WJT, 2) Alice’s input for the
> 10,000 WJT premium. This transaction should be signed by both Alice and Bob
> in order to be valid.
> > 3. Bob signs the WJT transaction and sends the WJT transaction to Alice.
> > 4. Alice signs this WJT transaction. At this stage, Alice has both the
> valid BTC transaction and the valid WJT transaction.
> > 5. Alice broadcasts both the BTC transaction and the WJT transaction.
>
> Incorrect.
>
> The order is below.
> I add also the behavior when the protocol is stalled such that a step is
> not completed.
>
> 1.  Alice broadcasts and confirms a BTC transaction paying an HTLC,
> hashlock Bob, Timelock Alice.
> * Alice is initiating the protocol via this step, thus non-completion
> of this step is simply not performing the protocol.
> 2.  Alice informs the BTC transaction to Bob.
> * If Alice does not perform this, Bob does not know it and Alice
> locked her own money for no reason.
> 3.  Alice and Bob indicate their inputs for the WJT-side funding
> transaction.
> * If Alice does not perform this, it aborts the protocol and Alice
> locked her own money for no reason.
> * If Bob does not perform this, it aborts the protocol and Bob turns
> down the opportunity to earn 10,000 WJT (opportunity cost).
> 4.  Alice and Bob exchange signatures for the WJT-side claim transaction
> which spends the funding transaction via the hashlock side and gives
> 1,000,000 WJT to payout to Alice and 10,000 WJT premium to Bob.
> Order does not matter as funding  tx is still unsigned.
> * If Alice does not perform this, it aborts the protocol and Alice
> locked her own money for no reason.
> * If Bob does not perform this, it aborts the protocol and Bob turns
> down 

Re: [bitcoin-dev] OP_LOOKUP_OUTPUT proposal

2019-08-12 Thread Runchao Han via bitcoin-dev
Hi ZmnSCPxj,

Thanks for your explanation. It’s comprehensive.

I think our disagreement is on the step 6.
In step 6,

- Alice can publish or withhold the WJT tx
- Bob can wait or unilaterally close the WJT payment channel

I see the following things:

First, both Alice and Bob can do something on the WJT blockchain at this stage. 
What will happen if they publish txs simultaneously?
For example, Alice publishes WJT tx while Bob publishes the tx closing the 
channel.

Second, will the concurrent txs introduce some attacks?  I guess 
concurrent-while-conflicting txs lead to highly unpredictable behaviours.
For example, Alice or Bob uses high tx fee to bribe miners to accept her/his 
tx, in order to gain some advantage on the concurrent txs?
Also, the “whale transaction” works here. Will this introduce some 
double-spending variants?

Third, assume Bob doesn’t wait any more and closes the channel. In this case, 
Bob cannot get the premium.
This is not consistent with the original American Call Option, in which Bob 
should still get the premium.

To conclude, I find this protocol highly depends on the implementation of the 
payment channel as well as the expertise of participants (Alice and Bob) c.f. 
relatively low usability.
We may need a suitable payment channel implementation here. What’s your opinion 
on the payment channel suitable for this scenario?

Sincerely,
Runchao

> On 12 Aug 2019, at 6:05 pm, ZmnSCPxj  wrote:
> 
> Good morning Runchao,
> 
> 
> Sent with ProtonMail Secure Email.
> 
> ‐‐‐ Original Message ‐‐‐
> On Monday, August 12, 2019 11:19 AM, Runchao Han  > wrote:
> 
>> Good morning ZmnSCPxj,
>> 
>> Sorry for the ambiguity of my last email. It was Sunday and I wrote it in 1 
>> min on my bed. Let me elaborate what we are thinking of here.
>> 
>> ## Analysis on the protocol from Fournier et al.
>> 
>> In this protocol, Bob participates in the swap following the steps below:
>> 
>> 1. Alice and Bob creates a payment channel on WJT blockchain.
>> 2. Bob creates the WJT transaction using the joint account of Alice and Bob, 
>> including 1) Bob's input of 1,000,000 WJT, 2) Alice’s input for the 10,000 
>> WJT premium. This transaction should be signed by both Alice and Bob in 
>> order to be valid.
>> 3. Bob signs the WJT transaction and sends the WJT transaction to Alice.
>> 4. Alice signs this WJT transaction. At this stage, Alice has both the valid 
>> BTC transaction and the valid WJT transaction.
>> 5. Alice broadcasts both the BTC transaction and the WJT transaction.
> 
> Incorrect.
> 
> The order is below.
> I add also the behavior when the protocol is stalled such that a step is not 
> completed.
> 
> 1.  Alice broadcasts and confirms a BTC transaction paying an HTLC, hashlock 
> Bob, Timelock Alice.
>* Alice is initiating the protocol via this step, thus non-completion of 
> this step is simply not performing the protocol.
> 2.  Alice informs the BTC transaction to Bob.
>* If Alice does not perform this, Bob does not know it and Alice locked 
> her own money for no reason.
> 3.  Alice and Bob indicate their inputs for the WJT-side funding transaction.
>* If Alice does not perform this, it aborts the protocol and Alice locked 
> her own money for no reason.
>* If Bob does not perform this, it aborts the protocol and Bob turns down 
> the opportunity to earn 10,000 WJT (opportunity cost).
> 4.  Alice and Bob exchange signatures for the WJT-side claim transaction 
> which spends the funding transaction via the hashlock side and gives 
> 1,000,000 WJT to payout to Alice and 10,000 WJT premium to Bob.
>Order does not matter as funding  tx is still unsigned.
>* If Alice does not perform this, it aborts the protocol and Alice locked 
> her own money for no reason.
>* If Bob does not perform this, it aborts the protocol and Bob turns down 
> the opportunity to earn 10,000 WJT (opportunity cost).
> 5.  Bob provides signatures for the WJT funding tx,
>* If Bob does not perform this, it aborts the protocol and Bob turns down 
> the opportunity to earn 10,000 WJT (opportunity cost).
> 6.  Alice signs WJT funding tx and broacasts and confirms.
>* If Alice does not perform this, Bob invalidates the transaction by 
> spending any of his inputs.
>  * Alice has an option here, but a very short option: up until Bob grows 
> tired of waiting.
>Bob can make this timeout arbitrarily small, without requiring input 
> from Alice.
>What value would there be in a 1-second option, even gotten for free, 
> when Alice has spent fees on the BTC-side transaction in the first place?
> 7.  Alice completes the claim transaction and broadcasts.
>* If Alice does not perform this, Bob simply waits out the timelock and 
> recovers his funds plus premium.
> 8.  Bob spends the BTC HTLC via the hashlock path.
>* If Bob does not perform this, Bob has given money for free to Alice.
> 
> Thus I do not believe this is needed for 

Re: [bitcoin-dev] Bitcoin vaults with anti-theft recovery/clawback mechanisms

2019-08-12 Thread Bryan Bishop via bitcoin-dev
On Mon, Aug 12, 2019 at 10:01 AM Peter Todd  wrote:

> The key difference being it's not important that this be a *public*
> notification: that the public can see just happens to be an (unfortunate)
> implementation detail. For example, you could imagine a system where the
> "prepare to spend" tx is indistinguishable from any other transaction.
>

True, I did not intend for everyone to know the meaning of the observed
transaction. It turns out to not be too useful to the scheme anyway, unless
you're interested in protecting against an adversary dumb enough to tell
you he has stolen your key before spending your coins. To reiterate my
other follow-up email, the best you can do (... or the best I can do right
now) is limit losses to k% where k is selected by the user, e.g. 1 input
100 outputs each with succesively increasing timeouts allowing the rotten
non-rotated(pre-inserted) key to spend, and instant spending by a recovery
flow. Once the attacker steals any one of the k% outputs, you know to not
let the outputs timeout to that key in the future. Unfortunately, without
an opcode-style covenant, the only way to know if a stale hot key is stolen
is to observe an unexpected spend or, if you're lucky, observe an
unexpected signature otherwise unassociated with a transaction.


> > * Nuclear abort key: Also unnecessary. This is a key for which only a
> single


>
Obviously normally to provably destroy coins you'd spend to an OP_RETURN
> output, or if miner censorship was an issue, a pay-to-script-hash of an
> OP_RETURN  script.
>

Oh, right. Well, that works.


> > Delete the key (for pre-signed transactions)
> > 
> >
> > The delete-the-key trick is simple. The idea is to pre-sign at least one
> > transaction and then delete the private key, thus locking in that course
> of
> > action.
> >
> > Unfortunately, delete-the-key doesn't really work for multisig scenarios
> > because nobody would trust that anyone else in the scheme has actually
> deleted
> > the secret. If they haven't deleted the secret, then they have full
> unilateral
> > control to sign anything in that branch of the transaction tree. The
> only time
> > that delete-the-key might be appropriate would be where the user who
> deletes
> > the key and controls the key during the setup process is also the sole
> > beneficiary of the entire setup with the multisig participants.
> >
> > Alternative fee rates are easier to deal with using delete-the-key,
> compared to
> > a technique where the private key never existed which can only be used
> to sign
> > one fee rate per public key, requiring an entirely new vault subtree for
> each
> > alternative fee rate. With delete-the-key, the alternative fee rates are
> signed
> > with the private key before the private key is deleted.
>
> I think this could use a bit more analysis here: why can't delete the
> *keys*
> work, with each party deleting a separate private key that's used in an
> m-of-n
> fashion? So long as at least n-m+1 parties actually deleted their keys
> IIUC it
> should be secure.
>

I was thinking about another construction where you pick a key as a group
(separate from the multisig setup) and sign with that. But in practice, as
you have pointed out, you would do the delete-the-key trick on the multisig
construction itself with each party contributing their own pubkey,
requiring 1/n honest deletes.


> > Multisig gated by ECDSA pubkey recovery for provably-unknown keys
> > =
> >
> > A group can participate in a multisig scheme with provably-unknown ECDSA
> keys.
> > Instead of deleting the key, the idea is to agree on a blockheight and
> then
> > select the blockhash (or some function of the chosen blockhash like
> > H(H(H(blockhash as the signature. Next, the group agrees on a
> transaction
> > and they recover the public key from the signature using ECDSA pubkey
> recovery.
>
> Could you explain in more detail why you're deriving this from a blockhash?
>

Well you need to pick an entropy source, and I wouldn't want to tell people
to just trust the first party to tell you a good sequence of bytes.

- Bryan
http://heybryan.org/
1 512 203 0507
___
bitcoin-dev mailing list
bitcoin-dev@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev


Re: [bitcoin-dev] Bitcoin vaults with anti-theft recovery/clawback mechanisms

2019-08-12 Thread Peter Todd via bitcoin-dev
On Wed, Aug 07, 2019 at 08:48:06AM -0500, Bryan Bishop via bitcoin-dev wrote:
> Hi,
> 
> I have a proposal for implementing bitcoin vaults in a way that does not
> require any soft-forks or other software upgrades, although it could benefit
> from SIGHASH_NOINPUT which I'll describe later.
> 
> I call them pre-signed vaults.
> 
> Vault definition
> 
> 
> Here, a vault is defined as a transaction setup scheme that binds both the 
> user
> and the attacker to always using a public observation and delay period before 
> a
> weakly-secured hot key is allowed to arbitrarily spend coins. This is the same
> definition previously used[1]. During the delay period, there is an 
> opportunity
> to initiate recovery/clawback which can either trigger deeper cold storage
> parameters or at least reset the delay period to start over again for the same
> keys.

So, I'll point out that I'd describe this a little bit differently:

The vault is a tx setup scheme that binds coins in such a way that they can
only be spent via a proof-of-publication *notification*, followed by a delay
period, during which coins can be recovered/clawed back.

The key difference being it's not important that this be a *public*
notification: that the public can see just happens to be an (unfortunate)
implementation detail. For example, you could imagine a system where the
"prepare to spend" tx is indistinguishable from any other transaction.

> One of the important components of this is the delete-the-key pre-signed
> transaction concept, where only a single transaction is (pre)signed before
> deleting the key. This is basically an emulation of a covenant and enforces a
> certain outcome.

It's important to note the reason this is possible is because any coin bound by
a convenant simply isn't a coin in the normal sense of the word, and is only
acceptable as payment directly if the receiver chooses to accept it.

To use an analogy many others have used, if you owe me $100, it's not
acceptable for you to pay me that $100 by dumping a time-locked safe on my
front lawn containing that $100 unless I've agreed to accept payment that way.

> * Nuclear abort key: Also unnecessary. This is a key for which only a single
> signed transaction will ever exist, and that single transaction will spend to 
> a
> proof-of-burn key like 0x00. This key must be extremely secure, and if there

So to be clear, you're spending to a proof-of-burn _key_ because of the use of
adapter signatures for multisig? I'm not sure where the 0x00 is coming from
here.

Obviously normally to provably destroy coins you'd spend to an OP_RETURN
output, or if miner censorship was an issue, a pay-to-script-hash of an
OP_RETURN  script.

> Delete the key (for pre-signed transactions)
> 
> 
> The delete-the-key trick is simple. The idea is to pre-sign at least one
> transaction and then delete the private key, thus locking in that course of
> action.
> 
> Unfortunately, delete-the-key doesn't really work for multisig scenarios
> because nobody would trust that anyone else in the scheme has actually deleted
> the secret. If they haven't deleted the secret, then they have full unilateral
> control to sign anything in that branch of the transaction tree. The only time
> that delete-the-key might be appropriate would be where the user who deletes
> the key and controls the key during the setup process is also the sole
> beneficiary of the entire setup with the multisig participants.
> 
> Alternative fee rates are easier to deal with using delete-the-key, compared 
> to
> a technique where the private key never existed which can only be used to sign
> one fee rate per public key, requiring an entirely new vault subtree for each
> alternative fee rate. With delete-the-key, the alternative fee rates are 
> signed
> with the private key before the private key is deleted.

I think this could use a bit more analysis here: why can't delete the *keys*
work, with each party deleting a separate private key that's used in an m-of-n
fashion? So long as at least n-m+1 parties actually deleted their keys IIUC it
should be secure.

> Multisig gated by ECDSA pubkey recovery for provably-unknown keys
> =
> 
> A group can participate in a multisig scheme with provably-unknown ECDSA keys.
> Instead of deleting the key, the idea is to agree on a blockheight and then
> select the blockhash (or some function of the chosen blockhash like
> H(H(H(blockhash as the signature. Next, the group agrees on a transaction
> and they recover the public key from the signature using ECDSA pubkey 
> recovery.

Could you explain in more detail why you're deriving this from a blockhash?

> Deploying exceedingly large scripts
> ===
> 
> A brief interlude to share a somewhat obvious construction. I haven't seen 
> this
> written down yet.
> 
> Suppose there is a 

[bitcoin-dev] Single-use-Seal Implementation

2019-08-12 Thread Peter Todd via bitcoin-dev
On Wed, Aug 07, 2019 at 08:48:06AM -0500, Bryan Bishop via bitcoin-dev wrote:
> Single-use seals
> 
> 
> This proposal may have inadvertedly demonstrated a practical way to implement
> Peter Todd's single-use seals concept [4]. I am hesitant to say so, though,
> because I think he would ask for a more sophisticated way to verify seal
> closure.

I'm not sure what you're getting at here; single-use-seals are really boring
and simple. To recap, they're akin to a pubkey that has the "magical" property
that it can only be signed once. This of course is impossible with math alone,
but can be implemented with beyond-math mechanisms like trust or PoW (physics).

Thus you have a globally unique seal, which can be closed over a message,
producing a witness attesting to the fact that the seal was closed over that
message. A single-use-seal protocol is secure if it is impossible (in your
chosen security model) to trick the validation function into thinking a single
seal was closed over two different messages.

The obvious implementation with Bitcoin is to define the seal to be a specified
txout, and the witness to be a transaction (and lite client proof) that spends
that txout in a transation with an OP_RETURN output committing to the hash of
the message as the first output. A fancier implementation could use a
pay-to-pubkey-style commitment (RGB¹ uses something along these lines).


For applications requiring a chain of single-use-seals, you can easily keep two
txouts for seals in your wallet, and alternate them as the chain is extended.


Do you mean to say there didn't previously exist a practical way to implement
them? Or that you've found another way? I'm curious what you mean here.


1) https://github.com/rgb-org/spec

-- 
https://petertodd.org 'peter'[:-1]@petertodd.org


signature.asc
Description: PGP signature
___
bitcoin-dev mailing list
bitcoin-dev@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev


Re: [bitcoin-dev] OP_LOOKUP_OUTPUT proposal

2019-08-12 Thread ZmnSCPxj via bitcoin-dev
Good morning Runchao,

> Thanks for your explanation. It’s comprehensive.
>
> I think our disagreement is on the step 6.
> In step 6,
>
> - Alice can publish or withhold the WJT tx
> - Bob can wait or unilaterally close the WJT payment channel
>
> I see the following things:
>
> First, both Alice and Bob can do something on the WJT blockchain at this 
> stage. What will happen if they publish txs simultaneously?
> For example, Alice publishes WJT tx while Bob publishes the tx closing the 
> channel.

I am uncertain what you refer to by the "WJT payment channel".
What I am proposing here is there is a single funding transaction that will 
output to a modified HTLC where hashlock is Alice+Bob while Timelock is Bob, 
spending inputs from both Alice (10,000 WJT) and Bob (1,000,000 WJT).

So let me rephrase the nearest question as I understand it:

* What happens when Alice broadcasts the funding tx at the same time as Bob 
double-spends his 1,000,000 WJT input?

As both transactions spend the same input (the 1,000,000 WJT from Bob) then 
what happens depends on the miners.
The miners decide which transaction is valid and gets confirmed onchain.

That is the reason why we need large timeouts in the HTLC constructions: we 
need to give enough time, not only to react to transactions being published, 
but also to have transactions become deeply confirmed.
Otherwise we could have made the timelocks so small as to be practically 
worthless as an option.

>
> Second, will the concurrent txs introduce some attacks?  I guess 
> concurrent-while-conflicting txs lead to highly unpredictable behaviours.
> For example, Alice or Bob uses high tx fee to bribe miners to accept her/his 
> tx, in order to gain some advantage on the concurrent txs?
> Also, the “whale transaction” works here. Will this introduce some 
> double-spending variants?

Yes, that is why Alice and Bob need to wait for deep confirmations of the 
transactions involved.
Once deeply confirmed, they now know which way the protocol went and can safely 
perform the next step (or abort the protocol).

>
> Third, assume Bob doesn’t wait any more and closes the channel. In this case, 
> Bob cannot get the premium.
> This is not consistent with the original American Call Option, in which Bob 
> should still get the premium.

It does not matter, because Bob doing so *prevents* the option.

Think of it this way:

Suppose we were to meet face-to-face, in order for you to sell me an options 
contract.
Now, suppose I agree to buy the options contract.
But, while filling up the paperwork, you change your mind.

Until the paperwork is properly filled up, the option does not exist.
Thus, until the paperwork is properly filled,, the option is not exerciseable 
(and I should not pay anything to you since you did not push through with 
completing the option).

This is similar in effect.


>
> To conclude, I find this protocol highly depends on the implementation of the 
> payment channel as well as the expertise of participants (Alice and Bob) c.f. 
> relatively low usability.
> We may need a suitable payment channel implementation here. What’s your 
> opinion on the payment channel suitable for this scenario?

Any payment channel has the problem of non-cooperation by the other side.
I already mentioned this before.
Again, this is always an issue regardless of the existence or non-existence of 
an `OP_LOOKUP_OUTPUT`: you have to execute onchain activity anyway in order to 
enforce anything offchain in case of non-cooperation, and adding in the 
possibility of various attacks makes it more likely that non-cooperation occurs.
It is the main reason why I think it is difficult to make Lightning support 
multiple currencies on the same network.

Usability can always be improved by proper software design; you do not worry 
about what voltage levels need to be transmitted over the wires in order to 
transmit your email to me, yet you probably consider your email client quite 
usable.

Regards,
ZmnSCPxj


___
bitcoin-dev mailing list
bitcoin-dev@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev


Re: [bitcoin-dev] OP_LOOKUP_OUTPUT proposal

2019-08-12 Thread ZmnSCPxj via bitcoin-dev
Good morning Runchao,


Sent with ProtonMail Secure Email.

‐‐‐ Original Message ‐‐‐
On Monday, August 12, 2019 11:19 AM, Runchao Han  wrote:

> Good morning ZmnSCPxj,
>
> Sorry for the ambiguity of my last email. It was Sunday and I wrote it in 1 
> min on my bed. Let me elaborate what we are thinking of here.
>
> ## Analysis on the protocol from Fournier et al.
>
> In this protocol, Bob participates in the swap following the steps below:
>
> 1. Alice and Bob creates a payment channel on WJT blockchain.
> 2. Bob creates the WJT transaction using the joint account of Alice and Bob, 
> including 1) Bob's input of 1,000,000 WJT, 2) Alice’s input for the 10,000 
> WJT premium. This transaction should be signed by both Alice and Bob in order 
> to be valid.
> 3. Bob signs the WJT transaction and sends the WJT transaction to Alice.
> 4. Alice signs this WJT transaction. At this stage, Alice has both the valid 
> BTC transaction and the valid WJT transaction.
> 5. Alice broadcasts both the BTC transaction and the WJT transaction.

Incorrect.

The order is below.
I add also the behavior when the protocol is stalled such that a step is not 
completed.

1.  Alice broadcasts and confirms a BTC transaction paying an HTLC, hashlock 
Bob, Timelock Alice.
* Alice is initiating the protocol via this step, thus non-completion of 
this step is simply not performing the protocol.
2.  Alice informs the BTC transaction to Bob.
* If Alice does not perform this, Bob does not know it and Alice locked her 
own money for no reason.
3.  Alice and Bob indicate their inputs for the WJT-side funding transaction.
* If Alice does not perform this, it aborts the protocol and Alice locked 
her own money for no reason.
* If Bob does not perform this, it aborts the protocol and Bob turns down 
the opportunity to earn 10,000 WJT (opportunity cost).
4.  Alice and Bob exchange signatures for the WJT-side claim transaction which 
spends the funding transaction via the hashlock side and gives 1,000,000 WJT to 
payout to Alice and 10,000 WJT premium to Bob.
Order does not matter as funding  tx is still unsigned.
* If Alice does not perform this, it aborts the protocol and Alice locked 
her own money for no reason.
* If Bob does not perform this, it aborts the protocol and Bob turns down 
the opportunity to earn 10,000 WJT (opportunity cost).
5.  Bob provides signatures for the WJT funding tx,
* If Bob does not perform this, it aborts the protocol and Bob turns down 
the opportunity to earn 10,000 WJT (opportunity cost).
6.  Alice signs WJT funding tx and broacasts and confirms.
* If Alice does not perform this, Bob invalidates the transaction by 
spending any of his inputs.
  * Alice has an option here, but a very short option: up until Bob grows 
tired of waiting.
Bob can make this timeout arbitrarily small, without requiring input 
from Alice.
What value would there be in a 1-second option, even gotten for free, 
when Alice has spent fees on the BTC-side transaction in the first place?
7.  Alice completes the claim transaction and broadcasts.
* If Alice does not perform this, Bob simply waits out the timelock and 
recovers his funds plus premium.
8.  Bob spends the BTC HTLC via the hashlock path.
* If Bob does not perform this, Bob has given money for free to Alice.

Thus I do not believe this is needed for blockchain-layer atomic swaps.

For Lightning-layer atomic swaps, the solution requires that two hashes be used 
on the WJT side, and is largely the above protocol in very broad strokes.
Unfortunately, using two hashes instead of one leaks to intermediate hops that 
the payment involved a cross-currency swap, thus undesirable.



>
> In a word, Bob is responsible for preparing the WJT transaction, while Alice 
> is responsible for preparing the BTC transaction and broadcasting both 
> transactions.
>
> Here, if Bob stalls, nothing will happen, because Bob cannot spend the 10,000 
> WJT premium without Alice’s signature.
> If Alice stalls, you are saying that Bob can spend the input of 1,000,000 WJT 
> so he does not lose any money.
>
> I have 3 questions on this scheme.
>
> First, I’m not sure how do you define “Alice stalls”. In this case, Alice can 
> stall by 1) withhold the WJT tx, or 2) broadcast BTC/WJT funding txs but 
> withhold the preimage.
> If 2), this protocol is okay. But what about 1) i.e. Alice withholds the WJT 
> tx? Here, Bob cannot do anything except for closing the payment channel and 
> quit.

Yes.

>
> Second, I’m not sure whether Bob can spend his money in this payment channel 
> while the payment channel is still valid.
> In Bitcoin, Bob needs to close the payment channel and get back his money 
> first, then he can spend the money.

Depends on how the payment channel is implemented.
If you do something like send transactions spending the internal state outputs, 
then ratifying this later by performing a transaction cut-through to derive the