Alice commits C into an output such that she can reveal R_N = HASH( ... HASH( C ))
.
We combine that to create transactions with dynamic lock times.
OP_HASH256
<COMMITMENT_HASH>
OP_SWAP
OP_ROT
OP_IF
OP_EQUALVERIFY
24
OP_CHECKSEQUENCEVERIFY
OP_ENDIF
OP_HASH256
OP_EQUALVERIFY
Spendable with:
1 <COMMITMENT_PREIMAGE>
OR
0 <HASH256(COMMITMENT_PREIMAGE)>
COMMITMENT = HASH(HASH(HASH(HASH(PREIMAGE))))
OP_HASH256
<COMMITMENT_HASH>
OP_SWAP
OP_ROT
OP_IF
OP_EQUALVERIFY
24
OP_CHECKSEQUENCEVERIFY
OP_ENDIF
OP_HASH256
OP_ROT
OP_IF
OP_EQUALVERIFY
18
OP_CHECKSEQUENCEVERIFY
OP_ENDIF
OP_HASH256
OP_ROT
OP_IF
OP_EQUALVERIFY
12
OP_CHECKSEQUENCEVERIFY
OP_ENDIF
OP_HASH256
OP_ROT
OP_IF
OP_EQUALVERIFY
6
OP_CHECKSEQUENCEVERIFY
OP_ENDIF
Hashed three times, spendable after 12 blocks.
0 0 1 0 <HASH(HASH(HASH256(PREIMAGE)))>
Hashed two times, spendable after 6 blocks.
0 0 0 1 <HASH(HASH256(PREIMAGE))>
Alice and Bob create an output in the Blockchain such that they can change its timelock afterwards.
Using two such time lock commitments in a payment channel with Alice and Bob, they can always execute their most recent state in a single transaction.
OP_HASH256
<COMMITMENT_1>
OP_SWAP
OP_ROT
OP_IF
OP_EQUALVERIFY
24
OP_CODESEPARATOR
OP_ENDIF
OP_HASH256
OP_ROT
OP_IF
OP_EQUALVERIFY
18
OP_CODESEPARATOR
OP_ENDIF
OP_HASH256
OP_ROT
OP_IF
OP_EQUALVERIFY
12
OP_CODESEPARATOR
OP_ENDIF
OP_HASH256
OP_ROT
OP_IF
OP_EQUALVERIFY
6
OP_CODESEPARATOR
OP_ENDIF
OP_CHECKSEQUENCEVERIFY
OP_DROP
<COMMITMENT_2>
OP_SWAP
OP_ROT
OP_IF
OP_EQUALVERIFY
24
OP_CODESEPARATOR
OP_ENDIF
OP_HASH256
OP_ROT
OP_IF
OP_EQUALVERIFY
18
OP_CODESEPARATOR
OP_ENDIF
OP_HASH256
OP_ROT
OP_IF
OP_EQUALVERIFY
12
OP_CODESEPARATOR
OP_ENDIF
OP_HASH256
OP_ROT
OP_IF
OP_EQUALVERIFY
6
OP_CODESEPARATOR
OP_ENDIF
OP_CHECKSEQUENCEVERIFY
OP_DROP
2
<ALICE KEY>
<BOB KEY>
2
OP_CHECKMULTISIG
The OP_CODESEPARATOR
guarantee signatures bind to pre-images. To trigger the N-th case Alice can not use any of Bob's signatures except for his N-th.
- 7 bit per party = 14 bit commitment + 2-of-2 signature
Use multiple hash functions to encode more states.
<COMMITMENT_HASH>
OP_SWAP
OP_ROT
OP_IF
OP_EQUALVERIFY
24
OP_CHECKSEQUENCEVERIFY
OP_ENDIF
OP_HASH256
OP_ROT
OP_IF
OP_EQUALVERIFY
18
OP_CHECKSEQUENCEVERIFY
OP_ENDIF
OP_HASH256
OP_ROT
OP_IF
OP_EQUALVERIFY
12
OP_CHECKSEQUENCEVERIFY
OP_ENDIF
OP_HASH256
OP_ROT
OP_IF
OP_EQUALVERIFY
6
OP_CHECKSEQUENCEVERIFY
OP_ENDIF