1

The question

Alice <--50--> Bob <--50--> Steve <--50--> Anna

Here, each arrow denotes a payment channel with capacity N eth. What is, step by step, the algorithm used to route a 10 eth payment between Alice and Anna? Please, include, at each step, how each party should react to the possibility of one party not following the protocol.

What I have tried

I have read some explanations but I'm missing the fine details. On that case, I assume, it'd go like this:

  1. Anna generates a random secret, sends its hash to Alice.

  2. Alice signs to send 10 eth to Bob given Alice's secret.

  3. Bob signs to send 10 eth to Steve given Anna's secret.

  4. Steve signs to send 10 eth to Anna given her secret.

  5. Anna reveals her secret to Steve.

  6. Steve reveals it to Bob.

  7. Bob reveals it to Alice.

  8. Alice now knows Anna received the payment, everyone else knows their balance are equal.

But that's pretty simple, so I'm not sure if I actually got it right. In particular, worried if one of those parties could just drop the protocol at any point to a personal benefit.

1

Let's make it clear that Alice wants to pay Anna 10 ETH. We'll answer using a similar way and terms to the question.

  1. Alice creates a secret, and computes H=hash(secret).
  2. Alice creates a "locked" transaction that pays 10 ETH to Bob that can only be "unlocked" by the secret. This can be a smart contract that pays 10 ETH to Bob if the contract receives input that hashes to H. That is, if someone provides the secret to the contract, it will hash to H, and so the 10 ETH is paid to Bob.
  3. Bob creates a similar contract that would pay 10 ETH to Steve, if the contract receives input that hashes to H.
  4. Steve creates a similar contract that would pay 10 ETH to Anna, if the contract receives input that hashes to H.
  5. Alice gives the secret to Anna.
  6. Anna unlocks her 10 ETH payment from Steve by providing the secret.
  7. Steve now has the secret, and can unlock and get his payment from Bob.
  8. Bob now has the secret, and can unlock and get his payment from Alice.

The "magic" to payment and state channels is that by Anna claiming her payment, she reveals the secret which allows everyone else in the path to claim their payment.

For Anna to get payment from her channel with Steve, she must publish the secret to the blockchain. Once published, Steve and Bob will then see the secret and can then use it to claim their payments. Anna does not need to be motivated to share the secret for the system to work, because the system is insightfully designed so that claiming the payment requires revealing the secret.

For more references: https://www.reddit.com/r/ethereum/comments/6fde8t/ethereum_payment_channels_in_50_lines_of_solidity

  • 1
    Oh, I had it the other way around, which is ehy it didn’t make sense. That sounds good, thanks. – MaiaVictor Oct 8 '17 at 20:35
  • One thing is not clear; all transactions are unlocked with the same secret (Alice's), or each one has a new secret (from who wrote the transaction)? If the later, then how can Anna unlock Steve's secret if she has Alice's secret, not Steve's? If the former (which is how I understood), then what motivation Anna has to give Steve the secret? She has both Steve's transaction, and the secret to unlock it. No need to give anything to Steve. Is it because if she doesn't give it, then Steve will close the channel, forcing her to give it by complaining on the blockchain? – MaiaVictor Oct 8 '17 at 23:07
  • 1
    Yes, same secret used. Anna can't get her funds without revealing the secret. Yes, Steve can close the channel if Anna decides to never get her funds. – eth Oct 10 '17 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.