/
state_channel.clinc
33 lines (30 loc) · 1.2 KB
/
state_channel.clinc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
; The actual state channel coin is a vanilla coin which does 2-of-2 aggregation at the signature level and
; unrolls to the unrolling puzzle. Unrolls to the unrolling puzzle are signed in tandem with sequence number
; updates to the unrolling puzzle. The keys of the state channel puzzle and the unrolling puzzle don't
; have to be related
(defun state_channel_unrolling (SHARED_PUZZLE_HASH OLD_SEQUENCE_NUMBER DEFAULT_CONDITIONS_HASH reveal solution)
(if (not (isthere solution))
; These probably contain a relative timelock
(assert (= DEFAULT_CONDITIONS_HASH (shatree reveal))
reveal
)
(assign
conditions (a reveal solution)
new_sequence_number (extract_sequence_number conditions)
(assert
(> new_sequence_number OLD_SEQUENCE_NUMBER)
(logand 1 (logxor new_sequence_number OLD_SEQUENCE_NUMBER))
(= SHARED_PUZZLE_HASH (shatree reveal))
conditions
)
)
)
)
(defun extract_sequence_number (conditions)
(assign ((cond_type arg)) conditions
(if (= cond_type 1)
arg
(extract_sequence_number (r conditions))
)
)
)