chik_puzzles/programs.rs
1// Auto-generated Rust file with loaded Chiklisp constants
2// This file was created from running generate_chiklisp_constants.py
3
4use hex_literal::hex;
5
6/// ```text
7/// ; Coins locked with this puzzle are spendable cats.
8/// ;
9/// ; Choose a list of n inputs (n>=1), I_1, ... I_n with amounts A_1, ... A_n.
10/// ;
11/// ; We put them in a ring, so "previous" and "next" have intuitive k-1 and k+1 semantics,
12/// ; wrapping so {n} and 0 are the same, ie. all indices are mod n.
13/// ;
14/// ; Each coin creates 0 or more coins with total output value O_k.
15/// ; Let D_k = the "debt" O_k - A_k contribution of coin I_k, ie. how much debt this input accumulates.
16/// ; Some coins may spend more than they contribute and some may spend less, ie. D_k need
17/// ; not be zero. That's okay. It's enough for the total of all D_k in the ring to be 0.
18/// ;
19/// ; A coin can calculate its own D_k since it can verify A_k (it's hashed into the coin id)
20/// ; and it can sum up `CREATE_COIN` conditions for O_k.
21/// ;
22/// ; Defines a "subtotal of debts" S_k for each coin as follows:
23/// ;
24/// ; S_1 = 0
25/// ; S_k = S_{k-1} + D_{k-1}
26/// ;
27/// ; Here's the main trick that shows the ring sums to 0.
28/// ; You can prove by induction that S_{k+1} = D_1 + D_2 + ... + D_k.
29/// ; But it's a ring, so S_{n+1} is also S_1, which is 0. So D_1 + D_2 + ... + D_k = 0.
30/// ; So the total debts must be 0, ie. no coins are created or destroyed.
31/// ;
32/// ; Each coin's solution includes I_{k-1}, I_k, and I_{k+1} along with proofs that I_{k}, and I_{k+1} are CATs of the same type.
33/// ; Each coin's solution includes S_{k-1}. It calculates D_k = O_k - A_k, and then S_k = S_{k-1} + D_{k-1}
34/// ;
35/// ; Announcements are used to ensure that each S_k follows the pattern is valid.
36/// ; Announcements automatically commit to their own coin id.
37/// ; Coin I_k creates an announcement that further commits to I_{k-1} and S_{k-1}.
38/// ;
39/// ; Coin I_k gets a proof that I_{k+1} is a cat, so it knows it must also create an announcement
40/// ; when spent. It checks that I_{k+1} creates an announcement committing to I_k and S_k.
41/// ;
42/// ; So S_{k+1} is correct iff S_k is correct.
43/// ;
44/// ; Coins also receive proofs that their neighbours are CATs, ensuring the announcements aren't forgeries.
45/// ; Inner puzzles and the CAT layer prepend `CREATE_COIN_ANNOUNCEMENT` with different prefixes to avoid forgeries.
46/// ; Ring announcements use 0xcb, and inner puzzles are given 0xca
47/// ;
48/// ; In summary, I_k generates a coin_announcement Y_k ("Y" for "yell") as follows:
49/// ;
50/// ; Y_k: hash of I_k (automatically), I_{k-1}, S_k
51/// ;
52/// ; Each coin creates an assert_coin_announcement to ensure that the next coin's announcement is as expected:
53/// ; Y_{k+1} : hash of I_{k+1}, I_k, S_{k+1}
54/// ;
55/// ; TLDR:
56/// ; I_k : coins
57/// ; A_k : amount coin k contributes
58/// ; O_k : amount coin k spend
59/// ; D_k : difference/delta that coin k incurs (A - O)
60/// ; S_k : subtotal of debts D_1 + D_2 ... + D_k
61/// ; Y_k : announcements created by coin k committing to I_{k-1}, I_k, S_k
62/// ;
63/// ; All conditions go through a "transformer" that looks for CREATE_COIN conditions
64/// ; generated by the inner solution, and wraps the puzzle hash ensuring the output is a cat.
65/// ;
66/// ; Three output conditions are prepended to the list of conditions for each I_k:
67/// ; (ASSERT_MY_ID I_k) to ensure that the passed in value for I_k is correct
68/// ; (CREATE_COIN_ANNOUNCEMENT I_{k-1} S_k) to create this coin's announcement
69/// ; (ASSERT_COIN_ANNOUNCEMENT hashed_announcement(Y_{k+1})) to ensure the next coin really is next and
70/// ; the relative values of S_k and S_{k+1} are correct
71/// ;
72/// ; This is all we need to do to ensure cats exactly balance in the inputs and outputs.
73/// ;
74/// ; Proof:
75/// ; Consider n, k, I_k values, O_k values, S_k and A_k as above.
76/// ; For the (CREATE_COIN_ANNOUNCEMENT Y_{k+1}) (created by the next coin)
77/// ; and (ASSERT_COIN_ANNOUNCEMENT hashed(Y_{k+1})) to match,
78/// ; we see that I_k can ensure that is has the correct value for S_{k+1}.
79/// ;
80/// ; By induction, we see that S_{m+1} = sum(i, 1, m) [O_i - A_i] = sum(i, 1, m) O_i - sum(i, 1, m) A_i
81/// ; So S_{n+1} = sum(i, 1, n) O_i - sum(i, 1, n) A_i. But S_{n+1} is actually S_1 = 0,
82/// ; so thus sum(i, 1, n) O_i = sum (i, 1, n) A_i, ie. output total equals input total.
83///
84/// ;; GLOSSARY:
85/// ;; MOD_HASH: this code's sha256 tree hash
86/// ;; TAIL_PROGRAM_HASH: the program that determines if a coin can mint new cats, burn cats, and check if its lineage is valid if its parent is not a CAT
87/// ;; INNER_PUZZLE: an independent puzzle protecting the coins. Solutions to this puzzle are expected to generate `AGG_SIG` conditions and possibly `CREATE_COIN` conditions.
88/// ;; ---- items above are curried into the puzzle hash ----
89/// ;; inner_puzzle_solution: the solution to the inner puzzle
90/// ;; prev_coin_id: the id for the previous coin
91/// ;; tail_program_reveal: reveal of TAIL_PROGRAM_HASH required to run the program if desired
92/// ;; tail_solution: optional solution passed into tail_program
93/// ;; lineage_proof: optional proof that our coin's parent is a CAT
94/// ;; this_coin_info: (parent_id puzzle_hash amount)
95/// ;; next_coin_proof: (parent_id inner_puzzle_hash amount)
96/// ;; prev_subtotal: the subtotal between prev-coin and this-coin
97/// ;; extra_delta: an amount that is added to our delta and checked by the TAIL program
98/// ;;
99///
100/// (mod (
101/// MOD_HASH ;; curried into puzzle
102/// TAIL_PROGRAM_HASH ;; curried into puzzle
103/// INNER_PUZZLE ;; curried into puzzle
104/// inner_puzzle_solution ;; if invalid, INNER_PUZZLE will fail
105/// lineage_proof ;; This is the parent's coin info, used to check if the parent was a CAT. Optional if using tail_program.
106/// prev_coin_id ;; used in this coin's announcement, prev_coin ASSERT_COIN_ANNOUNCEMENT will fail if wrong
107/// this_coin_info ;; verified with ASSERT_MY_COIN_ID
108/// next_coin_proof ;; used to generate ASSERT_COIN_ANNOUNCEMENT
109/// prev_subtotal ;; included in announcement, prev_coin ASSERT_COIN_ANNOUNCEMENT will fail if wrong
110/// extra_delta ;; this is the "legal discrepancy" between your real delta and what you're announcing your delta is
111/// )
112///
113/// ;;;;; start library code
114///
115/// (include condition_codes.clib)
116/// (include curry-and-treehash.clib)
117/// (include cat_truths.clib)
118/// (include utility_macros.clib)
119///
120/// (defconstant RING_MORPH_BYTE 0xcb)
121///
122///
123/// ; take two lists and merge them into one
124/// (defun merge_list (list_a list_b)
125/// (if list_a
126/// (c (f list_a) (merge_list (r list_a) list_b))
127/// list_b
128/// )
129/// )
130///
131/// ; cat_mod_struct = (MOD_HASH MOD_HASH_hash GENESIS_COIN_CHECKER GENESIS_COIN_CHECKER_hash)
132///
133/// (defun-inline mod_hash_from_cat_mod_struct (cat_mod_struct) (f cat_mod_struct))
134/// (defun-inline mod_hash_hash_from_cat_mod_struct (cat_mod_struct) (f (r cat_mod_struct)))
135/// (defun-inline tail_program_hash_from_cat_mod_struct (cat_mod_struct) (f (r (r cat_mod_struct))))
136///
137/// ;;;;; end library code
138///
139/// ;; return the puzzle hash for a cat with the given `GENESIS_COIN_CHECKER_hash` & `INNER_PUZZLE`
140/// (defun-inline cat_puzzle_hash (cat_mod_struct inner_puzzle_hash)
141/// (puzzle-hash-of-curried-function (mod_hash_from_cat_mod_struct cat_mod_struct)
142/// inner_puzzle_hash
143/// (sha256 ONE (tail_program_hash_from_cat_mod_struct cat_mod_struct))
144/// (mod_hash_hash_from_cat_mod_struct cat_mod_struct)
145/// )
146/// )
147///
148/// ;; assert `CREATE_COIN_ANNOUNCEMENT` doesn't contain the RING_MORPH_BYTE bytes so it cannot be used to cheat the coin ring
149///
150/// (defun-inline morph_condition (condition cat_mod_struct)
151/// (if (= (f condition) CREATE_COIN)
152/// (c CREATE_COIN
153/// (c (cat_puzzle_hash cat_mod_struct (f (r condition)))
154/// (r (r condition)))
155/// )
156/// (if (= (f condition) CREATE_COIN_ANNOUNCEMENT)
157/// (assert (not (and
158/// (= 33 (strlen (f (r condition))))
159/// (= (substr (f (r condition)) 0 ONE) RING_MORPH_BYTE) ; lazy eval
160/// ))
161/// ; then
162/// condition
163/// )
164/// condition
165/// )
166/// )
167/// )
168///
169/// ;; given a coin's parent, inner_puzzle and amount, and the cat_mod_struct, calculate the id of the coin
170/// (defun-inline coin_id_for_proof (coin cat_mod_struct)
171/// (calculate_coin_id (f coin) (cat_puzzle_hash cat_mod_struct (f (r coin))) (f (r (r coin))))
172/// )
173///
174/// ;; utility to fetch coin amount from coin
175/// (defun-inline input_amount_for_coin (coin)
176/// (f (r (r coin)))
177/// )
178///
179/// ;; calculate the hash of an announcement
180/// ;; we add 0xcb so ring announcements exist in a different namespace to announcements from inner_puzzles
181/// (defun-inline calculate_annoucement_id (this_coin_id this_subtotal next_coin_id cat_mod_struct)
182/// (sha256 next_coin_id RING_MORPH_BYTE (sha256tree (list this_coin_id this_subtotal)))
183/// )
184///
185/// ;; create the `ASSERT_COIN_ANNOUNCEMENT` condition that ensures the next coin's announcement is correct
186/// (defun-inline create_assert_next_announcement_condition (this_coin_id this_subtotal next_coin_id cat_mod_struct)
187/// (list ASSERT_COIN_ANNOUNCEMENT
188/// (calculate_annoucement_id this_coin_id
189/// this_subtotal
190/// next_coin_id
191/// cat_mod_struct
192/// )
193/// )
194/// )
195///
196/// ;; here we commit to I_{k-1} and S_k
197/// ;; we add 0xcb so ring announcements exist in a different namespace to announcements from inner_puzzles
198/// (defun-inline create_announcement_condition (prev_coin_id prev_subtotal)
199/// (list CREATE_COIN_ANNOUNCEMENT
200/// (concat RING_MORPH_BYTE (sha256tree (list prev_coin_id prev_subtotal)))
201/// )
202/// )
203///
204/// ;;;;;;;;;;;;;;;;;;;;;;;;;;;
205///
206/// ;; this function takes a condition and returns an integer indicating
207/// ;; the value of all output coins created with CREATE_COIN. If it's not
208/// ;; a CREATE_COIN condition, it returns 0.
209///
210/// (defun-inline output_value_for_condition (condition)
211/// (if (= (f condition) CREATE_COIN)
212/// (f (r (r condition)))
213/// 0
214/// )
215/// )
216///
217/// ;; add two conditions to the list of morphed conditions:
218/// ;; CREATE_COIN_ANNOUNCEMENT for my announcement
219/// ;; ASSERT_COIN_ANNOUNCEMENT for the next coin's announcement
220/// (defun-inline generate_final_output_conditions
221/// (
222/// prev_subtotal
223/// this_subtotal
224/// morphed_conditions
225/// prev_coin_id
226/// this_coin_id
227/// next_coin_id
228/// cat_mod_struct
229/// )
230/// (c (create_announcement_condition prev_coin_id prev_subtotal)
231/// (c (create_assert_next_announcement_condition this_coin_id this_subtotal next_coin_id cat_mod_struct)
232/// morphed_conditions)
233/// )
234/// )
235///
236///
237/// ;; This next section of code loops through all of the conditions to do three things:
238/// ;; 1) Look for a "magic" value of -113 and, if one exists, filter it, and take note of the tail reveal and solution
239/// ;; 2) Morph any CREATE_COIN or CREATE_COIN_ANNOUNCEMENT conditions
240/// ;; 3) Sum the total output amount of all of the CREATE_COINs that are output by the inner puzzle
241/// ;;
242/// ;; After everything return a struct in the format (morphed_conditions . (output_sum . tail_reveal_and_solution))
243/// ;; If multiple magic conditions are specified, the later one will take precedence
244///
245/// (defun-inline condition_tail_reveal (condition) (f (r (r (r condition)))))
246/// (defun-inline condition_tail_solution (condition) (f (r (r (r (r condition))))))
247///
248/// (defun cons_onto_first_and_add_to_second (morphed_condition output_value struct)
249/// (c (c morphed_condition (f struct)) (c (+ output_value (f (r struct))) (r (r struct))))
250/// )
251///
252/// (defun find_and_strip_tail_info (inner_conditions cat_mod_struct tail_reveal_and_solution)
253/// (if inner_conditions
254/// (if (= (output_value_for_condition (f inner_conditions)) -113) ; Checks this is a CREATE_COIN of value -113
255/// (find_and_strip_tail_info
256/// (r inner_conditions)
257/// cat_mod_struct
258/// (c (condition_tail_reveal (f inner_conditions)) (condition_tail_solution (f inner_conditions)))
259/// )
260/// (cons_onto_first_and_add_to_second
261/// (morph_condition (f inner_conditions) cat_mod_struct)
262/// (output_value_for_condition (f inner_conditions))
263/// (find_and_strip_tail_info
264/// (r inner_conditions)
265/// cat_mod_struct
266/// tail_reveal_and_solution
267/// )
268/// )
269/// )
270/// (c () (c 0 tail_reveal_and_solution))
271/// )
272/// )
273///
274/// ;;;;;;;;;;;;;;;;;;;;;;;;;;; lineage checking
275///
276/// ;; return true iff parent of `this_coin_info` is provably a cat
277/// ;; A 'lineage proof' consists of (parent_parent_id parent_INNER_puzzle_hash parent_amount)
278/// ;; We use this information to construct a coin who's puzzle has been wrapped in this MOD and verify that,
279/// ;; once wrapped, it matches our parent coin's ID.
280/// (defun-inline is_parent_cat (
281/// cat_mod_struct
282/// parent_id
283/// lineage_proof
284/// )
285/// (= parent_id
286/// (calculate_coin_id (f lineage_proof)
287/// (cat_puzzle_hash cat_mod_struct (f (r lineage_proof)))
288/// (f (r (r lineage_proof)))
289/// )
290/// )
291/// )
292///
293/// (defun check_lineage_or_run_tail_program
294/// (
295/// this_coin_info
296/// tail_reveal_and_solution
297/// parent_is_cat ; flag which says whether or not the parent CAT check ran and passed
298/// lineage_proof
299/// Truths
300/// extra_delta
301/// inner_conditions
302/// )
303/// (if tail_reveal_and_solution
304/// (assert (= (sha256tree (f tail_reveal_and_solution)) (cat_tail_program_hash_truth Truths))
305/// (merge_list
306/// (a (f tail_reveal_and_solution)
307/// (list
308/// Truths
309/// parent_is_cat
310/// lineage_proof ; Lineage proof is only guaranteed to be true if parent_is_cat
311/// extra_delta
312/// inner_conditions
313/// (r tail_reveal_and_solution)
314/// )
315/// )
316/// inner_conditions
317/// )
318/// )
319/// (assert parent_is_cat (not extra_delta)
320/// inner_conditions
321/// )
322/// )
323/// )
324///
325/// ;;;;;;;;;;;;;;;;;;;;;;;;;;;
326///
327/// (defun stager_two (
328/// Truths
329/// (inner_conditions . (output_sum . tail_reveal_and_solution))
330/// lineage_proof
331/// prev_coin_id
332/// this_coin_info
333/// next_coin_id
334/// prev_subtotal
335/// extra_delta
336/// )
337/// (check_lineage_or_run_tail_program
338/// this_coin_info
339/// tail_reveal_and_solution
340/// (if lineage_proof (is_parent_cat (cat_struct_truth Truths) (my_parent_cat_truth Truths) lineage_proof) ())
341/// lineage_proof
342/// Truths
343/// extra_delta
344/// (generate_final_output_conditions
345/// prev_subtotal
346/// ; the expression on the next line calculates `this_subtotal` by adding the delta to `prev_subtotal`
347/// (+ prev_subtotal (- (input_amount_for_coin this_coin_info) output_sum) extra_delta)
348/// inner_conditions
349/// prev_coin_id
350/// (my_id_cat_truth Truths)
351/// next_coin_id
352/// (cat_struct_truth Truths)
353/// )
354/// )
355/// )
356///
357/// ; CAT TRUTHS struct is: ; CAT Truths is: ((Inner puzzle hash . (MOD hash . (MOD hash hash . TAIL hash))) . (my_id . (my_parent_info my_puzhash my_amount)))
358/// ; create truths - this_coin_info verified true because we calculated my ID from it!
359/// ; lineage proof is verified later by cat parent check or tail_program
360///
361/// (defun stager (
362/// cat_mod_struct
363/// inner_conditions
364/// lineage_proof
365/// inner_puzzle_hash
366/// my_id
367/// prev_coin_id
368/// this_coin_info
369/// next_coin_proof
370/// prev_subtotal
371/// extra_delta
372/// )
373/// (c (list ASSERT_MY_COIN_ID my_id) (stager_two
374/// (cat_truth_data_to_truth_struct
375/// inner_puzzle_hash
376/// cat_mod_struct
377/// my_id
378/// this_coin_info
379/// )
380/// (find_and_strip_tail_info inner_conditions cat_mod_struct ())
381/// lineage_proof
382/// prev_coin_id
383/// this_coin_info
384/// (coin_id_for_proof next_coin_proof cat_mod_struct)
385/// prev_subtotal
386/// extra_delta
387/// ))
388/// )
389///
390/// (stager
391/// ;; calculate cat_mod_struct, inner_puzzle_hash, coin_id
392/// (list MOD_HASH (sha256 ONE MOD_HASH) TAIL_PROGRAM_HASH)
393/// (a INNER_PUZZLE inner_puzzle_solution)
394/// lineage_proof
395/// (sha256tree INNER_PUZZLE)
396/// (calculate_coin_id (f this_coin_info) (f (r this_coin_info)) (f (r (r this_coin_info))))
397/// prev_coin_id ; ID
398/// this_coin_info ; (parent_id puzzle_hash amount)
399/// next_coin_proof ; (parent_id innerpuzhash amount)
400/// prev_subtotal
401/// extra_delta
402/// )
403/// )
404/// ```
405pub const CAT_PUZZLE: [u8; 1672] = hex!("ff02ffff01ff02ff5effff04ff02ffff04ffff04ff05ffff04ffff0bff34ff0580ffff04ff0bff80808080ffff04ffff02ff17ff2f80ffff04ff5fffff04ffff02ff2effff04ff02ffff04ff17ff80808080ffff04ffff02ff2affff04ff02ffff04ff82027fffff04ff82057fffff04ff820b7fff808080808080ffff04ff81bfffff04ff82017fffff04ff8202ffffff04ff8205ffffff04ff820bffff80808080808080808080808080ffff04ffff01ffffffff3d46ff02ff333cffff0401ff01ff81cb02ffffff20ff02ffff03ff05ffff01ff02ff32ffff04ff02ffff04ff0dffff04ffff0bff7cffff0bff34ff2480ffff0bff7cffff0bff7cffff0bff34ff2c80ff0980ffff0bff7cff0bffff0bff34ff8080808080ff8080808080ffff010b80ff0180ffff02ffff03ffff22ffff09ffff0dff0580ff2280ffff09ffff0dff0b80ff2280ffff15ff17ffff0181ff8080ffff01ff0bff05ff0bff1780ffff01ff088080ff0180ffff02ffff03ff0bffff01ff02ffff03ffff09ffff02ff2effff04ff02ffff04ff13ff80808080ff820b9f80ffff01ff02ff56ffff04ff02ffff04ffff02ff13ffff04ff5fffff04ff17ffff04ff2fffff04ff81bfffff04ff82017fffff04ff1bff8080808080808080ffff04ff82017fff8080808080ffff01ff088080ff0180ffff01ff02ffff03ff17ffff01ff02ffff03ffff20ff81bf80ffff0182017fffff01ff088080ff0180ffff01ff088080ff018080ff0180ff04ffff04ff05ff2780ffff04ffff10ff0bff5780ff778080ffffff02ffff03ff05ffff01ff02ffff03ffff09ffff02ffff03ffff09ff11ff5880ffff0159ff8080ff0180ffff01818f80ffff01ff02ff26ffff04ff02ffff04ff0dffff04ff0bffff04ffff04ff81b9ff82017980ff808080808080ffff01ff02ff7affff04ff02ffff04ffff02ffff03ffff09ff11ff5880ffff01ff04ff58ffff04ffff02ff76ffff04ff02ffff04ff13ffff04ff29ffff04ffff0bff34ff5b80ffff04ff2bff80808080808080ff398080ffff01ff02ffff03ffff09ff11ff7880ffff01ff02ffff03ffff20ffff02ffff03ffff09ffff0121ffff0dff298080ffff01ff02ffff03ffff09ffff0cff29ff80ff3480ff5c80ffff01ff0101ff8080ff0180ff8080ff018080ffff0109ffff01ff088080ff0180ffff010980ff018080ff0180ffff04ffff02ffff03ffff09ff11ff5880ffff0159ff8080ff0180ffff04ffff02ff26ffff04ff02ffff04ff0dffff04ff0bffff04ff17ff808080808080ff80808080808080ff0180ffff01ff04ff80ffff04ff80ff17808080ff0180ffff02ffff03ff05ffff01ff04ff09ffff02ff56ffff04ff02ffff04ff0dffff04ff0bff808080808080ffff010b80ff0180ff0bff7cffff0bff34ff2880ffff0bff7cffff0bff7cffff0bff34ff2c80ff0580ffff0bff7cffff02ff32ffff04ff02ffff04ff07ffff04ffff0bff34ff3480ff8080808080ffff0bff34ff8080808080ffff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff2effff04ff02ffff04ff09ff80808080ffff02ff2effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ffff04ffff04ff30ffff04ff5fff808080ffff02ff7effff04ff02ffff04ffff04ffff04ff2fff0580ffff04ff5fff82017f8080ffff04ffff02ff26ffff04ff02ffff04ff0bffff04ff05ffff01ff808080808080ffff04ff17ffff04ff81bfffff04ff82017fffff04ffff02ff2affff04ff02ffff04ff8204ffffff04ffff02ff76ffff04ff02ffff04ff09ffff04ff820affffff04ffff0bff34ff2d80ffff04ff15ff80808080808080ffff04ff8216ffff808080808080ffff04ff8205ffffff04ff820bffff808080808080808080808080ff02ff5affff04ff02ffff04ff5fffff04ff3bffff04ffff02ffff03ff17ffff01ff09ff2dffff02ff2affff04ff02ffff04ff27ffff04ffff02ff76ffff04ff02ffff04ff29ffff04ff57ffff04ffff0bff34ff81b980ffff04ff59ff80808080808080ffff04ff81b7ff80808080808080ff8080ff0180ffff04ff17ffff04ff05ffff04ff8202ffffff04ffff04ffff04ff78ffff04ffff0eff5cffff02ff2effff04ff02ffff04ffff04ff2fffff04ff82017fff808080ff8080808080ff808080ffff04ffff04ff20ffff04ffff0bff81bfff5cffff02ff2effff04ff02ffff04ffff04ff15ffff04ffff10ff82017fffff11ff8202dfff2b80ff8202ff80ff808080ff8080808080ff808080ff138080ff80808080808080808080ff018080");
406pub const CAT_PUZZLE_HASH: [u8; 32] =
407 hex!("37bef360ee858133b69d595a906dc45d01af50379dad515eb9518abb7c1d2a7a");
408
409/// ```text
410/// ; This is a "limitations_program" for use with cat.clsp.
411/// (mod (
412/// PUBKEY
413/// Truths
414/// parent_is_cat
415/// lineage_proof
416/// delta
417/// inner_conditions
418/// (
419/// delegated_puzzle
420/// delegated_solution
421/// )
422/// )
423///
424/// (include condition_codes.clib)
425///
426/// (defun sha256tree1 (TREE)
427/// (if (l TREE)
428/// (sha256 2 (sha256tree1 (f TREE)) (sha256tree1 (r TREE)))
429/// (sha256 1 TREE)))
430///
431/// (c (list AGG_SIG_UNSAFE PUBKEY (sha256tree1 delegated_puzzle))
432/// (a delegated_puzzle (c Truths (c parent_is_cat (c lineage_proof (c delta (c inner_conditions delegated_solution))))))
433/// )
434/// )
435/// ```
436pub const DELEGATED_TAIL: [u8; 180] = hex!("ff02ffff01ff04ffff04ff04ffff04ff05ffff04ffff02ff06ffff04ff02ffff04ff82027fff80808080ff80808080ffff02ff82027fffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ff81bfff82057f80808080808080ffff04ffff01ff31ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff06ffff04ff02ffff04ff09ff80808080ffff02ff06ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080");
437pub const DELEGATED_TAIL_HASH: [u8; 32] =
438 hex!("999c3696e167f8a79d938adc11feba3a3dcb39ccff69a426d570706e7b8ec399");
439
440/// ```text
441/// ; This is a "limitations_program" for use with cat.clsp.
442/// (mod (
443/// PUBKEY
444/// Truths
445/// parent_is_cat
446/// lineage_proof
447/// delta
448/// inner_conditions
449/// _
450/// )
451///
452/// (include condition_codes.clib)
453///
454/// (list (list AGG_SIG_ME PUBKEY delta)) ; Careful with a delta of zero, the bytecode is 80 not 00
455/// )
456/// ```
457pub const EVERYTHING_WITH_SIGNATURE: [u8; 41] =
458 hex!("ff02ffff01ff04ffff04ff02ffff04ff05ffff04ff5fff80808080ff8080ffff04ffff0132ff018080");
459pub const EVERYTHING_WITH_SIGNATURE_HASH: [u8; 32] =
460 hex!("1720d13250a7c16988eaf530331cefa9dd57a76b2c82236bec8bbbff91499b89");
461
462/// ```text
463/// ; This is a "limitations_program" for use with cat.clsp.
464/// ; It allows a singleton to both mint and melt this CAT by sending a message.
465/// (mod (
466/// SINGLETON_MOD_HASH
467/// SINGLETON_STRUCT_HASH ; The hash of (SINGLETON_MOD_HASH . (LAUNCHER_ID . SINGLETON_LAUNCHER_HASH))
468/// NONCE
469/// Truths
470/// parent_is_cat
471/// lineage_proof
472/// delta
473/// inner_conditions
474/// ( ; solution
475/// singleton_inner_puzzle_hash
476/// )
477/// )
478///
479/// (include condition_codes.clib)
480/// (include curry.clib)
481///
482/// (defun-inline calculate_full_puzzle_hash (SINGLETON_MOD_HASH SINGLETON_STRUCT_HASH inner_puzzle_hash)
483/// (curry_hashes_inline SINGLETON_MOD_HASH
484/// SINGLETON_STRUCT_HASH
485/// inner_puzzle_hash
486/// )
487/// )
488///
489/// (list
490/// (list RECEIVE_MESSAGE
491/// 23 ; = 010 111, mask for puzzle hash to coin ID
492/// delta
493/// (calculate_full_puzzle_hash SINGLETON_MOD_HASH SINGLETON_STRUCT_HASH singleton_inner_puzzle_hash)
494/// )
495/// )
496/// )
497/// ```
498pub const EVERYTHING_WITH_SINGLETON: [u8; 283] = hex!("ff02ffff01ff04ffff04ff04ffff04ffff0117ffff04ff82017fffff04ffff0bff2effff0bff0affff0bff0aff36ff0580ffff0bff0affff0bff3effff0bff0affff0bff0aff36ff0b80ffff0bff0affff0bff3effff0bff0affff0bff0aff36ff8209ff80ffff0bff0aff36ff26808080ff26808080ff26808080ff8080808080ff8080ffff04ffff01ff43ff02ffffa04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459aa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ffa102a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222a102a8d5dd63fba471ebcb1f3e8f7c1e1879b7152a6e7298a91ce119a63400ade7c5ff018080");
499pub const EVERYTHING_WITH_SINGLETON_HASH: [u8; 32] =
500 hex!("0876da2005fe6262d4504c27a1b6379227aba8adbbad3758cb0e329a4e74c6cc");
501
502/// ```text
503/// ; This is a TAIL for use with cat.klvm.
504/// ;
505/// ; This checker allows new CATs to be created if they have a particular coin id as parent
506/// ;
507/// ; The genesis_id is curried in, making this lineage_check program unique and giving the CAT it's uniqueness
508/// (mod (
509/// GENESIS_ID
510/// MINT_LAUNCHER_PUZZLE_HASH
511/// Truths
512/// parent_is_cat
513/// lineage_proof
514/// delta
515/// inner_conditions
516/// ( ; solution
517/// parent_parent_id
518/// parent_amount
519/// )
520/// )
521///
522/// (include cat_truths.clib)
523/// (include curry-and-treehash.clib)
524///
525/// (if delta
526/// (x)
527/// (if (= (my_parent_cat_truth Truths) GENESIS_ID)
528/// ()
529/// (if
530/// (=
531/// (my_parent_cat_truth Truths)
532/// (sha256
533/// parent_parent_id
534/// MINT_LAUNCHER_PUZZLE_HASH
535/// parent_amount
536/// )
537/// )
538/// ()
539/// (x)
540/// )
541/// )
542/// )
543///
544/// )
545/// ```
546pub const GENESIS_BY_COIN_ID_OR_SINGLETON: [u8; 79] = hex!("ff02ffff03ff5fffff01ff0880ffff01ff02ffff03ffff09ff5bff0280ff80ffff01ff02ffff03ffff09ff5bffff0bff82027fff05ff82057f8080ff80ffff01ff088080ff018080ff018080ff0180");
547pub const GENESIS_BY_COIN_ID_OR_SINGLETON_HASH: [u8; 32] =
548 hex!("40170305e3a71c3e7523f37fbcfc3188f9f949da0818a6331f28251e76e8c56f");
549
550/// ```text
551/// ; This is a TAIL for use with cat.klvm.
552/// ;
553/// ; This checker allows new CATs to be created if they have a particular coin id as parent
554/// ;
555/// ; The genesis_id is curried in, making this lineage_check program unique and giving the CAT it's uniqueness
556/// (mod (
557/// GENESIS_ID
558/// Truths
559/// parent_is_cat
560/// lineage_proof
561/// delta
562/// inner_conditions
563/// _
564/// )
565///
566/// (include cat_truths.clib)
567///
568/// (if delta
569/// (x)
570/// (if (= (my_parent_cat_truth Truths) GENESIS_ID)
571/// ()
572/// (x)
573/// )
574/// )
575///
576/// )
577/// ```
578pub const GENESIS_BY_COIN_ID: [u8; 45] = hex!(
579 "ff02ffff03ff2fffff01ff0880ffff01ff02ffff03ffff09ff2dff0280ff80ffff01ff088080ff018080ff0180"
580);
581pub const GENESIS_BY_COIN_ID_HASH: [u8; 32] =
582 hex!("493afb89eed93ab86741b2aa61b8f5de495d33ff9b781dfc8919e602b2afa150");
583
584/// ```text
585/// ; This is a "limitations_program" for use with cat.clsp.
586/// ;
587/// ; This checker allows new CATs to be created if their parent has a particular puzzle hash
588/// (mod (
589/// GENESIS_PUZZLE_HASH
590/// Truths
591/// parent_is_cat
592/// lineage_proof
593/// delta
594/// inner_conditions
595/// (parent_parent_id parent_amount)
596/// )
597///
598/// (include cat_truths.clib)
599///
600/// ; Returns nil since we don't need to add any conditions
601/// (if delta
602/// (x)
603/// (if (= (sha256 parent_parent_id GENESIS_PUZZLE_HASH parent_amount) (my_parent_cat_truth Truths))
604/// ()
605/// (x)
606/// )
607/// )
608/// )
609/// ```
610pub const GENESIS_BY_PUZZLE_HASH: [u8; 57] = hex!("ff02ffff03ff2fffff01ff0880ffff01ff02ffff03ffff09ffff0bff82013fff02ff8202bf80ff2d80ff80ffff01ff088080ff018080ff0180");
611pub const GENESIS_BY_PUZZLE_HASH_HASH: [u8; 32] =
612 hex!("de5a6e06d41518be97ff6365694f4f89475dda773dede267caa33da63b434e36");
613
614/// ```text
615/// ; This file is what the first form the CAT takes, and then it gets immediately eve spent out of here.
616/// ; This allows the coin to move into its real state already having been eve spent and validated to not be a fake CAT.
617/// ; The trick is that we won't know what the real state puzzlehash reveal is, but we will know what this is.
618/// ; Mint into this, eve spend out of this
619/// (mod (
620/// NEW_PUZZLE_HASH ; this is the CAT inner_puzzle
621/// my_amount
622/// tail_reveal
623/// tail_solution
624/// )
625/// (include condition_codes.clib)
626/// (list
627/// (list CREATE_COIN NEW_PUZZLE_HASH my_amount (list NEW_PUZZLE_HASH))
628/// (list ASSERT_MY_AMOUNT my_amount)
629/// (list CREATE_COIN 0 -113 tail_reveal tail_solution) ; this is secure because anything but the real values won't work
630/// )
631/// )
632/// ```
633pub const DAO_CAT_EVE: [u8; 112] = hex!("ff02ffff01ff04ffff04ff06ffff04ff05ffff04ff0bffff04ffff04ff05ff8080ff8080808080ffff04ffff04ff04ffff04ff0bff808080ffff04ffff04ff06ffff04ff80ffff04ffff01818fffff04ff17ffff04ff2fff808080808080ff80808080ffff04ffff01ff4933ff018080");
634pub const DAO_CAT_EVE_HASH: [u8; 32] =
635 hex!("488f55bedaca5a599544dfd5ab341e2e5c7e6fca67d9b98a3d856f876c52f53e");
636
637/// ```text
638/// (mod (
639/// TREASURY_SINGLETON_STRUCT
640/// treasury_inner_puz_hash
641/// parent_parent
642/// new_puzzle_hash ; the full CAT puzzle
643/// amount
644/// )
645/// (include condition_codes.clib)
646/// (include curry-and-treehash.clib)
647///
648/// (defun calculate_singleton_puzzle_hash (PROPOSAL_SINGLETON_STRUCT inner_puzzle_hash)
649/// (puzzle-hash-of-curried-function (f PROPOSAL_SINGLETON_STRUCT)
650/// inner_puzzle_hash
651/// (sha256tree PROPOSAL_SINGLETON_STRUCT)
652/// )
653/// )
654///
655/// (defun create_parent_conditions (parent_id new_puzzle_hash amount)
656/// (list
657/// (list ASSERT_COIN_ANNOUNCEMENT (sha256 parent_id (sha256tree (list 'm' new_puzzle_hash))))
658/// (list ASSERT_MY_PARENT_ID parent_id)
659/// )
660/// )
661///
662/// (c
663/// (list CREATE_COIN new_puzzle_hash amount (list new_puzzle_hash))
664/// (c
665/// (list ASSERT_MY_AMOUNT amount)
666/// (create_parent_conditions
667/// (sha256 parent_parent (calculate_singleton_puzzle_hash TREASURY_SINGLETON_STRUCT treasury_inner_puz_hash) ONE)
668/// new_puzzle_hash
669/// amount
670/// )
671/// )
672/// )
673/// )
674/// ```
675pub const DAO_CAT_LAUNCHER: [u8; 529] = hex!("ff02ffff01ff04ffff04ff34ffff04ff2fffff04ff5fffff04ffff04ff2fff8080ff8080808080ffff04ffff04ff28ffff04ff5fff808080ffff02ff36ffff04ff02ffff04ffff0bff17ffff02ff26ffff04ff02ffff04ff05ffff04ff0bff8080808080ff3c80ffff04ff2fffff04ff5fff8080808080808080ffff04ffff01ffffff3dff4947ffff0233ff0401ffff01ff02ff02ffff03ff05ffff01ff02ff3affff04ff02ffff04ff0dffff04ffff0bff2affff0bff3cff2c80ffff0bff2affff0bff2affff0bff3cff1280ff0980ffff0bff2aff0bffff0bff3cff8080808080ff8080808080ffff010b80ff0180ffffff02ff2effff04ff02ffff04ff09ffff04ff0bffff04ffff02ff3effff04ff02ffff04ff05ff80808080ff808080808080ff04ffff04ff10ffff04ffff0bff05ffff02ff3effff04ff02ffff04ffff04ffff016dffff04ff0bff808080ff8080808080ff808080ffff04ffff04ff38ffff04ff05ff808080ff808080ffff0bff2affff0bff3cff2480ffff0bff2affff0bff2affff0bff3cff1280ff0580ffff0bff2affff02ff3affff04ff02ffff04ff07ffff04ffff0bff3cff3c80ff8080808080ffff0bff3cff8080808080ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff3effff04ff02ffff04ff09ff80808080ffff02ff3effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080");
676pub const DAO_CAT_LAUNCHER_HASH: [u8; 32] =
677 hex!("a01a838d18d4e031e937c79fa3f80f213fa00a3e64af6c16a1f137770cd3a567");
678
679/// ```text
680/// ; This code is the end state of a proposal or a dividend.
681/// ; It is an oracle which simply recreates itself and emits an announcement that it has concluded operation
682///
683/// (mod (SINGLETON_STRUCT DAO_FINISHED_STATE_MOD_HASH my_amount)
684/// (include condition_codes.clib)
685/// (include curry-and-treehash.clib)
686/// (include *standard-cl-21*)
687///
688/// (defun wrap_in_singleton (SINGLETON_STRUCT my_inner_puzhash)
689/// (puzzle-hash-of-curried-function (f SINGLETON_STRUCT)
690/// my_inner_puzhash
691/// (sha256tree SINGLETON_STRUCT)
692/// )
693/// )
694///
695/// (defun recreate_self (SINGLETON_STRUCT DAO_FINISHED_STATE_MOD_HASH)
696/// (puzzle-hash-of-curried-function DAO_FINISHED_STATE_MOD_HASH
697/// (sha256 ONE DAO_FINISHED_STATE_MOD_HASH)
698/// (sha256tree SINGLETON_STRUCT)
699/// )
700/// )
701///
702///
703/// (let
704/// (
705/// (my_inner_puzhash (recreate_self SINGLETON_STRUCT DAO_FINISHED_STATE_MOD_HASH))
706/// )
707/// (list
708/// (list ASSERT_MY_PUZZLEHASH (wrap_in_singleton SINGLETON_STRUCT my_inner_puzhash))
709/// (list ASSERT_MY_AMOUNT my_amount)
710/// (list CREATE_COIN my_inner_puzhash my_amount)
711/// (list CREATE_PUZZLE_ANNOUNCEMENT 0)
712/// )
713/// )
714/// )
715/// ```
716pub const DAO_FINISHED_STATE: [u8; 771] = hex!("ff02ffff01ff04ffff04ffff0148ffff04ffff02ff16ffff04ff02ffff04ffff05ffff06ff018080ffff04ffff02ff1effff04ff02ffff04ff05ffff04ff0bff8080808080ff8080808080ffff01808080ffff04ffff04ffff0149ffff04ffff05ffff06ffff06ffff06ff0180808080ffff01808080ffff04ffff04ffff0133ffff04ffff02ff1effff04ff02ffff04ff05ffff04ff0bff8080808080ffff04ffff05ffff06ffff06ffff06ff0180808080ffff0180808080ffff04ffff04ffff013effff04ffff0180ffff01808080ffff018080808080ffff04ffff01ffffff02ffff03ff05ffff01ff02ffff01ff02ff08ffff04ff02ffff04ffff06ff0580ffff04ffff0bffff0102ffff0bffff0101ffff010480ffff0bffff0102ffff0bffff0102ffff0bffff0101ffff010180ffff05ff058080ffff0bffff0102ff0bffff0bffff0101ffff018080808080ff8080808080ff0180ffff01ff02ffff010bff018080ff0180ff0bffff0102ffff01a0a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222ffff0bffff0102ffff0bffff0102ffff01a09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ff0580ffff0bffff0102ffff02ff08ffff04ff02ffff04ff07ffff01ffa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b280808080ffff01a04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a808080ffff02ffff03ffff07ff0580ffff01ff02ffff01ff0bffff0102ffff02ff0affff04ff02ffff04ffff05ff0580ff80808080ffff02ff0affff04ff02ffff04ffff06ff0580ff8080808080ff0180ffff01ff02ffff01ff0bffff0101ff0580ff018080ff0180ffff02ff0cffff04ff02ffff04ff09ffff04ff0bffff04ffff02ff0affff04ff02ffff04ff05ff80808080ff808080808080ff02ff0cffff04ff02ffff04ff0bffff04ffff0bffff0101ff0b80ffff04ffff02ff0affff04ff02ffff04ff05ff80808080ff808080808080ff018080");
717pub const DAO_FINISHED_STATE_HASH: [u8; 32] =
718 hex!("694c99e1fb07671771bbca3d110880693a9ecc37a6529891ec979d0f3e760eba");
719
720/// ```text
721/// ; This code is the "voting mode" for a DAO CAT.
722/// ; The coin can be spent from this state to vote on a proposal or claim a dividend.
723/// ; It locks the CAT in while it has active votes/dividends going on.
724/// ; Once a vote or dividend closes, then the coin can spend itself to remove that coin from the "active list"
725/// ; If the "active list" is empty the coin can leave the voting mode
726///
727/// (mod (
728/// ; this is the first curry
729/// SINGLETON_MOD_HASH
730/// SINGLETON_LAUNCHER_PUZHASH
731/// DAO_FINISHED_STATE_MOD_HASH
732/// CAT_MOD_HASH
733/// CAT_TAIL_HASH
734/// ; this is the second curry
735/// SELF_HASH ; this is the self_hash Optimization
736/// ACTIVE_VOTES ; "active votes" list
737/// INNERPUZ
738/// ; this is the solution
739/// my_id ; if my_id is 0 we do the return to return_address (exit voting mode) spend case
740/// inner_solution
741/// my_amount
742/// new_proposal_vote_id_or_removal_id ; removal_id is a list of removal_ids
743/// proposal_innerpuzhash ; list of singleton innerpuzhashes which should match the order of the new_proposal_vote_id list
744/// vote_info
745/// vote_amount
746/// my_inner_puzhash
747/// new_innerpuzhash ; only include this if we're changing owners - secured because coin is still made from inner_puz
748/// )
749/// (include condition_codes.clib)
750/// (include curry-and-treehash.clib)
751/// (include *standard-cl-21*)
752///
753/// (defun calculate_finished_state (singleton_struct dao_finished_state)
754/// (puzzle-hash-of-curried-function dao_finished_state
755/// (sha256 ONE dao_finished_state)
756/// (sha256tree singleton_struct)
757/// )
758/// )
759///
760/// ; take two lists and merge them into one
761/// (defun merge_list (list_a list_b)
762/// (if list_a
763/// (c (f list_a) (merge_list (r list_a) list_b))
764/// list_b
765/// )
766/// )
767///
768/// (defun wrap_in_cat_layer (CAT_MOD_HASH CAT_TAIL_HASH INNERPUZHASH)
769/// (puzzle-hash-of-curried-function CAT_MOD_HASH
770/// INNERPUZHASH
771/// (sha256 ONE CAT_TAIL_HASH)
772/// (sha256 ONE CAT_MOD_HASH)
773/// )
774/// )
775///
776/// ; loop through conditions and check that they aren't trying to create anything they shouldn't
777/// (defun check_conditions (conditions vote_added_puzhash my_amount message vote_amount my_inner_puzhash seen_vote seen_change)
778/// (if conditions
779/// (if (= (f (f conditions)) CREATE_COIN) ; this guarantees that the new coin is obeying the rules - other coins are banned to avoid re-voting
780/// (if (= (f (r (f conditions))) vote_added_puzhash)
781/// (if seen_vote ; assert we haven't already made a coin with the new vote included
782/// (x)
783/// (if (= (f (r (r (f conditions)))) my_amount) ; we vote with all our value
784/// (if seen_change ; assert that we haven't already recreated ourself in some fashion
785/// (x)
786/// (c (f conditions) (check_conditions (r conditions) vote_added_puzhash my_amount message vote_amount my_inner_puzhash 1 1))
787/// )
788/// (if (= (f (r (r (f conditions)))) vote_amount) ; we vote with part of our power
789/// (c (f conditions) (check_conditions (r conditions) vote_added_puzhash my_amount message vote_amount my_inner_puzhash 1 seen_change))
790/// (x)
791/// )
792/// )
793/// )
794/// (if (all
795/// (= (f (r (f conditions))) my_inner_puzhash)
796/// (not seen_change)
797/// (= (f (r (r (f conditions)))) (- my_amount vote_amount))
798/// ) ; we recreate ourselves with unused voting power
799/// (c (f conditions) (check_conditions (r conditions) vote_added_puzhash my_amount message vote_amount my_inner_puzhash seen_vote 1))
800/// (x)
801/// )
802/// )
803/// (if (= (f (f conditions)) CREATE_PUZZLE_ANNOUNCEMENT) ; this secures the values used to generate message - other messages are banned in case of LIES
804/// (if (= (f (r (f conditions))) message)
805/// (c (f conditions) (check_conditions (r conditions) vote_added_puzhash my_amount message vote_amount my_inner_puzhash seen_vote seen_change))
806/// (x)
807/// )
808/// (c (f conditions) (check_conditions (r conditions) vote_added_puzhash my_amount message vote_amount my_inner_puzhash seen_vote seen_change))
809/// )
810/// )
811/// (if (all seen_vote seen_change) ; check all value is accounted for
812/// ()
813/// (x)
814/// )
815/// )
816/// )
817///
818/// ; go through our list of active votes and check that we aren't revoting
819/// (defun check_not_previously_voted (
820/// SINGLETON_MOD_HASH
821/// SINGLETON_LAUNCHER_PUZHASH
822/// INNERPUZ
823/// my_id
824/// new_vote_id
825/// active_votes
826/// proposal_innerpuzhash
827/// )
828/// (if active_votes
829/// (if (= new_vote_id (f active_votes)) ; check new vote id is not equal to an existent vote id
830/// (x)
831/// (check_not_previously_voted
832/// SINGLETON_MOD_HASH
833/// SINGLETON_LAUNCHER_PUZHASH
834/// INNERPUZ
835/// my_id
836/// new_vote_id
837/// (r active_votes)
838/// proposal_innerpuzhash
839/// )
840/// )
841/// (list ASSERT_PUZZLE_ANNOUNCEMENT
842/// (sha256
843/// (calculate_singleton_puzzle_hash
844/// (c SINGLETON_MOD_HASH (c new_vote_id SINGLETON_LAUNCHER_PUZHASH))
845/// proposal_innerpuzhash
846/// )
847/// my_id
848/// )
849/// )
850/// )
851/// )
852///
853///
854/// (defun calculate_singleton_puzzle_hash (PROPOSAL_SINGLETON_STRUCT inner_puzzle_hash)
855/// (puzzle-hash-of-curried-function (f PROPOSAL_SINGLETON_STRUCT)
856/// inner_puzzle_hash
857/// (sha256tree PROPOSAL_SINGLETON_STRUCT)
858/// )
859/// )
860///
861/// (defun calculate_lockup_puzzlehash (
862/// SELF_HASH
863/// active_votes
864/// innerpuzhash
865/// )
866/// (puzzle-hash-of-curried-function SELF_HASH
867/// innerpuzhash
868/// (sha256tree active_votes)
869/// (sha256 ONE SELF_HASH)
870/// )
871/// )
872///
873/// (defun for_every_removal_id (
874/// SINGLETON_MOD_HASH
875/// SINGLETON_LAUNCHER_PUZHASH
876/// SELF_HASH
877/// DAO_FINISHED_STATE_MOD_HASH
878/// CAT_MOD_HASH
879/// CAT_TAIL_HASH
880/// ACTIVE_VOTES
881/// INNERPUZ
882/// removal_ids
883/// my_amount
884/// unused_votes
885/// )
886/// (if removal_ids
887/// (c
888/// (list
889/// ASSERT_PUZZLE_ANNOUNCEMENT ; check proposal is actually finished
890/// (sha256
891/// (calculate_singleton_puzzle_hash
892/// (c SINGLETON_MOD_HASH (c (f removal_ids) SINGLETON_LAUNCHER_PUZHASH))
893/// (calculate_finished_state
894/// (c SINGLETON_MOD_HASH (c (f removal_ids) SINGLETON_LAUNCHER_PUZHASH))
895/// DAO_FINISHED_STATE_MOD_HASH
896/// )
897/// )
898/// 0
899/// )
900/// )
901/// (for_every_removal_id
902/// SINGLETON_MOD_HASH
903/// SINGLETON_LAUNCHER_PUZHASH
904/// SELF_HASH
905/// DAO_FINISHED_STATE_MOD_HASH
906/// CAT_MOD_HASH
907/// CAT_TAIL_HASH
908/// ACTIVE_VOTES
909/// INNERPUZ
910/// (r removal_ids)
911/// my_amount
912/// (c (f removal_ids) unused_votes)
913/// )
914/// )
915/// (list
916/// (list ASSERT_MY_AMOUNT my_amount) ; assert that we aren't lying about our amount to free up money and re-vote
917/// (list
918/// CREATE_COIN ; recreate self with the finished proposal ID removed
919/// (calculate_lockup_puzzlehash
920/// SELF_HASH
921/// (remove_list_one_entries_from_list_two unused_votes ACTIVE_VOTES)
922/// (sha256tree INNERPUZ)
923/// )
924/// my_amount
925/// )
926/// )
927/// )
928/// )
929///
930/// (defun remove_list_one_entries_from_list_two (list_one list_two)
931/// (if list_one
932/// (remove_item_from_list (f list_one) (remove_list_one_entries_from_list_two (r list_one) list_two))
933/// list_two
934/// )
935/// )
936///
937/// (defun remove_item_from_list (item list_one)
938/// (if list_one
939/// (if (= (f list_one) item)
940/// (r list_one) ; assuming there are no duplicates
941/// (c (f list_one) (remove_item_from_list item (r list_one)))
942/// )
943/// () ; item was never in list_one, return list_two entirely
944/// )
945/// )
946///
947///
948/// ; main
949/// (if my_id
950/// (c (list ASSERT_MY_PUZZLEHASH (wrap_in_cat_layer CAT_MOD_HASH CAT_TAIL_HASH my_inner_puzhash))
951/// (c
952/// (list ASSERT_MY_AMOUNT my_amount)
953/// (c
954/// (list ASSERT_MY_COIN_ID my_id)
955/// (c
956/// (if new_proposal_vote_id_or_removal_id
957/// (check_not_previously_voted ; this returns a single condition asserting announcement from vote singleton
958/// SINGLETON_MOD_HASH
959/// SINGLETON_LAUNCHER_PUZHASH
960/// INNERPUZ
961/// my_id
962/// new_proposal_vote_id_or_removal_id
963/// ACTIVE_VOTES
964/// proposal_innerpuzhash
965/// )
966/// (list REMARK)
967/// )
968///
969/// ; loop over conditions and check that we aren't trying to leave voting state
970/// (check_conditions
971/// (a INNERPUZ inner_solution)
972/// (calculate_lockup_puzzlehash ; compare created coin to our own calculation on what the next puzzle should be
973/// SELF_HASH
974/// (if new_proposal_vote_id_or_removal_id (c new_proposal_vote_id_or_removal_id ACTIVE_VOTES) ACTIVE_VOTES)
975/// (if new_innerpuzhash new_innerpuzhash (sha256tree INNERPUZ))
976/// )
977/// my_amount
978/// ; TODO: add namespace to this announcement to allow announcements from the innerpuz
979/// (sha256tree (list new_proposal_vote_id_or_removal_id vote_amount vote_info my_id))
980/// vote_amount
981/// my_inner_puzhash
982/// 0
983/// 0
984/// )
985/// )
986/// )
987/// )
988/// )
989///
990/// ; return to return_address or remove something from active list - check if our locked list is empty
991/// (if ACTIVE_VOTES
992/// (for_every_removal_id ; locked list is not empty, so we must be trying to remove something from it
993/// SINGLETON_MOD_HASH
994/// SINGLETON_LAUNCHER_PUZHASH
995/// SELF_HASH
996/// DAO_FINISHED_STATE_MOD_HASH
997/// CAT_MOD_HASH
998/// CAT_TAIL_HASH
999/// ACTIVE_VOTES
1000/// INNERPUZ
1001/// new_proposal_vote_id_or_removal_id
1002/// my_amount
1003/// ()
1004/// )
1005/// (a INNERPUZ inner_solution)
1006/// )
1007/// )
1008/// )
1009/// ```
1010pub const DAO_LOCKUP: [u8; 3140] = hex!("ff02ffff01ff02ffff03ff8205ffffff01ff02ffff01ff04ffff04ffff0148ffff04ffff02ff2cffff04ff02ffff04ff2fffff04ff5fffff04ff8302ffffff808080808080ffff01808080ffff04ffff04ffff0149ffff04ff8217ffffff01808080ffff04ffff04ffff0146ffff04ff8205ffffff01808080ffff04ffff02ffff03ff822fffffff01ff02ffff01ff02ff12ffff04ff02ffff04ff05ffff04ff0bffff04ff8202ffffff04ff8205ffffff04ff822fffffff04ff82017fffff04ff825fffff80808080808080808080ff0180ffff01ff02ffff01ff04ffff0101ffff018080ff018080ff0180ffff02ff3cffff04ff02ffff04ffff02ff8202ffff820bff80ffff04ffff02ff3affff04ff02ffff04ff8200bfffff04ffff02ffff03ff822fffffff01ff02ffff01ff04ff822fffff82017f80ff0180ffff01ff02ffff0182017fff018080ff0180ffff04ffff02ffff03ff8305ffffffff01ff02ffff018305ffffff0180ffff01ff02ffff01ff02ff38ffff04ff02ffff04ff8202ffff80808080ff018080ff0180ff808080808080ffff04ff8217ffffff04ffff02ff38ffff04ff02ffff04ffff04ff822fffffff04ff83017fffffff04ff8300bfffffff04ff8205ffffff018080808080ff80808080ffff04ff83017fffffff04ff8302ffffffff04ffff0180ffff04ffff0180ff808080808080808080808080808080ff0180ffff01ff02ffff01ff02ffff03ff82017fffff01ff02ffff01ff02ff16ffff04ff02ffff04ff05ffff04ff0bffff04ff8200bfffff04ff17ffff04ff2fffff04ff5fffff04ff82017fffff04ff8202ffffff04ff822fffffff04ff8217ffffff04ffff0180ff8080808080808080808080808080ff0180ffff01ff02ffff01ff02ff8202ffff820bff80ff018080ff0180ff018080ff0180ffff04ffff01ffffffff02ffff03ff05ffff01ff02ffff01ff02ff10ffff04ff02ffff04ffff06ff0580ffff04ffff0bffff0102ffff0bffff0101ffff010480ffff0bffff0102ffff0bffff0102ffff0bffff0101ffff010180ffff05ff058080ffff0bffff0102ff0bffff0bffff0101ffff018080808080ff8080808080ff0180ffff01ff02ffff010bff018080ff0180ffff0bffff0102ffff01a0a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222ffff0bffff0102ffff0bffff0102ffff01a09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ff0580ffff0bffff0102ffff02ff10ffff04ff02ffff04ff07ffff01ffa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b280808080ffff01a04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a808080ff02ffff03ffff07ff0580ffff01ff02ffff01ff0bffff0102ffff02ff38ffff04ff02ffff04ffff05ff0580ff80808080ffff02ff38ffff04ff02ffff04ffff06ff0580ff8080808080ff0180ffff01ff02ffff01ff0bffff0101ff0580ff018080ff0180ffff02ff28ffff04ff02ffff04ff0bffff04ffff0bffff0101ff0b80ffff04ffff02ff38ffff04ff02ffff04ff05ff80808080ff808080808080ffff02ff28ffff04ff02ffff04ff05ffff04ff17ffff04ffff0bffff0101ff0b80ffff04ffff0bffff0101ff0580ff80808080808080ff02ffff03ff05ffff01ff02ffff01ff02ffff03ffff09ffff05ffff05ff058080ffff013380ffff01ff02ffff01ff02ffff03ffff09ffff05ffff06ffff05ff05808080ff0b80ffff01ff02ffff01ff02ffff03ff82017fffff01ff02ffff01ff0880ff0180ffff01ff02ffff01ff02ffff03ffff09ffff05ffff06ffff06ffff05ff0580808080ff1780ffff01ff02ffff01ff02ffff03ff8202ffffff01ff02ffff01ff0880ff0180ffff01ff02ffff01ff04ffff05ff0580ffff02ff3cffff04ff02ffff04ffff06ff0580ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ff8200bfffff04ffff0101ffff04ffff0101ff808080808080808080808080ff018080ff0180ff0180ffff01ff02ffff01ff02ffff03ffff09ffff05ffff06ffff06ffff05ff0580808080ff5f80ffff01ff02ffff01ff04ffff05ff0580ffff02ff3cffff04ff02ffff04ffff06ff0580ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ff8200bfffff04ffff0101ffff04ff8202ffff808080808080808080808080ff0180ffff01ff02ffff01ff0880ff018080ff0180ff018080ff0180ff018080ff0180ff0180ffff01ff02ffff01ff02ffff03ffff22ffff09ffff05ffff06ffff05ff05808080ff8200bf80ffff20ff8202ff80ffff09ffff05ffff06ffff06ffff05ff0580808080ffff11ff17ff5f808080ffff01ff02ffff01ff04ffff05ff0580ffff02ff3cffff04ff02ffff04ffff06ff0580ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ff8200bfffff04ff82017fffff04ffff0101ff808080808080808080808080ff0180ffff01ff02ffff01ff0880ff018080ff0180ff018080ff0180ff0180ffff01ff02ffff01ff02ffff03ffff09ffff05ffff05ff058080ffff013e80ffff01ff02ffff01ff02ffff03ffff09ffff05ffff06ffff05ff05808080ff2f80ffff01ff02ffff01ff04ffff05ff0580ffff02ff3cffff04ff02ffff04ffff06ff0580ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ff8200bfffff04ff82017fffff04ff8202ffff808080808080808080808080ff0180ffff01ff02ffff01ff0880ff018080ff0180ff0180ffff01ff02ffff01ff04ffff05ff0580ffff02ff3cffff04ff02ffff04ffff06ff0580ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ff8200bfffff04ff82017fffff04ff8202ffff808080808080808080808080ff018080ff0180ff018080ff0180ff0180ffff01ff02ffff01ff02ffff03ffff22ff82017fff8202ff80ffff01ff02ffff01ff0180ff0180ffff01ff02ffff01ff0880ff018080ff0180ff018080ff0180ffffff02ffff03ff8200bfffff01ff02ffff01ff02ffff03ffff09ff5fffff05ff8200bf8080ffff01ff02ffff01ff0880ff0180ffff01ff02ffff01ff02ff12ffff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ffff06ff8200bf80ffff04ff82017fff80808080808080808080ff018080ff0180ff0180ffff01ff02ffff01ff04ffff013fffff04ffff0bffff02ff2affff04ff02ffff04ffff04ff05ffff04ff5fff0b8080ffff04ff82017fff8080808080ff2f80ffff01808080ff018080ff0180ffff02ff28ffff04ff02ffff04ff09ffff04ff0bffff04ffff02ff38ffff04ff02ffff04ff05ff80808080ff808080808080ff02ff28ffff04ff02ffff04ff05ffff04ff17ffff04ffff02ff38ffff04ff02ffff04ff0bff80808080ffff04ffff0bffff0101ff0580ff80808080808080ffff02ffff03ff8205ffffff01ff02ffff01ff04ffff04ffff013fffff04ffff0bffff02ff2affff04ff02ffff04ffff04ff05ffff04ffff05ff8205ff80ff0b8080ffff04ffff02ff14ffff04ff02ffff04ffff04ff05ffff04ffff05ff8205ff80ff0b8080ffff04ff2fff8080808080ff8080808080ffff018080ffff01808080ffff02ff16ffff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ff8200bfffff04ff82017fffff04ff8202ffffff04ffff06ff8205ff80ffff04ff820bffffff04ffff04ffff05ff8205ff80ff8217ff80ff808080808080808080808080808080ff0180ffff01ff02ffff01ff04ffff04ffff0149ffff04ff820bffffff01808080ffff04ffff04ffff0133ffff04ffff02ff3affff04ff02ffff04ff17ffff04ffff02ff2effff04ff02ffff04ff8217ffffff04ff82017fff8080808080ffff04ffff02ff38ffff04ff02ffff04ff8202ffff80808080ff808080808080ffff04ff820bffffff0180808080ffff01808080ff018080ff0180ffff02ffff03ff05ffff01ff02ffff01ff02ff3effff04ff02ffff04ffff05ff0580ffff04ffff02ff2effff04ff02ffff04ffff06ff0580ffff04ff0bff8080808080ff8080808080ff0180ffff01ff02ffff010bff018080ff0180ff02ffff03ff0bffff01ff02ffff01ff02ffff03ffff09ffff05ff0b80ff0580ffff01ff02ffff01ff06ff0b80ff0180ffff01ff02ffff01ff04ffff05ff0b80ffff02ff3effff04ff02ffff04ff05ffff04ffff06ff0b80ff808080808080ff018080ff0180ff0180ffff01ff02ffff01ff0180ff018080ff0180ff018080");
1011pub const DAO_LOCKUP_HASH: [u8; 32] =
1012 hex!("d6215f0916715a69fbbf2d1a679f437fde81787adeb90c666642fb9c2deff7ce");
1013
1014/// ```text
1015/// ; This is a persistent timer for a proposal which allows it to have a relative time that survives despite it being recreated.
1016/// ; The closing time is contained in the timelock and passed in to the solution, and confirmed via an announcement from the Proposal
1017/// ; It creates/asserts announcements to pair it with the finishing spend of a proposal
1018///
1019/// (mod (
1020/// PROPOSAL_SELF_HASH
1021/// MY_PARENT_SINGLETON_STRUCT
1022/// proposal_yes_votes
1023/// proposal_total_votes
1024/// proposal_innerpuzhash
1025/// proposal_timelock
1026/// parent_parent
1027/// parent_amount
1028/// )
1029/// (include condition_codes.clib)
1030/// (include curry-and-treehash.clib)
1031/// (include *standard-cl-21*)
1032///
1033/// (defun calculate_singleton_puzzle_hash (PROPOSAL_SINGLETON_STRUCT inner_puzzle_hash)
1034/// (puzzle-hash-of-curried-function (f PROPOSAL_SINGLETON_STRUCT)
1035/// inner_puzzle_hash
1036/// (sha256tree PROPOSAL_SINGLETON_STRUCT)
1037/// )
1038/// )
1039///
1040/// (defun calculate_proposal_puzzlehash (
1041/// PROPOSAL_SINGLETON_STRUCT
1042/// PROPOSAL_SELF_HASH
1043/// proposal_yes_votes
1044/// proposal_total_votes
1045/// proposal_innerpuzhash
1046/// )
1047/// (calculate_singleton_puzzle_hash
1048/// PROPOSAL_SINGLETON_STRUCT
1049/// (puzzle-hash-of-curried-function PROPOSAL_SELF_HASH
1050/// (sha256 ONE proposal_total_votes)
1051/// (sha256 ONE proposal_yes_votes)
1052/// (sha256 ONE proposal_innerpuzhash)
1053/// (sha256 ONE (f (r PROPOSAL_SINGLETON_STRUCT)))
1054/// (sha256 ONE PROPOSAL_SELF_HASH)
1055/// )
1056/// )
1057/// )
1058///
1059/// ; main
1060/// (list
1061/// (list ASSERT_HEIGHT_RELATIVE proposal_timelock)
1062/// (list CREATE_PUZZLE_ANNOUNCEMENT (f (r MY_PARENT_SINGLETON_STRUCT)))
1063/// (list
1064/// ASSERT_PUZZLE_ANNOUNCEMENT
1065/// (sha256
1066/// (calculate_proposal_puzzlehash
1067/// MY_PARENT_SINGLETON_STRUCT
1068/// PROPOSAL_SELF_HASH
1069/// proposal_yes_votes
1070/// proposal_total_votes
1071/// proposal_innerpuzhash
1072/// )
1073/// proposal_timelock
1074/// )
1075/// )
1076/// (list
1077/// ASSERT_MY_PARENT_ID
1078/// (sha256
1079/// parent_parent
1080/// (calculate_proposal_puzzlehash
1081/// MY_PARENT_SINGLETON_STRUCT
1082/// PROPOSAL_SELF_HASH
1083/// 0
1084/// 0
1085/// proposal_innerpuzhash
1086/// )
1087/// parent_amount
1088/// )
1089///
1090/// )
1091/// )
1092/// )
1093/// ```
1094pub const DAO_PROPOSAL_TIMER: [u8; 825] = hex!("ff02ffff01ff04ffff04ffff0152ffff04ff8200bfffff01808080ffff04ffff04ffff013effff04ffff05ffff06ff0b8080ffff01808080ffff04ffff04ffff013fffff04ffff0bffff02ff1effff04ff02ffff04ff0bffff04ff05ffff04ff17ffff04ff2fffff04ff5fff8080808080808080ff8200bf80ffff01808080ffff04ffff04ffff0147ffff04ffff0bff82017fffff02ff1effff04ff02ffff04ff0bffff04ff05ffff04ffff0180ffff04ffff0180ffff04ff5fff8080808080808080ff8202ff80ffff01808080ffff018080808080ffff04ffff01ffffff02ffff03ff05ffff01ff02ffff01ff02ff08ffff04ff02ffff04ffff06ff0580ffff04ffff0bffff0102ffff0bffff0101ffff010480ffff0bffff0102ffff0bffff0102ffff0bffff0101ffff010180ffff05ff058080ffff0bffff0102ff0bffff0bffff0101ffff018080808080ff8080808080ff0180ffff01ff02ffff010bff018080ff0180ff0bffff0102ffff01a0a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222ffff0bffff0102ffff0bffff0102ffff01a09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ff0580ffff0bffff0102ffff02ff08ffff04ff02ffff04ff07ffff01ffa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b280808080ffff01a04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a808080ffff02ffff03ffff07ff0580ffff01ff02ffff01ff0bffff0102ffff02ff0affff04ff02ffff04ffff05ff0580ff80808080ffff02ff0affff04ff02ffff04ffff06ff0580ff8080808080ff0180ffff01ff02ffff01ff0bffff0101ff0580ff018080ff0180ffff02ff0cffff04ff02ffff04ff09ffff04ff0bffff04ffff02ff0affff04ff02ffff04ff05ff80808080ff808080808080ff02ff16ffff04ff02ffff04ff05ffff04ffff02ff0cffff04ff02ffff04ff0bffff04ffff0bffff0101ff2f80ffff04ffff0bffff0101ff1780ffff04ffff0bffff0101ff5f80ffff04ffff0bffff0101ff1580ffff04ffff0bffff0101ff0b80ff808080808080808080ff8080808080ff018080");
1095pub const DAO_PROPOSAL_TIMER_HASH: [u8; 32] =
1096 hex!("1acd912fca662d1474f7a6c762280fc1430875bef518883387086c1125027526");
1097
1098/// ```text
1099/// (mod
1100/// (
1101/// SINGLETON_STRUCT ; (SINGLETON_MOD_HASH (SINGLETON_ID . LAUNCHER_PUZZLE_HASH))
1102/// PROPOSAL_SELF_HASH
1103/// PROPOSAL_MINIMUM_AMOUNT
1104/// PROPOSAL_EXCESS_PAYOUT_PUZ_HASH ; this is where the excess money gets paid out to
1105/// Attendance_Required ; this is passed in as a Truth from above
1106/// Pass_Margin ; this is a pass in as a Truth from above
1107/// (announcement_source delegated_puzzle_hash announcement_args)
1108/// (
1109/// proposal_id
1110/// total_votes
1111/// yes_votes
1112/// coin_parent
1113/// coin_amount
1114/// )
1115/// conditions
1116/// )
1117///
1118/// (include condition_codes.clib)
1119/// (include curry-and-treehash.clib)
1120/// (include utility_macros.clib)
1121/// (include *standard-cl-21*)
1122///
1123/// (defconstant TEN_THOUSAND 10000)
1124///
1125/// (defun-inline calculate_win_percentage (TOTAL PERCENTAGE)
1126/// (f (divmod (* TOTAL PERCENTAGE) TEN_THOUSAND))
1127/// )
1128///
1129/// (defun-inline calculate_full_puzzle_hash (SINGLETON_STRUCT inner_puzzle_hash)
1130/// (puzzle-hash-of-curried-function (f SINGLETON_STRUCT)
1131/// inner_puzzle_hash
1132/// (sha256tree SINGLETON_STRUCT)
1133/// )
1134/// )
1135///
1136/// (defun-inline calculate_proposal_puzzle (
1137/// PROPOSAL_SELF_HASH
1138/// proposal_singleton_id
1139/// proposal_yes_votes
1140/// proposal_total_votes
1141/// proposal_innerpuz_hash
1142/// )
1143/// (puzzle-hash-of-curried-function PROPOSAL_SELF_HASH
1144/// (sha256 ONE proposal_total_votes)
1145/// (sha256 ONE proposal_yes_votes)
1146/// (sha256 ONE proposal_innerpuz_hash)
1147/// (sha256 ONE proposal_singleton_id)
1148/// (sha256 ONE PROPOSAL_SELF_HASH)
1149/// )
1150/// )
1151///
1152/// (assert
1153/// ; (= (sha256tree my_solution) announcement_args) - quex suggested this. We don't need to check it now. Can be used for future functionality.
1154/// (> (+ coin_amount ONE) PROPOSAL_MINIMUM_AMOUNT) ; >=
1155/// (gte total_votes Attendance_Required) ; TODO: we might want to change this to storing total cats and calculating like with yes votes
1156/// (gte yes_votes (calculate_win_percentage total_votes Pass_Margin))
1157/// (=
1158/// announcement_source
1159/// (calculate_coin_id
1160/// coin_parent
1161/// (calculate_full_puzzle_hash
1162/// (c (f SINGLETON_STRUCT) (c proposal_id (r (r SINGLETON_STRUCT))))
1163/// (calculate_proposal_puzzle
1164/// PROPOSAL_SELF_HASH
1165/// proposal_id
1166/// yes_votes ; this is where we validate the yes votes and total votes
1167/// total_votes
1168/// delegated_puzzle_hash
1169/// )
1170/// )
1171/// coin_amount
1172/// )
1173/// )
1174/// (c
1175/// (list CREATE_PUZZLE_ANNOUNCEMENT proposal_id) ; specify the proposal we're talking about
1176/// (if (> (- coin_amount 1) 0)
1177/// (c
1178/// (list CREATE_COIN PROPOSAL_EXCESS_PAYOUT_PUZ_HASH (- coin_amount 1) (list (f (r SINGLETON_STRUCT))))
1179/// conditions
1180/// )
1181/// conditions
1182/// )
1183/// )
1184/// )
1185/// )
1186/// ```
1187pub const DAO_PROPOSAL_VALIDATOR: [u8; 1170] = hex!("ff02ffff01ff02ffff03ffff15ffff10ff825effffff010180ff1780ffff01ff02ffff01ff02ffff03ffff02ff1effff04ff02ffff04ff820affffff04ff5fff8080808080ffff01ff02ffff01ff02ffff03ffff02ff1effff04ff02ffff04ff8216ffffff04ffff05ffff14ffff12ff820affff8200bf80ffff018227108080ff8080808080ffff01ff02ffff01ff02ffff03ffff09ff82027fffff02ff0affff04ff02ffff04ff822effffff04ffff02ff0cffff04ff02ffff04ffff05ffff04ffff05ff0580ffff04ff8204ffffff06ffff06ff058080808080ffff04ffff02ff0cffff04ff02ffff04ff0bffff04ffff0bffff0101ff820aff80ffff04ffff0bffff0101ff8216ff80ffff04ffff0bffff0101ff82057f80ffff04ffff0bffff0101ff8204ff80ffff04ffff0bffff0101ff0b80ff808080808080808080ffff04ffff02ff16ffff04ff02ffff04ffff04ffff05ff0580ffff04ff8204ffffff06ffff06ff0580808080ff80808080ff808080808080ffff04ff825effff80808080808080ffff01ff02ffff01ff04ffff04ffff013effff04ff8204ffffff01808080ffff02ffff03ffff15ffff11ff825effffff010180ffff018080ffff01ff02ffff01ff04ffff04ffff0133ffff04ff2fffff04ffff11ff825effffff010180ffff04ffff04ffff05ffff06ff058080ffff018080ffff018080808080ff8205ff80ff0180ffff01ff02ffff018205ffff018080ff018080ff0180ffff01ff02ffff01ff0880ff018080ff0180ff0180ffff01ff02ffff01ff0880ff018080ff0180ff0180ffff01ff02ffff01ff0880ff018080ff0180ff0180ffff01ff02ffff01ff0880ff018080ff0180ffff04ffff01ffffff02ffff03ff05ffff01ff02ffff01ff02ff08ffff04ff02ffff04ffff06ff0580ffff04ffff0bffff0102ffff0bffff0101ffff010480ffff0bffff0102ffff0bffff0102ffff0bffff0101ffff010180ffff05ff058080ffff0bffff0102ff0bffff0bffff0101ffff018080808080ff8080808080ff0180ffff01ff02ffff010bff018080ff0180ff0bffff0102ffff01a0a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222ffff0bffff0102ffff0bffff0102ffff01a09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ff0580ffff0bffff0102ffff02ff08ffff04ff02ffff04ff07ffff01ffa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b280808080ffff01a04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a808080ffff02ffff03ffff22ffff09ffff0dff0580ffff012080ffff09ffff0dff0b80ffff012080ffff15ff17ffff0181ff8080ffff01ff02ffff01ff0bff05ff0bff1780ff0180ffff01ff02ffff01ff0880ff018080ff0180ffff02ffff03ffff07ff0580ffff01ff02ffff01ff0bffff0102ffff02ff16ffff04ff02ffff04ffff05ff0580ff80808080ffff02ff16ffff04ff02ffff04ffff06ff0580ff8080808080ff0180ffff01ff02ffff01ff0bffff0101ff0580ff018080ff0180ff20ffff15ff0bff058080ff018080");
1188pub const DAO_PROPOSAL_VALIDATOR_HASH: [u8; 32] =
1189 hex!("92209b0f7efb2dbaaaa3aab94dcadcafa9d008d39661763841c7d92065b3fd34");
1190
1191/// ```text
1192/// (mod (
1193/// ; first hash
1194/// PROPOSAL_TIMER_MOD_HASH ; proposal timer needs to know which proposal created it
1195/// SINGLETON_MOD_HASH
1196/// LAUNCHER_PUZZLE_HASH
1197/// CAT_MOD_HASH
1198/// DAO_FINISHED_STATE_MOD_HASH
1199/// TREASURY_MOD_HASH
1200/// LOCKUP_SELF_HASH
1201/// CAT_TAIL_HASH
1202/// TREASURY_ID
1203/// ; second hash
1204/// SELF_HASH
1205/// SINGLETON_ID
1206/// PROPOSED_PUZ_HASH ; this is what runs if this proposal is successful - the inner puzzle of this proposal
1207/// YES_VOTES ; yes votes are +1, no votes don't tally - we compare yes_votes/total_votes at the end
1208/// TOTAL_VOTES ; how many people responded
1209/// ; solution
1210/// vote_amounts_or_proposal_validator_hash ; The qty of "votes" to add or subtract. ALWAYS POSITIVE.
1211/// vote_info ; vote_info is whether we are voting YES or NO. XXX rename vote_type?
1212/// vote_coin_ids_or_proposal_timelock_length ; this is either the coin ID we're taking a vote from
1213/// previous_votes_or_pass_margin ; this is the active votes of the lockup we're communicating with
1214/// ; OR this is what percentage of the total votes must be YES - represented as an integer from 0 to 10,000 - typically this is set at 5100 (51%)
1215/// lockup_innerpuzhashes_or_attendance_required ; this is either the innerpuz of the locked up CAT we're taking a vote from OR
1216/// ; the attendance required - the percentage of the current issuance which must have voted represented as 0 to 10,000 - this is announced by the treasury
1217/// innerpuz_reveal ; this is only added during the first vote
1218/// soft_close_length ; revealed by the treasury - 0 in add vote case
1219/// self_destruct_time ; revealed by the treasury
1220/// oracle_spend_delay ; used to recreate the treasury
1221/// self_destruct_flag ; if not 0, do the self-destruct spend
1222/// my_amount
1223/// )
1224/// (include condition_codes.clib)
1225/// (include utility_macros.clib)
1226/// (include curry-and-treehash.clib)
1227/// (include *standard-cl-21*)
1228///
1229/// (defconstant TEN_THOUSAND 10000)
1230///
1231/// (defun is_member (e L)
1232/// (if L
1233/// (if (= e (f L))
1234/// 1
1235/// (is_member e (r L))
1236/// )
1237/// 0
1238/// )
1239/// )
1240///
1241/// (defun-inline calculate_win_percentage (TOTAL PERCENTAGE)
1242/// (f (divmod (* TOTAL PERCENTAGE) TEN_THOUSAND))
1243/// )
1244///
1245/// (defun calculate_finished_state (singleton_struct DAO_FINISHED_STATE_MOD_HASH)
1246/// (puzzle-hash-of-curried-function DAO_FINISHED_STATE_MOD_HASH
1247/// (sha256 ONE DAO_FINISHED_STATE_MOD_HASH)
1248/// (sha256tree singleton_struct)
1249/// )
1250/// )
1251///
1252/// (defun calculate_timer_puzhash (
1253/// PROPOSAL_TIMER_MOD_HASH
1254/// SELF_HASH
1255/// MY_SINGLETON_STRUCT
1256/// )
1257/// (puzzle-hash-of-curried-function PROPOSAL_TIMER_MOD_HASH
1258/// (sha256tree MY_SINGLETON_STRUCT)
1259/// (sha256 ONE SELF_HASH)
1260/// )
1261/// )
1262///
1263/// (defun calculate_lockup_puzzlehash (
1264/// LOCKUP_SELF_HASH
1265/// previous_votes
1266/// lockup_innerpuzhash
1267/// )
1268/// (puzzle-hash-of-curried-function LOCKUP_SELF_HASH
1269/// lockup_innerpuzhash
1270/// (sha256tree previous_votes)
1271/// (sha256 ONE LOCKUP_SELF_HASH)
1272/// )
1273/// )
1274///
1275/// (defun recreate_self (
1276/// SELF_HASH
1277/// PROPOSAL_ID
1278/// PROPOSED_PUZ_HASH
1279/// YES_VOTES
1280/// TOTAL_VOTES
1281/// )
1282/// (puzzle-hash-of-curried-function SELF_HASH
1283/// (sha256 ONE TOTAL_VOTES)
1284/// (sha256 ONE YES_VOTES)
1285/// (sha256 ONE PROPOSED_PUZ_HASH)
1286/// (sha256 ONE PROPOSAL_ID)
1287/// (sha256 ONE SELF_HASH)
1288/// )
1289/// )
1290///
1291/// (defun wrap_in_cat_layer (CAT_MOD_HASH CAT_TAIL_HASH INNERPUZHASH)
1292/// (puzzle-hash-of-curried-function CAT_MOD_HASH
1293/// INNERPUZHASH
1294/// (sha256 ONE CAT_TAIL_HASH)
1295/// (sha256 ONE CAT_MOD_HASH)
1296/// )
1297/// )
1298///
1299/// (defun calculate_singleton_puzzle_hash (PROPOSAL_SINGLETON_STRUCT inner_puzzle_hash)
1300/// (puzzle-hash-of-curried-function (f PROPOSAL_SINGLETON_STRUCT)
1301/// inner_puzzle_hash
1302/// (sha256tree PROPOSAL_SINGLETON_STRUCT)
1303/// )
1304/// )
1305///
1306/// (defun calculate_treasury_puzzlehash (
1307/// treasury_singleton_struct
1308/// TREASURY_MOD_HASH
1309/// PROPOSAL_VALIDATOR_HASH
1310/// PROPOSAL_LENGTH
1311/// PROPOSAL_SOFTCLOSE_LENGTH
1312/// attendance_required
1313/// pass_percentage
1314/// self_destruct_time
1315/// oracle_spend_delay
1316/// )
1317///
1318/// (calculate_singleton_puzzle_hash treasury_singleton_struct
1319/// (puzzle-hash-of-curried-function TREASURY_MOD_HASH
1320/// (sha256 ONE oracle_spend_delay)
1321/// (sha256 ONE self_destruct_time)
1322/// (sha256 ONE pass_percentage)
1323/// (sha256 ONE attendance_required)
1324/// (sha256 ONE PROPOSAL_SOFTCLOSE_LENGTH)
1325/// (sha256 ONE PROPOSAL_LENGTH)
1326/// PROPOSAL_VALIDATOR_HASH
1327/// (sha256 ONE TREASURY_MOD_HASH)
1328/// )
1329/// )
1330/// )
1331///
1332/// (defun loop_over_vote_coins (
1333/// SINGLETON_ID
1334/// LOCKUP_SELF_HASH
1335/// CAT_MOD_HASH
1336/// CAT_TAIL_HASH
1337/// TREASURY_ID
1338/// SELF_HASH
1339/// YES_VOTES
1340/// TOTAL_VOTES
1341/// PROPOSED_PUZ_HASH
1342/// coin_id_list
1343/// vote_amount_list
1344/// previous_votes
1345/// lockup_innerpuzhashes
1346/// vote_info
1347/// sum
1348/// output
1349/// my_amount
1350/// distinct_ids
1351/// )
1352/// (if coin_id_list
1353/// (if (> (f vote_amount_list) 0)
1354/// (c
1355/// (list CREATE_PUZZLE_ANNOUNCEMENT (f coin_id_list))
1356/// (c
1357/// (list
1358/// ASSERT_PUZZLE_ANNOUNCEMENT ; take the vote
1359/// (sha256
1360/// (wrap_in_cat_layer
1361/// CAT_MOD_HASH
1362/// CAT_TAIL_HASH
1363/// (calculate_lockup_puzzlehash ; because the message comes from
1364/// LOCKUP_SELF_HASH
1365/// (f previous_votes)
1366/// (f lockup_innerpuzhashes)
1367/// )
1368/// )
1369/// (sha256tree (list SINGLETON_ID (f vote_amount_list) vote_info (f coin_id_list)))
1370/// )
1371/// )
1372/// (loop_over_vote_coins
1373/// SINGLETON_ID
1374/// LOCKUP_SELF_HASH
1375/// CAT_MOD_HASH
1376/// CAT_TAIL_HASH
1377/// TREASURY_ID
1378/// SELF_HASH
1379/// YES_VOTES
1380/// TOTAL_VOTES
1381/// PROPOSED_PUZ_HASH
1382/// (r coin_id_list)
1383/// (r vote_amount_list)
1384/// (r previous_votes)
1385/// (r lockup_innerpuzhashes)
1386/// vote_info
1387/// (+ (f vote_amount_list) sum)
1388/// output
1389/// my_amount
1390/// (if (is_member (f coin_id_list) distinct_ids) (x) (c (f coin_id_list) distinct_ids))
1391/// )
1392/// )
1393/// )
1394/// (x)
1395/// )
1396/// (c
1397/// (list
1398/// CREATE_COIN ; recreate self with vote information added
1399/// (recreate_self
1400/// SELF_HASH
1401/// SINGLETON_ID
1402/// PROPOSED_PUZ_HASH
1403/// (if vote_info (+ YES_VOTES sum) YES_VOTES)
1404/// (+ TOTAL_VOTES sum)
1405/// )
1406/// my_amount
1407/// (list TREASURY_ID) ; hint to Treasury ID so people can find it
1408/// )
1409/// (c
1410/// (list ASSERT_MY_AMOUNT my_amount)
1411/// (if TOTAL_VOTES
1412/// (c (list ASSERT_HEIGHT_RELATIVE 1) output)
1413/// output
1414/// )
1415/// )
1416/// )
1417/// )
1418///
1419/// )
1420///
1421///
1422/// (if self_destruct_flag
1423/// ; assert self_destruct_time > proposal_timelock_length
1424/// ; this is the code path for if we've not been accepted by the treasury for a long time, and we're "bad" for some reason
1425/// (if (> self_destruct_time vote_coin_ids_or_proposal_timelock_length)
1426/// (list
1427/// (list CREATE_COIN (calculate_finished_state (c SINGLETON_MOD_HASH (c SINGLETON_ID LAUNCHER_PUZZLE_HASH)) DAO_FINISHED_STATE_MOD_HASH) ONE (list TREASURY_ID))
1428/// (list ASSERT_HEIGHT_RELATIVE self_destruct_time)
1429/// (list ASSERT_PUZZLE_ANNOUNCEMENT ; make sure that we have a matching treasury oracle spend
1430/// (sha256
1431/// (calculate_treasury_puzzlehash
1432/// (c SINGLETON_MOD_HASH (c TREASURY_ID LAUNCHER_PUZZLE_HASH))
1433/// TREASURY_MOD_HASH
1434/// vote_amounts_or_proposal_validator_hash
1435/// vote_coin_ids_or_proposal_timelock_length ; check the veracity of these values by if the treasury uses them
1436/// soft_close_length
1437/// lockup_innerpuzhashes_or_attendance_required
1438/// previous_votes_or_pass_margin
1439/// self_destruct_time
1440/// oracle_spend_delay
1441/// )
1442/// 0 ; the arguments are secured implicitly in the puzzle of the treasury
1443/// )
1444/// )
1445/// )
1446/// (x)
1447/// )
1448/// ; We're not trying to self destruct
1449/// ; Check whether we have a soft close to either try closing the proposal or adding votes
1450/// ; soft_close_length is used to prevent people from spamming the proposal and preventing others from being able to vote.
1451/// ; Someone could add 1 'no' vote to the proposal in every block until the proposal timelock has passed and then close the proposal as failed.
1452/// ; soft_close_length imposes some fixed number of blocks have passed without the proposal being spent before it can be closed.
1453/// ; This means there will always be some time for people to vote if they want before a proposal is closed.
1454/// (if soft_close_length
1455/// ; Add the conditions which apply in both passed and failed cases
1456/// (c
1457/// (list ASSERT_HEIGHT_RELATIVE soft_close_length)
1458/// (c
1459/// (list CREATE_COIN (calculate_finished_state (c SINGLETON_MOD_HASH (c SINGLETON_ID LAUNCHER_PUZZLE_HASH)) DAO_FINISHED_STATE_MOD_HASH) ONE (list TREASURY_ID))
1460/// (c
1461/// (list
1462/// ASSERT_PUZZLE_ANNOUNCEMENT
1463/// (sha256 ; external timer
1464/// (calculate_timer_puzhash
1465/// PROPOSAL_TIMER_MOD_HASH
1466/// SELF_HASH
1467/// (c SINGLETON_MOD_HASH (c SINGLETON_ID LAUNCHER_PUZZLE_HASH))
1468///
1469/// )
1470/// SINGLETON_ID
1471/// )
1472/// )
1473/// (c
1474/// (list CREATE_PUZZLE_ANNOUNCEMENT vote_coin_ids_or_proposal_timelock_length)
1475/// ; We are trying to close the proposal, so check whether it passed or failed
1476/// (if
1477/// (all
1478/// (gte TOTAL_VOTES lockup_innerpuzhashes_or_attendance_required)
1479/// (gte YES_VOTES (calculate_win_percentage TOTAL_VOTES previous_votes_or_pass_margin))
1480/// )
1481/// ; Passed
1482/// (list
1483/// (list CREATE_COIN_ANNOUNCEMENT (sha256tree (list PROPOSED_PUZ_HASH 0))) ; the 0 at the end is announcement_args in proposal_validators
1484/// ; the above coin annnouncement lets us validate this coin in the proposal validator
1485/// (list ASSERT_PUZZLE_ANNOUNCEMENT ; make sure that we actually have a matching treasury spend
1486/// (sha256
1487/// (calculate_treasury_puzzlehash
1488/// (c SINGLETON_MOD_HASH (c TREASURY_ID LAUNCHER_PUZZLE_HASH))
1489/// TREASURY_MOD_HASH
1490/// vote_amounts_or_proposal_validator_hash
1491/// vote_coin_ids_or_proposal_timelock_length ; check the veracity of these values by if the treasury uses them
1492/// soft_close_length
1493/// lockup_innerpuzhashes_or_attendance_required
1494/// previous_votes_or_pass_margin
1495/// self_destruct_time
1496/// oracle_spend_delay
1497/// )
1498/// SINGLETON_ID ; directed at singleton, but most values are implicitly announced in the puzzle
1499/// )
1500/// )
1501/// )
1502/// ; Failed
1503/// (list
1504/// (list ASSERT_PUZZLE_ANNOUNCEMENT ; make sure that we verify solution values against the treasury's oracle spend
1505/// (sha256
1506/// (calculate_treasury_puzzlehash
1507/// (c SINGLETON_MOD_HASH (c TREASURY_ID LAUNCHER_PUZZLE_HASH))
1508/// TREASURY_MOD_HASH
1509/// vote_amounts_or_proposal_validator_hash
1510/// vote_coin_ids_or_proposal_timelock_length ; check the veracity of these values by if the treasury uses them
1511/// soft_close_length
1512/// lockup_innerpuzhashes_or_attendance_required
1513/// previous_votes_or_pass_margin
1514/// self_destruct_time
1515/// oracle_spend_delay
1516/// )
1517/// 0 ; the arguments are secured implicitly in the puzzle of the treasury
1518/// )
1519/// )
1520/// )
1521/// )
1522/// )
1523/// )
1524/// )
1525/// )
1526///
1527///
1528/// ; no soft_close_length so run the add votes path
1529/// (loop_over_vote_coins
1530/// SINGLETON_ID
1531/// LOCKUP_SELF_HASH
1532/// CAT_MOD_HASH
1533/// CAT_TAIL_HASH
1534/// TREASURY_ID
1535/// SELF_HASH
1536/// YES_VOTES
1537/// TOTAL_VOTES
1538/// PROPOSED_PUZ_HASH
1539/// vote_coin_ids_or_proposal_timelock_length
1540/// vote_amounts_or_proposal_validator_hash
1541/// previous_votes_or_pass_margin
1542/// lockup_innerpuzhashes_or_attendance_required
1543/// vote_info
1544/// 0
1545/// (if (any YES_VOTES TOTAL_VOTES) ; this prevents the timer from being created if the coin has been created with fake votes
1546/// ()
1547/// (c
1548/// (list
1549/// CREATE_COIN
1550/// (calculate_timer_puzhash
1551/// PROPOSAL_TIMER_MOD_HASH
1552/// SELF_HASH
1553/// (c SINGLETON_MOD_HASH (c SINGLETON_ID LAUNCHER_PUZZLE_HASH)) ; SINGLETON_STRUCT
1554/// )
1555/// 0
1556/// )
1557/// (if (= (sha256tree innerpuz_reveal) PROPOSED_PUZ_HASH) ; reveal the proposed code on chain with the first vote
1558/// ()
1559/// (x)
1560/// )
1561/// )
1562/// )
1563/// my_amount
1564/// ()
1565/// )
1566/// )
1567/// )
1568/// )
1569/// ```
1570pub const DAO_PROPOSAL: [u8; 3270] = hex!("ff02ffff01ff02ffff03ff8402ffffffffff01ff02ffff01ff02ffff03ffff15ff8400bfffffff8305ffff80ffff01ff02ffff01ff04ffff04ffff0133ffff04ffff02ff3cffff04ff02ffff04ffff04ff0bffff04ff8217ffff178080ffff04ff5fff8080808080ffff04ffff0101ffff04ffff04ff8205ffffff018080ffff018080808080ffff04ffff04ffff0152ffff04ff8400bfffffffff01808080ffff04ffff04ffff013fffff04ffff0bffff02ff2effff04ff02ffff04ffff04ff0bffff04ff8205ffff178080ffff04ff8200bfffff04ff83017fffffff04ff8305ffffffff04ff835fffffffff04ff8317ffffffff04ff830bffffffff04ff8400bfffffffff04ff84017fffffff808080808080808080808080ffff018080ffff01808080ffff0180808080ff0180ffff01ff02ffff01ff0880ff018080ff0180ff0180ffff01ff02ffff01ff02ffff03ff835fffffffff01ff02ffff01ff04ffff04ffff0152ffff04ff835fffffffff01808080ffff04ffff04ffff0133ffff04ffff02ff3cffff04ff02ffff04ffff04ff0bffff04ff8217ffff178080ffff04ff5fff8080808080ffff04ffff0101ffff04ffff04ff8205ffffff018080ffff018080808080ffff04ffff04ffff013fffff04ffff0bffff02ff12ffff04ff02ffff04ff05ffff04ff820bffffff04ffff04ff0bffff04ff8217ffff178080ff808080808080ff8217ff80ffff01808080ffff04ffff04ffff013effff04ff8305ffffffff01808080ffff02ffff03ffff22ffff02ff10ffff04ff02ffff04ff8300bfffffff04ff8317ffffff8080808080ffff02ff10ffff04ff02ffff04ff825fffffff04ffff05ffff14ffff12ff8300bfffff830bffff80ffff018227108080ff808080808080ffff01ff02ffff01ff04ffff04ffff013cffff04ffff02ff14ffff04ff02ffff04ffff04ff822fffffff04ffff0180ffff01808080ff80808080ffff01808080ffff04ffff04ffff013fffff04ffff0bffff02ff2effff04ff02ffff04ffff04ff0bffff04ff8205ffff178080ffff04ff8200bfffff04ff83017fffffff04ff8305ffffffff04ff835fffffffff04ff8317ffffffff04ff830bffffffff04ff8400bfffffffff04ff84017fffffff808080808080808080808080ff8217ff80ffff01808080ffff01808080ff0180ffff01ff02ffff01ff04ffff04ffff013fffff04ffff0bffff02ff2effff04ff02ffff04ffff04ff0bffff04ff8205ffff178080ffff04ff8200bfffff04ff83017fffffff04ff8305ffffffff04ff835fffffffff04ff8317ffffffff04ff830bffffffff04ff8400bfffffffff04ff84017fffffff808080808080808080808080ffff018080ffff01808080ffff018080ff018080ff018080808080ff0180ffff01ff02ffff01ff02ff3effff04ff02ffff04ff8217ffffff04ff82017fffff04ff2fffff04ff8202ffffff04ff8205ffffff04ff820bffffff04ff825fffffff04ff8300bfffffff04ff822fffffff04ff8305ffffffff04ff83017fffffff04ff830bffffffff04ff8317ffffffff04ff8302ffffffff04ffff0180ffff04ffff02ffff03ffff21ff825fffff8300bfff80ffff01ff02ffff01ff0180ff0180ffff01ff02ffff01ff04ffff04ffff0133ffff04ffff02ff12ffff04ff02ffff04ff05ffff04ff820bffffff04ffff04ff0bffff04ff8217ffff178080ff808080808080ffff04ffff0180ffff0180808080ffff02ffff03ffff09ffff02ff14ffff04ff02ffff04ff832fffffff80808080ff822fff80ffff01ff02ffff01ff0180ff0180ffff01ff02ffff01ff0880ff018080ff018080ff018080ff0180ffff04ff8405ffffffffff04ffff0180ff808080808080808080808080808080808080808080ff018080ff0180ff018080ff0180ffff04ffff01ffffffff20ffff15ff0bff058080ffff02ffff03ff05ffff01ff02ffff01ff02ff28ffff04ff02ffff04ffff06ff0580ffff04ffff0bffff0102ffff0bffff0101ffff010480ffff0bffff0102ffff0bffff0102ffff0bffff0101ffff010180ffff05ff058080ffff0bffff0102ff0bffff0bffff0101ffff018080808080ff8080808080ff0180ffff01ff02ffff010bff018080ff0180ff0bffff0102ffff01a0a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222ffff0bffff0102ffff0bffff0102ffff01a09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ff0580ffff0bffff0102ffff02ff28ffff04ff02ffff04ff07ffff01ffa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b280808080ffff01a04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a808080ffff02ffff03ffff07ff0580ffff01ff02ffff01ff0bffff0102ffff02ff14ffff04ff02ffff04ffff05ff0580ff80808080ffff02ff14ffff04ff02ffff04ffff06ff0580ff8080808080ff0180ffff01ff02ffff01ff0bffff0101ff0580ff018080ff0180ffff02ffff03ff0bffff01ff02ffff01ff02ffff03ffff09ff05ffff05ff0b8080ffff01ff02ffff01ff0101ff0180ffff01ff02ffff01ff02ff2cffff04ff02ffff04ff05ffff04ffff06ff0b80ff8080808080ff018080ff0180ff0180ffff01ff02ffff01ff0180ff018080ff0180ff02ff38ffff04ff02ffff04ff0bffff04ffff0bffff0101ff0b80ffff04ffff02ff14ffff04ff02ffff04ff05ff80808080ff808080808080ffffff02ff38ffff04ff02ffff04ff05ffff04ffff02ff14ffff04ff02ffff04ff17ff80808080ffff04ffff0bffff0101ff0b80ff808080808080ffff02ff38ffff04ff02ffff04ff05ffff04ff17ffff04ffff02ff14ffff04ff02ffff04ff0bff80808080ffff04ffff0bffff0101ff0580ff80808080808080ff02ff38ffff04ff02ffff04ff05ffff04ffff0bffff0101ff5f80ffff04ffff0bffff0101ff2f80ffff04ffff0bffff0101ff1780ffff04ffff0bffff0101ff0b80ffff04ffff0bffff0101ff0580ff808080808080808080ffffff02ff38ffff04ff02ffff04ff05ffff04ff17ffff04ffff0bffff0101ff0b80ffff04ffff0bffff0101ff0580ff80808080808080ff02ff38ffff04ff02ffff04ff09ffff04ff0bffff04ffff02ff14ffff04ff02ffff04ff05ff80808080ff808080808080ffff02ff36ffff04ff02ffff04ff05ffff04ffff02ff38ffff04ff02ffff04ff0bffff04ffff0bffff0101ff8205ff80ffff04ffff0bffff0101ff8202ff80ffff04ffff0bffff0101ff82017f80ffff04ffff0bffff0101ff8200bf80ffff04ffff0bffff0101ff5f80ffff04ffff0bffff0101ff2f80ffff04ff17ffff04ffff0bffff0101ff0b80ff808080808080808080808080ff8080808080ff02ffff03ff820bffffff01ff02ffff01ff02ffff03ffff15ffff05ff8217ff80ffff018080ffff01ff02ffff01ff04ffff04ffff013effff04ffff05ff820bff80ffff01808080ffff04ffff04ffff013fffff04ffff0bffff02ff26ffff04ff02ffff04ff17ffff04ff2fffff04ffff02ff2affff04ff02ffff04ff0bffff04ffff05ff822fff80ffff04ffff05ff825fff80ff808080808080ff808080808080ffff02ff14ffff04ff02ffff04ffff04ff05ffff04ffff05ff8217ff80ffff04ff8300bfffffff04ffff05ff820bff80ffff018080808080ff8080808080ffff01808080ffff02ff3effff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ff8200bfffff04ff82017fffff04ff8202ffffff04ff8205ffffff04ffff06ff820bff80ffff04ffff06ff8217ff80ffff04ffff06ff822fff80ffff04ffff06ff825fff80ffff04ff8300bfffffff04ffff10ffff05ff8217ff80ff83017fff80ffff04ff8302ffffffff04ff8305ffffffff04ffff02ffff03ffff02ff2cffff04ff02ffff04ffff05ff820bff80ffff04ff830bffffff8080808080ffff01ff02ffff01ff0880ff0180ffff01ff02ffff01ff04ffff05ff820bff80ff830bffff80ff018080ff0180ff8080808080808080808080808080808080808080808080ff0180ffff01ff02ffff01ff0880ff018080ff0180ff0180ffff01ff02ffff01ff04ffff04ffff0133ffff04ffff02ff3affff04ff02ffff04ff8200bfffff04ff05ffff04ff8205ffffff04ffff02ffff03ff8300bfffffff01ff02ffff01ff10ff82017fff83017fff80ff0180ffff01ff02ffff0182017fff018080ff0180ffff04ffff10ff8202ffff83017fff80ff8080808080808080ffff04ff8305ffffffff04ffff04ff5fffff018080ffff018080808080ffff04ffff04ffff0149ffff04ff8305ffffffff01808080ffff02ffff03ff8202ffffff01ff02ffff01ff04ffff04ffff0152ffff04ffff0101ffff01808080ff8302ffff80ff0180ffff01ff02ffff018302ffffff018080ff01808080ff018080ff0180ff018080");
1571pub const DAO_PROPOSAL_HASH: [u8; 32] =
1572 hex!("fe6d5c0373c1750598d137ce50b5b025a203655ccab4ab3329315abad49c3586");
1573
1574/// ```text
1575/// (mod (
1576/// TREASURY_SINGLETON_STRUCT
1577/// CAT_MOD_HASH
1578/// CONDITIONS ; XCK conditions, to be generated by the treasury
1579/// LIST_OF_TAILHASH_CONDITIONS ; the delegated puzzlehash must be curried in to the proposal.
1580/// ; Puzzlehash is only run in the last coin for that asset
1581/// ; ((TAIL_HASH CONDITIONS) (TAIL_HASH CONDITIONS)... )
1582/// P2_SINGLETON_VIA_DELEGATED_PUZZLE_PUZHASH
1583/// p2_singleton_parent_amount_list ; for xck this is just a list of (coin_parent coin_amount)
1584/// p2_singleton_tailhash_parent_amount_list ; list of ((asset (parent amount) (parent amount)... ) (asset (parent amount)... )... ),
1585/// ; must match order of curryed asset list
1586/// ; the last (parent amount) gets given the puzzlehash, the rest get given 0
1587/// treasury_inner_puzhash
1588/// )
1589/// ; we need to track CAT_TYPE and DELEGATED_PUZZLE
1590/// ; list of (asset_type (parent amount))
1591///
1592/// ; If you're writing a proposal you'll want to use this layer
1593/// ; if you don't, your proposal might be invalidated if the p2_singleton coins get spent
1594///
1595/// (include condition_codes.clib)
1596/// (include curry-and-treehash.clib)
1597/// (include utility_macros.clib)
1598/// (include *standard-cl-21*)
1599///
1600/// (defun-inline calculate_singleton_puzzle_hash (PROPOSAL_SINGLETON_STRUCT inner_puzzle_hash)
1601/// (puzzle-hash-of-curried-function (f PROPOSAL_SINGLETON_STRUCT)
1602/// inner_puzzle_hash
1603/// (sha256tree PROPOSAL_SINGLETON_STRUCT)
1604/// )
1605/// )
1606///
1607/// (defun loop_through_list (
1608/// TREASURY_SINGLETON_STRUCT
1609/// SPEND_AMOUNT
1610/// P2_SINGLETON_PUZHASH
1611/// p2_calculated
1612/// p2_singleton_list
1613/// total
1614/// output
1615/// )
1616/// (c
1617/// (list CREATE_PUZZLE_ANNOUNCEMENT (sha256tree (list p2_calculated (sha256tree 0))))
1618/// (c
1619/// (list ASSERT_COIN_ANNOUNCEMENT (sha256 p2_calculated '$'))
1620/// (if p2_singleton_list
1621/// (loop_through_list
1622/// TREASURY_SINGLETON_STRUCT
1623/// SPEND_AMOUNT
1624/// P2_SINGLETON_PUZHASH
1625/// (calculate_coin_id (f (f p2_singleton_list)) P2_SINGLETON_PUZHASH (f (r (f p2_singleton_list))))
1626/// (r p2_singleton_list)
1627/// (+ total (f (r (f p2_singleton_list))))
1628/// output
1629/// )
1630/// (if (> (- total SPEND_AMOUNT) 0)
1631/// (c
1632/// (list CREATE_COIN P2_SINGLETON_PUZHASH (- total SPEND_AMOUNT) (list P2_SINGLETON_PUZHASH))
1633/// output
1634/// )
1635/// output
1636/// )
1637/// )
1638/// )
1639/// )
1640/// )
1641///
1642/// (defun add_announcements_to_result (p2_calculated delegated_puzhash output)
1643/// (c
1644/// (list CREATE_PUZZLE_ANNOUNCEMENT (sha256tree (list p2_calculated delegated_puzhash)))
1645/// (c
1646/// (list ASSERT_COIN_ANNOUNCEMENT (sha256 p2_calculated '$'))
1647/// output
1648/// )
1649/// )
1650/// )
1651///
1652/// (defun sum_create_coins (conditions)
1653/// (if conditions
1654/// (+
1655/// (if
1656/// (= (f (f conditions)) CREATE_COIN)
1657/// (if
1658/// (> (f (r (r (f conditions)))) 0) ; make an exception for -113 and other magic conditions
1659/// (f (r (r (f conditions))))
1660/// 0
1661/// )
1662/// 0
1663/// )
1664/// (sum_create_coins (r conditions))
1665/// )
1666/// 0
1667/// )
1668/// )
1669///
1670/// (defun-inline calculate_delegated_puzzlehash (CONDITIONS)
1671/// (sha256tree (c ONE CONDITIONS)) ; this makes (q . CONDITIONS)
1672/// )
1673///
1674/// (defun wrap_in_cat_layer (CAT_MOD_HASH CAT_TAIL_HASH INNERPUZHASH)
1675/// (puzzle-hash-of-curried-function CAT_MOD_HASH
1676/// INNERPUZHASH
1677/// (sha256 ONE CAT_TAIL_HASH)
1678/// (sha256 ONE CAT_MOD_HASH)
1679/// )
1680/// )
1681///
1682/// (defun dedupe ((@ lst ((@ first (parent amount)) . rest)) ids)
1683/// (if lst
1684/// (let ((id (sha256 parent amount)))
1685/// (if (in id ids)
1686/// (dedupe rest ids)
1687/// (c first (dedupe rest (c id ids)))
1688/// )
1689/// )
1690/// ()
1691/// )
1692/// )
1693///
1694///
1695/// ; for a given asset type, loop through the cat coins and generate the announcements required for each
1696/// (defun for_each_asset (
1697/// TREASURY_SINGLETON_STRUCT
1698/// CAT_MOD_HASH
1699/// CONDITIONS_FOR_THIS_ASSET_TYPE
1700/// P2_SINGLETON_PUZHASH
1701/// p2_singleton_puzzle_hash
1702/// parent_amount_list
1703/// total
1704/// create_coin_sum
1705/// output
1706/// )
1707/// (if parent_amount_list
1708/// (add_announcements_to_result
1709/// (calculate_coin_id (f (f parent_amount_list)) p2_singleton_puzzle_hash (f (r (f parent_amount_list))))
1710/// (if
1711/// (r parent_amount_list) ; this is the delegated_puzhash
1712/// (sha256tree 0) ; most coins destroy themselves
1713/// (calculate_delegated_puzzlehash ; the last coin creates the conditions
1714/// (let ((coin_sum (- (+ total (f (r (f parent_amount_list)))) create_coin_sum)))
1715/// (if (> coin_sum 0)
1716/// (c
1717/// (list CREATE_COIN P2_SINGLETON_PUZHASH coin_sum (list P2_SINGLETON_PUZHASH))
1718/// CONDITIONS_FOR_THIS_ASSET_TYPE
1719/// )
1720/// CONDITIONS_FOR_THIS_ASSET_TYPE
1721/// ))
1722/// )
1723/// )
1724/// (for_each_asset
1725/// TREASURY_SINGLETON_STRUCT
1726/// CAT_MOD_HASH
1727/// CONDITIONS_FOR_THIS_ASSET_TYPE
1728/// P2_SINGLETON_PUZHASH
1729/// p2_singleton_puzzle_hash
1730/// (r parent_amount_list)
1731/// (+ total (f (r (f parent_amount_list))))
1732/// create_coin_sum
1733/// output
1734/// )
1735/// )
1736/// output
1737/// )
1738/// )
1739///
1740/// ; loops through the list of ((tailhash conditions))
1741/// (defun for_each_asset_type (
1742/// TREASURY_SINGLETON_STRUCT
1743/// CAT_MOD_HASH
1744/// P2_SINGLETON_PUZHASH
1745/// LIST_OF_TAILHASH_CONDITIONS
1746/// p2_singleton_tailhash_parent_amount_list ; ((tailhash ((parent amount) (parent_amount)... ) (tailhash (parent amount))..)
1747/// output
1748/// )
1749/// (if LIST_OF_TAILHASH_CONDITIONS
1750/// (for_each_asset_type
1751/// TREASURY_SINGLETON_STRUCT
1752/// CAT_MOD_HASH
1753/// P2_SINGLETON_PUZHASH
1754/// (r LIST_OF_TAILHASH_CONDITIONS)
1755/// (r p2_singleton_tailhash_parent_amount_list)
1756/// (for_each_asset
1757/// TREASURY_SINGLETON_STRUCT
1758/// CAT_MOD_HASH
1759/// (if
1760/// (=
1761/// (f (f LIST_OF_TAILHASH_CONDITIONS))
1762/// (f (f p2_singleton_tailhash_parent_amount_list))
1763/// )
1764/// (f (r (f LIST_OF_TAILHASH_CONDITIONS)))
1765/// (x) ; bad solution format
1766/// )
1767/// P2_SINGLETON_PUZHASH
1768/// (wrap_in_cat_layer CAT_MOD_HASH (f (f p2_singleton_tailhash_parent_amount_list)) P2_SINGLETON_PUZHASH) ; p2_singleton_puzzle_hash
1769/// (dedupe (f (r (f p2_singleton_tailhash_parent_amount_list))) 0 0) ; list of ((parent amount) (parent amount)...)
1770/// 0 ; current total - initialise as 0
1771/// (sum_create_coins (f (r (f LIST_OF_TAILHASH_CONDITIONS))))
1772/// output ; add new conditions to previous calculated output conditions
1773/// )
1774/// )
1775/// output ; at the end of the loop output our calculated conditions
1776/// )
1777/// )
1778///
1779///
1780/// ; main
1781/// (c
1782/// (list ASSERT_MY_PUZZLEHASH (calculate_singleton_puzzle_hash TREASURY_SINGLETON_STRUCT treasury_inner_puzhash))
1783/// (c
1784/// (list CREATE_COIN treasury_inner_puzhash ONE (list (f (r TREASURY_SINGLETON_STRUCT))))
1785/// (if CONDITIONS
1786/// (loop_through_list
1787/// TREASURY_SINGLETON_STRUCT
1788/// (sum_create_coins CONDITIONS)
1789/// P2_SINGLETON_VIA_DELEGATED_PUZZLE_PUZHASH
1790/// (if p2_singleton_parent_amount_list (calculate_coin_id (f (f p2_singleton_parent_amount_list)) P2_SINGLETON_VIA_DELEGATED_PUZZLE_PUZHASH (f (r (f p2_singleton_parent_amount_list)))) ())
1791/// (if p2_singleton_parent_amount_list (r p2_singleton_parent_amount_list) ())
1792/// (if p2_singleton_parent_amount_list (f (r (f p2_singleton_parent_amount_list))) ())
1793/// (for_each_asset_type
1794/// TREASURY_SINGLETON_STRUCT
1795/// CAT_MOD_HASH
1796/// P2_SINGLETON_VIA_DELEGATED_PUZZLE_PUZHASH
1797/// LIST_OF_TAILHASH_CONDITIONS
1798/// p2_singleton_tailhash_parent_amount_list ; ((tailhash ((parent amount) (parent_amount)... ) (tailhash (parent amount))..)
1799/// CONDITIONS
1800/// )
1801/// )
1802/// (for_each_asset_type
1803/// TREASURY_SINGLETON_STRUCT
1804/// CAT_MOD_HASH
1805/// P2_SINGLETON_VIA_DELEGATED_PUZZLE_PUZHASH
1806/// LIST_OF_TAILHASH_CONDITIONS
1807/// p2_singleton_tailhash_parent_amount_list ; ((tailhash ((parent amount) (parent_amount)... ) (tailhash (parent amount))..)
1808/// CONDITIONS
1809/// )
1810/// )
1811/// )
1812/// )
1813///
1814/// )
1815/// ```
1816pub const DAO_SPEND_P2_SINGLETON: [u8; 2954] = hex!("ff02ffff01ff04ffff04ffff0148ffff04ffff02ff28ffff04ff02ffff04ffff05ff0580ffff04ff8202ffffff04ffff02ff14ffff04ff02ffff04ff05ff80808080ff808080808080ffff01808080ffff04ffff04ffff0133ffff04ff8202ffffff04ffff0101ffff04ffff04ffff05ffff06ff058080ffff018080ffff018080808080ffff02ffff03ff17ffff01ff02ffff01ff02ff3cffff04ff02ffff04ff05ffff04ffff02ff2affff04ff02ffff04ff17ff80808080ffff04ff5fffff04ffff02ffff03ff8200bfffff01ff02ffff01ff02ff38ffff04ff02ffff04ffff05ffff05ff8200bf8080ffff04ff5fffff04ffff05ffff06ffff05ff8200bf808080ff808080808080ff0180ffff01ff02ffff01ff0180ff018080ff0180ffff04ffff02ffff03ff8200bfffff01ff02ffff01ff06ff8200bf80ff0180ffff01ff02ffff01ff0180ff018080ff0180ffff04ffff02ffff03ff8200bfffff01ff02ffff01ff05ffff06ffff05ff8200bf808080ff0180ffff01ff02ffff01ff0180ff018080ff0180ffff04ffff02ff3effff04ff02ffff04ff05ffff04ff0bffff04ff5fffff04ff2fffff04ff82017fffff04ff17ff808080808080808080ff80808080808080808080ff0180ffff01ff02ffff01ff02ff3effff04ff02ffff04ff05ffff04ff0bffff04ff5fffff04ff2fffff04ff82017fffff04ff17ff808080808080808080ff018080ff01808080ffff04ffff01ffffffff02ffff03ff05ffff01ff02ffff01ff02ff10ffff04ff02ffff04ffff06ff0580ffff04ffff0bffff0102ffff0bffff0101ffff010480ffff0bffff0102ffff0bffff0102ffff0bffff0101ffff010180ffff05ff058080ffff0bffff0102ff0bffff0bffff0101ffff018080808080ff8080808080ff0180ffff01ff02ffff010bff018080ff0180ffff0bffff0102ffff01a0a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222ffff0bffff0102ffff0bffff0102ffff01a09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ff0580ffff0bffff0102ffff02ff10ffff04ff02ffff04ff07ffff01ffa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b280808080ffff01a04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a808080ff02ffff03ffff22ffff09ffff0dff0580ffff012080ffff09ffff0dff0b80ffff012080ffff15ff17ffff0181ff8080ffff01ff02ffff01ff0bff05ff0bff1780ff0180ffff01ff02ffff01ff0880ff018080ff0180ffff02ffff03ffff07ff0580ffff01ff02ffff01ff0bffff0102ffff02ff14ffff04ff02ffff04ffff05ff0580ff80808080ffff02ff14ffff04ff02ffff04ffff06ff0580ff8080808080ff0180ffff01ff02ffff01ff0bffff0101ff0580ff018080ff0180ffff02ffff03ff0bffff01ff02ffff01ff03ffff09ff05ffff05ff0b8080ffff0101ffff02ff2cffff04ff02ffff04ff05ffff04ffff06ff0b80ff808080808080ff0180ffff01ff02ffff01ff0180ff018080ff0180ff04ffff04ffff013effff04ffff02ff14ffff04ff02ffff04ffff04ff2fffff04ffff02ff14ffff04ff02ffff01ff80808080ff808080ff80808080ff808080ffff04ffff04ffff013dffff04ffff0bff2fffff012480ff808080ffff02ffff03ff5fffff01ff02ffff01ff02ff3cffff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ffff02ff38ffff04ff02ffff04ffff05ffff05ff5f8080ffff04ff17ffff04ffff05ffff06ffff05ff5f808080ff808080808080ffff04ffff06ff5f80ffff04ffff10ff8200bfffff05ffff06ffff05ff5f80808080ffff04ff82017fff80808080808080808080ff0180ffff01ff02ffff01ff02ffff03ffff15ffff11ff8200bfff0b80ffff018080ffff01ff02ffff01ff04ffff04ffff0133ffff04ff17ffff04ffff11ff8200bfff0b80ffff04ffff04ff17ffff018080ffff018080808080ff82017f80ff0180ffff01ff02ffff0182017fff018080ff0180ff018080ff01808080ffffff04ffff04ffff013effff04ffff02ff14ffff04ff02ffff04ffff04ff05ffff04ff0bff808080ff80808080ff808080ffff04ffff04ffff013dffff04ffff0bff05ffff012480ff808080ff178080ffff02ffff03ff05ffff01ff02ffff01ff10ffff02ffff03ffff09ffff05ffff05ff058080ffff013380ffff01ff02ffff01ff02ffff03ffff15ffff05ffff06ffff06ffff05ff0580808080ffff018080ffff01ff02ffff01ff05ffff06ffff06ffff05ff0580808080ff0180ffff01ff02ffff01ff0180ff018080ff0180ff0180ffff01ff02ffff01ff0180ff018080ff0180ffff02ff2affff04ff02ffff04ffff06ff0580ff8080808080ff0180ffff01ff02ffff01ff0180ff018080ff0180ff02ff28ffff04ff02ffff04ff05ffff04ff17ffff04ffff0bffff0101ff0b80ffff04ffff0bffff0101ff0580ff80808080808080ffff02ffff03ff05ffff01ff02ffff01ff02ffff03ffff02ff2cffff04ff02ffff04ffff0bff11ff2980ffff04ffff05ffff06ffff06ff01808080ff8080808080ffff01ff02ffff01ff02ff16ffff04ff02ffff04ffff06ffff05ffff06ff01808080ffff04ffff05ffff06ffff06ff01808080ff8080808080ff0180ffff01ff02ffff01ff04ffff05ffff05ffff06ff01808080ffff02ff16ffff04ff02ffff04ffff06ffff05ffff06ff01808080ffff04ffff04ffff0bff11ff2980ffff05ffff06ffff06ff0180808080ff808080808080ff018080ff0180ff0180ffff01ff02ffff01ff0180ff018080ff0180ffff02ffff03ff8200bfffff01ff02ffff01ff02ff12ffff04ff02ffff04ffff02ff38ffff04ff02ffff04ffff05ffff05ff8200bf8080ffff04ff5fffff04ffff05ffff06ffff05ff8200bf808080ff808080808080ffff04ffff02ffff03ffff06ff8200bf80ffff01ff02ffff01ff02ff14ffff04ff02ffff04ffff0180ff80808080ff0180ffff01ff02ffff01ff02ff14ffff04ff02ffff04ffff04ffff0101ffff02ffff03ffff15ffff11ffff10ff82017fffff05ffff06ffff05ff8200bf80808080ff8202ff80ffff018080ffff01ff02ffff01ff04ffff04ffff0133ffff04ffff05ffff06ffff06ffff06ffff06ff018080808080ffff04ffff11ffff10ff82017fffff05ffff06ffff05ff8200bf80808080ff8202ff80ffff04ffff04ffff05ffff06ffff06ffff06ffff06ff018080808080ffff018080ffff018080808080ffff05ffff06ffff06ffff06ff018080808080ff0180ffff01ff02ffff01ff05ffff06ffff06ffff06ff0180808080ff018080ff018080ff80808080ff018080ff0180ffff04ffff02ff2effff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ffff06ff8200bf80ffff04ffff10ff82017fffff05ffff06ffff05ff8200bf80808080ffff04ff8202ffffff04ff8205ffff808080808080808080808080ff808080808080ff0180ffff01ff02ffff018205ffff018080ff0180ff02ffff03ff2fffff01ff02ffff01ff02ff3effff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ffff06ff2f80ffff04ffff06ff5f80ffff04ffff02ff2effff04ff02ffff04ff05ffff04ff0bffff04ffff02ffff03ffff09ffff05ffff05ff2f8080ffff05ffff05ff5f808080ffff01ff02ffff01ff05ffff06ffff05ff2f808080ff0180ffff01ff02ffff01ff0880ff018080ff0180ffff04ff17ffff04ffff02ff3affff04ff02ffff04ff0bffff04ffff05ffff05ff5f8080ffff04ff17ff808080808080ffff04ffff02ff16ffff04ff02ffff04ffff05ffff06ffff05ff5f808080ffff04ffff0180ffff04ffff0180ff808080808080ffff04ffff0180ffff04ffff02ff2affff04ff02ffff04ffff05ffff06ffff05ff2f808080ff80808080ffff04ff8200bfff808080808080808080808080ff808080808080808080ff0180ffff01ff02ffff018200bfff018080ff0180ff018080");
1817pub const DAO_SPEND_P2_SINGLETON_HASH: [u8; 32] =
1818 hex!("7bc8942159e600f56a87e1d9c059c8705307ec2fb996a949503298dedfed00be");
1819
1820/// ```text
1821/// (mod
1822/// (
1823/// TREASURY_MOD_HASH
1824/// PROPOSAL_VALIDATOR ; this is the curryed proposal validator
1825/// PROPOSAL_LENGTH
1826/// PROPOSAL_SOFTCLOSE_LENGTH
1827/// ATTENDANCE_REQUIRED
1828/// PASS_MARGIN ; this is a percentage 0 - 10,000 - 51% would be 5100
1829/// PROPOSAL_SELF_DESTRUCT_TIME ; time in seconds after which proposals can be automatically closed
1830/// ORACLE_SPEND_DELAY ; timelock delay for oracle spend
1831/// (@ proposal_announcement (announcement_source delegated_puzzle_hash announcement_args))
1832/// proposal_validator_solution
1833/// delegated_puzzle_reveal ; this is the reveal of the puzzle announced by the proposal
1834/// delegated_solution ; this is not secure unless the delegated puzzle secures it
1835/// my_singleton_struct
1836/// )
1837/// (include utility_macros.clib)
1838/// (include condition_codes.clib)
1839/// (include curry-and-treehash.clib)
1840/// (include *standard-cl-21*)
1841///
1842/// (defun-inline recreate_self (
1843/// TREASURY_MOD_HASH
1844/// PROPOSAL_VALIDATOR
1845/// PROPOSAL_LENGTH
1846/// PROPOSAL_SOFTCLOSE_LENGTH
1847/// ATTENDANCE_REQUIRED
1848/// PASS_MARGIN
1849/// PROPOSAL_SELF_DESTRUCT_TIME
1850/// ORACLE_SPEND_DELAY
1851/// )
1852/// (puzzle-hash-of-curried-function TREASURY_MOD_HASH
1853/// (sha256 ONE ORACLE_SPEND_DELAY)
1854/// (sha256 ONE PROPOSAL_SELF_DESTRUCT_TIME)
1855/// (sha256 ONE PASS_MARGIN)
1856/// (sha256 ONE ATTENDANCE_REQUIRED)
1857/// (sha256 ONE PROPOSAL_SOFTCLOSE_LENGTH)
1858/// (sha256 ONE PROPOSAL_LENGTH)
1859/// (sha256tree PROPOSAL_VALIDATOR)
1860/// (sha256 ONE TREASURY_MOD_HASH)
1861/// )
1862/// )
1863///
1864/// (defun calculate_singleton_puzzle_hash (SINGLETON_STRUCT inner_puzzle_hash)
1865/// (puzzle-hash-of-curried-function (f SINGLETON_STRUCT)
1866/// inner_puzzle_hash
1867/// (sha256tree SINGLETON_STRUCT)
1868/// )
1869/// )
1870///
1871/// (defun stager (ORACLE_SPEND_DELAY my_inner_puzhash singleton_struct)
1872/// (c
1873/// (if singleton_struct
1874/// (list ASSERT_MY_COIN_ID
1875/// (calculate_coin_id
1876/// (f (r singleton_struct))
1877/// (calculate_singleton_puzzle_hash singleton_struct my_inner_puzhash)
1878/// ONE
1879/// )
1880/// ;; TODO: When the new condition codes are available, use ASSERT_EPHEMERAL to ensure this
1881/// ;; spend path is only used in the eve spend.
1882/// ;; (list ASSERT_EPHEMERAL)
1883/// )
1884/// (list ASSERT_HEIGHT_RELATIVE ORACLE_SPEND_DELAY)
1885/// )
1886/// (list (list CREATE_COIN my_inner_puzhash ONE))
1887/// )
1888/// )
1889///
1890/// (c
1891/// (list CREATE_PUZZLE_ANNOUNCEMENT 0) ; the arguments are secured implicitly in the puzzle of the treasury
1892/// (if delegated_puzzle_reveal
1893/// ; if we're checking a proposal (testing if it has passed)
1894/// (if (= (sha256tree delegated_puzzle_reveal) delegated_puzzle_hash)
1895/// ; Merge the treasury conditions with the proposal validator conditions
1896/// ; If the update case then the validator returns the new treasury create coin
1897/// ; If the spend case then we need to recreate the treasury outselves
1898/// ; treasury specific conditions
1899///
1900/// (c
1901/// (list ASSERT_COIN_ANNOUNCEMENT (sha256 announcement_source (sha256tree (list delegated_puzzle_hash announcement_args)))) ; announcement source is validated inside the ProposalValidator
1902/// (c
1903/// (list ASSERT_HEIGHT_RELATIVE 1)
1904/// (a
1905/// PROPOSAL_VALIDATOR
1906/// (list
1907/// ATTENDANCE_REQUIRED
1908/// PASS_MARGIN
1909/// proposal_announcement
1910/// proposal_validator_solution
1911/// (a delegated_puzzle_reveal delegated_solution)
1912/// )
1913/// )
1914/// )
1915/// )
1916/// (x)
1917/// )
1918/// ; no proposal_flag so create the oracle announcement
1919/// (stager
1920/// ORACLE_SPEND_DELAY
1921/// (recreate_self
1922/// TREASURY_MOD_HASH
1923/// PROPOSAL_VALIDATOR
1924/// PROPOSAL_LENGTH
1925/// PROPOSAL_SOFTCLOSE_LENGTH
1926/// ATTENDANCE_REQUIRED
1927/// PASS_MARGIN
1928/// PROPOSAL_SELF_DESTRUCT_TIME
1929/// ORACLE_SPEND_DELAY
1930/// )
1931/// my_singleton_struct
1932/// )
1933/// )
1934/// )
1935/// )
1936/// ```
1937pub const DAO_TREASURY: [u8; 1200] = hex!("ff02ffff01ff04ffff04ffff013effff04ffff0180ffff01808080ffff02ffff03ff8217ffffff01ff02ffff01ff02ffff03ffff09ffff02ff0affff04ff02ffff04ff8217ffff80808080ff8215ff80ffff01ff02ffff01ff04ffff04ffff013dffff04ffff0bff8209ffffff02ff0affff04ff02ffff04ffff04ff8215ffffff04ff822dffffff01808080ff8080808080ffff01808080ffff04ffff04ffff0152ffff04ffff0101ffff01808080ffff02ff0bffff04ff5fffff04ff8200bfffff04ff8205ffffff04ff820bffffff04ffff02ff8217ffff822fff80ffff01808080808080808080ff0180ffff01ff02ffff01ff0880ff018080ff0180ff0180ffff01ff02ffff01ff02ff1effff04ff02ffff04ff8202ffffff04ffff02ff14ffff04ff02ffff04ff05ffff04ffff0bffff0101ff8202ff80ffff04ffff0bffff0101ff82017f80ffff04ffff0bffff0101ff8200bf80ffff04ffff0bffff0101ff5f80ffff04ffff0bffff0101ff2f80ffff04ffff0bffff0101ff1780ffff04ffff02ff0affff04ff02ffff04ff0bff80808080ffff04ffff0bffff0101ff0580ff808080808080808080808080ffff04ff825fffff808080808080ff018080ff018080ffff04ffff01ffffff02ffff03ff05ffff01ff02ffff01ff02ff08ffff04ff02ffff04ffff06ff0580ffff04ffff0bffff0102ffff0bffff0101ffff010480ffff0bffff0102ffff0bffff0102ffff0bffff0101ffff010180ffff05ff058080ffff0bffff0102ff0bffff0bffff0101ffff018080808080ff8080808080ff0180ffff01ff02ffff010bff018080ff0180ffff0bffff0102ffff01a0a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222ffff0bffff0102ffff0bffff0102ffff01a09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ff0580ffff0bffff0102ffff02ff08ffff04ff02ffff04ff07ffff01ffa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b280808080ffff01a04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a808080ff02ffff03ffff22ffff09ffff0dff0580ffff012080ffff09ffff0dff0b80ffff012080ffff15ff17ffff0181ff8080ffff01ff02ffff01ff0bff05ff0bff1780ff0180ffff01ff02ffff01ff0880ff018080ff0180ffff02ffff03ffff07ff0580ffff01ff02ffff01ff0bffff0102ffff02ff0affff04ff02ffff04ffff05ff0580ff80808080ffff02ff0affff04ff02ffff04ffff06ff0580ff8080808080ff0180ffff01ff02ffff01ff0bffff0101ff0580ff018080ff0180ffff02ff14ffff04ff02ffff04ff09ffff04ff0bffff04ffff02ff0affff04ff02ffff04ff05ff80808080ff808080808080ff04ffff02ffff03ff17ffff01ff02ffff01ff04ffff0146ffff04ffff02ff1cffff04ff02ffff04ffff05ffff06ff178080ffff04ffff02ff16ffff04ff02ffff04ff17ffff04ff0bff8080808080ffff04ffff0101ff808080808080ffff01808080ff0180ffff01ff02ffff01ff04ffff0152ffff04ff05ffff01808080ff018080ff0180ffff04ffff04ffff0133ffff04ff0bffff01ff01808080ff808080ff018080");
1938pub const DAO_TREASURY_HASH: [u8; 32] =
1939 hex!("637d78acd395b6bb03211bcfc5f5f2e878cba2d62b2f53871d49a8b928411b19");
1940
1941/// ```text
1942/// (mod
1943/// (
1944/// TREASURY_MOD_HASH
1945/// VALIDATOR_MOD_HASH
1946/// SINGLETON_STRUCT ; (SINGLETON_MOD_HASH (SINGLETON_ID . LAUNCHER_PUZZLE_HASH))
1947/// PROPOSAL_SELF_HASH
1948/// PROPOSAL_MINIMUM_AMOUNT
1949/// PROPOSAL_EXCESS_PAYOUT_PUZHASH
1950/// PROPOSAL_LENGTH
1951/// PROPOSAL_SOFTCLOSE_LENGTH
1952/// ATTENDANCE_REQUIRED
1953/// PASS_MARGIN
1954/// PROPOSAL_SELF_DESTRUCT_TIME
1955/// ORACLE_SPEND_DELAY
1956/// )
1957/// ;; This is a proposal to update treasury conditions for a DAO
1958///
1959///
1960/// (include condition_codes.clib)
1961/// (include curry-and-treehash.clib)
1962/// (include *standard-cl-21*)
1963/// (include utility_macros.clib)
1964///
1965/// (list
1966/// (list CREATE_COIN
1967/// (puzzle-hash-of-curried-function TREASURY_MOD_HASH
1968/// (sha256 ONE ORACLE_SPEND_DELAY)
1969/// (sha256 ONE PROPOSAL_SELF_DESTRUCT_TIME)
1970/// (sha256 ONE PASS_MARGIN)
1971/// (sha256 ONE ATTENDANCE_REQUIRED)
1972/// (sha256 ONE PROPOSAL_SOFTCLOSE_LENGTH)
1973/// (sha256 ONE PROPOSAL_LENGTH)
1974/// (puzzle-hash-of-curried-function VALIDATOR_MOD_HASH
1975/// (sha256 ONE PROPOSAL_EXCESS_PAYOUT_PUZHASH)
1976/// (sha256 ONE PROPOSAL_MINIMUM_AMOUNT)
1977/// (sha256 ONE PROPOSAL_SELF_HASH)
1978/// (sha256tree SINGLETON_STRUCT)
1979/// )
1980/// (sha256 ONE TREASURY_MOD_HASH)
1981/// )
1982/// ONE
1983/// )
1984/// )
1985/// )
1986/// ```
1987pub const DAO_UPDATE_PROPOSAL: [u8; 705] = hex!("ff02ffff01ff04ffff04ffff0133ffff04ffff02ff0affff04ff02ffff04ff05ffff04ffff0bffff0101ff822fff80ffff04ffff0bffff0101ff8217ff80ffff04ffff0bffff0101ff820bff80ffff04ffff0bffff0101ff8205ff80ffff04ffff0bffff0101ff8202ff80ffff04ffff0bffff0101ff82017f80ffff04ffff02ff0affff04ff02ffff04ff0bffff04ffff0bffff0101ff8200bf80ffff04ffff0bffff0101ff5f80ffff04ffff0bffff0101ff2f80ffff04ffff02ff0effff04ff02ffff04ff17ff80808080ff8080808080808080ffff04ffff0bffff0101ff0580ff808080808080808080808080ffff04ffff0101ffff0180808080ffff018080ffff04ffff01ffff02ffff03ff05ffff01ff02ffff01ff02ff04ffff04ff02ffff04ffff06ff0580ffff04ffff0bffff0102ffff0bffff0101ffff010480ffff0bffff0102ffff0bffff0102ffff0bffff0101ffff010180ffff05ff058080ffff0bffff0102ff0bffff0bffff0101ffff018080808080ff8080808080ff0180ffff01ff02ffff010bff018080ff0180ffff0bffff0102ffff01a0a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222ffff0bffff0102ffff0bffff0102ffff01a09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ff0580ffff0bffff0102ffff02ff04ffff04ff02ffff04ff07ffff01ffa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b280808080ffff01a04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a808080ff02ffff03ffff07ff0580ffff01ff02ffff01ff0bffff0102ffff02ff0effff04ff02ffff04ffff05ff0580ff80808080ffff02ff0effff04ff02ffff04ffff06ff0580ff8080808080ff0180ffff01ff02ffff01ff0bffff0101ff0580ff018080ff0180ff018080");
1988pub const DAO_UPDATE_PROPOSAL_HASH: [u8; 32] =
1989 hex!("fc032384cfece9b542c3e1ea77ba119fb1013a3d74b622302c0b670447e4343d");
1990
1991/// ```text
1992/// ; The DID innerpuzzle is designed to sit inside the singleton layer and provide functionality related to being an identity.
1993/// ; At the moment the two pieces of functionality are recovery and message creation.
1994/// ; A DID's ID is it's Singleton ID
1995/// ; Recovery is based around having a list of known other DIDs which can send messages approving you change the innerpuzzle of your DID singleton
1996///
1997/// (mod
1998/// (
1999/// INNER_PUZZLE ; Standard P2 inner puzzle, used to record the ownership of the DID.
2000/// RECOVERY_DID_LIST_HASH ; the list of DIDs that can send messages to you for recovery we store only the hash so that we don't have to reveal every time we make a message spend
2001/// NUM_VERIFICATIONS_REQUIRED ; how many of the above list are required for a recovery
2002/// SINGLETON_STRUCT ; my singleton_struct, formerly a Truth - ((SINGLETON_MOD_HASH, (LAUNCHER_ID, LAUNCHER_PUZZLE_HASH)))
2003/// METADATA ; Customized metadata, e.g KYC info
2004/// mode ; this indicates which spend mode we want. 0. Recovery mode 1. Run INNER_PUZZLE with p2_solution
2005/// my_amount_or_inner_solution ; In mode 0, we use this to recover our coin and assert it is our actual amount
2006/// ; In mode 1 this is the solution of the inner P2 puzzle, only required in the create message mode and transfer mode.
2007/// new_inner_puzhash ; In recovery mode, this will be the new wallet DID puzzle hash
2008/// parent_innerpuzhash_amounts_for_recovery_ids ; during a recovery we need extra information about our recovery list coins
2009/// pubkey ; this is the new pubkey used for a recovery
2010/// recovery_list_reveal ; this is the reveal of the stored list of DIDs approved for recovery
2011/// my_id ; my coin ID
2012/// )
2013/// ;message is the new puzzle in the recovery and standard spend cases
2014///
2015/// ;MOD_HASH, MY_PUBKEY, RECOVERY_DID_LIST_HASH are curried into the puzzle
2016/// ;EXAMPLE SOLUTION (0xcafef00d 0x12341234 0x923bf9a7856b19d335a65f12d68957d497e1f0c16c0e14baf6d120e60753a1ce 2 1 100 (q "source code") 0xdeadbeef 0xcafef00d ((0xdadadada 0xdad5dad5 200) () (0xfafafafa 0xfaf5faf5 200)) 0xfadeddab (0x22222222 0x33333333 0x44444444))
2017///
2018/// (include condition_codes.clib)
2019/// (include curry-and-treehash.clib)
2020///
2021/// ; takes a lisp tree and returns the hash of it
2022/// (defun sha256tree1 (TREE)
2023/// (if (l TREE)
2024/// (sha256 2 (sha256tree1 (f TREE)) (sha256tree1 (r TREE)))
2025/// (sha256 1 TREE)
2026/// )
2027/// )
2028///
2029/// ; recovery message module - gets values curried in to make the puzzle
2030/// (defun make_message_puzzle (recovering_coin newpuz pubkey)
2031/// (qq (q . (((unquote CREATE_COIN_ANNOUNCEMENT) (unquote recovering_coin)) ((unquote AGG_SIG_UNSAFE) (unquote pubkey) (unquote newpuz)))))
2032/// )
2033///
2034/// ; this function creates the assert announcement for each message coin approving a recovery
2035/// (defun-inline create_consume_message (coin_id my_id new_innerpuz pubkey)
2036/// (list ASSERT_COIN_ANNOUNCEMENT (sha256 (sha256 coin_id (sha256tree1 (make_message_puzzle my_id new_innerpuz pubkey))) my_id))
2037/// )
2038///
2039/// ; this function calculates a coin ID given the inner puzzle and singleton information
2040/// (defun create_coin_ID_for_recovery (SINGLETON_STRUCT launcher_id parent innerpuzhash amount)
2041/// (sha256 parent (calculate_full_puzzle_hash (c (f SINGLETON_STRUCT) (c launcher_id (r (r SINGLETON_STRUCT)))) innerpuzhash) amount)
2042/// )
2043///
2044///
2045/// ; return the full puzzlehash for a singleton with the innerpuzzle curried in
2046/// ; puzzle-hash-of-curried-function is imported from curry-and-treehash.clib
2047/// (defun-inline calculate_full_puzzle_hash (SINGLETON_STRUCT inner_puzzle_hash)
2048/// (puzzle-hash-of-curried-function (f SINGLETON_STRUCT)
2049/// inner_puzzle_hash
2050/// (sha256tree1 SINGLETON_STRUCT)
2051/// )
2052/// )
2053///
2054/// ; this loops over our identities to check list, and checks if we have been given parent information for this identity
2055/// ; the reason for this is because we might only require 3/5 of the IDs give approval messages for a recovery
2056/// ; if we have the information for an identity then we create a consume message using that information
2057///
2058/// (defun check_messages_from_identities (SINGLETON_STRUCT num_verifications_required identities my_id new_puz parent_innerpuzhash_amounts_for_recovery_ids pubkey num_verifications)
2059/// (if identities
2060/// (if (f parent_innerpuzhash_amounts_for_recovery_ids)
2061/// ; if we have parent information then we should create a consume coin condition
2062/// (c
2063/// (create_consume_message
2064/// ; create coin_id from DID
2065/// (create_coin_ID_for_recovery
2066/// SINGLETON_STRUCT
2067/// (f identities)
2068/// (f (f parent_innerpuzhash_amounts_for_recovery_ids))
2069/// (f (r (f parent_innerpuzhash_amounts_for_recovery_ids)))
2070/// (f (r (r (f parent_innerpuzhash_amounts_for_recovery_ids)))))
2071/// my_id
2072/// new_puz
2073/// pubkey
2074/// )
2075/// (check_messages_from_identities
2076/// SINGLETON_STRUCT
2077/// num_verifications_required
2078/// (r identities)
2079/// my_id
2080/// new_puz
2081/// (r parent_innerpuzhash_amounts_for_recovery_ids)
2082/// pubkey
2083/// (+ num_verifications 1)
2084/// )
2085/// )
2086/// ; if no parent information found for this identity, move on to next in list
2087/// (check_messages_from_identities
2088/// SINGLETON_STRUCT
2089/// (r identities)
2090/// my_id
2091/// new_puz
2092/// (r parent_innerpuzhash_amounts_for_recovery_ids)
2093/// pubkey
2094/// num_verifications
2095/// )
2096/// )
2097/// ;if we're out of identites to check for, check we have enough
2098/// (if (> num_verifications (- num_verifications_required 1))
2099/// (list (list AGG_SIG_UNSAFE pubkey new_puz) )
2100/// (x)
2101/// )
2102/// )
2103/// )
2104///
2105/// ;Spend modes:
2106/// ;0 = recovery
2107/// ;1 = run the INNER_PUZZLE
2108///
2109/// ;MAIN
2110/// (if mode
2111/// ; mode 1 - run INNER_PUZZLE
2112/// (a INNER_PUZZLE my_amount_or_inner_solution)
2113///
2114/// ; mode 0 - recovery
2115/// (if (all (= (sha256tree1 recovery_list_reveal) RECOVERY_DID_LIST_HASH) (> NUM_VERIFICATIONS_REQUIRED 0))
2116/// (c (list ASSERT_MY_AMOUNT my_amount_or_inner_solution)
2117/// (c (list CREATE_COIN new_inner_puzhash my_amount_or_inner_solution (list new_inner_puzhash))
2118/// (c (list ASSERT_MY_COIN_ID my_id)
2119/// (check_messages_from_identities SINGLETON_STRUCT NUM_VERIFICATIONS_REQUIRED recovery_list_reveal my_id new_inner_puzhash parent_innerpuzhash_amounts_for_recovery_ids pubkey 0)
2120/// )
2121/// )
2122/// )
2123/// (x)
2124/// )
2125/// )
2126/// )
2127/// ```
2128pub const DID_INNERPUZ: [u8; 1012] = hex!("ff02ffff01ff02ffff03ff81bfffff01ff02ff05ff82017f80ffff01ff02ffff03ffff22ffff09ffff02ff7effff04ff02ffff04ff8217ffff80808080ff0b80ffff15ff17ff808080ffff01ff04ffff04ff28ffff04ff82017fff808080ffff04ffff04ff34ffff04ff8202ffffff04ff82017fffff04ffff04ff8202ffff8080ff8080808080ffff04ffff04ff38ffff04ff822fffff808080ffff02ff26ffff04ff02ffff04ff2fffff04ff17ffff04ff8217ffffff04ff822fffffff04ff8202ffffff04ff8205ffffff04ff820bffffff01ff8080808080808080808080808080ffff01ff088080ff018080ff0180ffff04ffff01ffffffff313dff4946ffff0233ff3c04ffffff0101ff02ff02ffff03ff05ffff01ff02ff3affff04ff02ffff04ff0dffff04ffff0bff2affff0bff22ff3c80ffff0bff2affff0bff2affff0bff22ff3280ff0980ffff0bff2aff0bffff0bff22ff8080808080ff8080808080ffff010b80ff0180ffffff02ffff03ff17ffff01ff02ffff03ff82013fffff01ff04ffff04ff30ffff04ffff0bffff0bffff02ff36ffff04ff02ffff04ff05ffff04ff27ffff04ff82023fffff04ff82053fffff04ff820b3fff8080808080808080ffff02ff7effff04ff02ffff04ffff02ff2effff04ff02ffff04ff2fffff04ff5fffff04ff82017fff808080808080ff8080808080ff2f80ff808080ffff02ff26ffff04ff02ffff04ff05ffff04ff0bffff04ff37ffff04ff2fffff04ff5fffff04ff8201bfffff04ff82017fffff04ffff10ff8202ffffff010180ff808080808080808080808080ffff01ff02ff26ffff04ff02ffff04ff05ffff04ff37ffff04ff2fffff04ff5fffff04ff8201bfffff04ff82017fffff04ff8202ffff8080808080808080808080ff0180ffff01ff02ffff03ffff15ff8202ffffff11ff0bffff01018080ffff01ff04ffff04ff20ffff04ff82017fffff04ff5fff80808080ff8080ffff01ff088080ff018080ff0180ff0bff17ffff02ff5effff04ff02ffff04ff09ffff04ff2fffff04ffff02ff7effff04ff02ffff04ffff04ff09ffff04ff0bff1d8080ff80808080ff808080808080ff5f80ffff04ffff0101ffff04ffff04ff2cffff04ff05ff808080ffff04ffff04ff20ffff04ff17ffff04ff0bff80808080ff80808080ffff0bff2affff0bff22ff2480ffff0bff2affff0bff2affff0bff22ff3280ff0580ffff0bff2affff02ff3affff04ff02ffff04ff07ffff04ffff0bff22ff2280ff8080808080ffff0bff22ff8080808080ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff7effff04ff02ffff04ff09ff80808080ffff02ff7effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080");
2129pub const DID_INNERPUZ_HASH: [u8; 32] =
2130 hex!("33143d2bef64f14036742673afd158126b94284b4530a28c354fac202b0c910e");
2131
2132/// ```text
2133/// (mod
2134/// (
2135/// INNER_PUZZLE
2136/// SINGLETON_STRUCTS
2137/// METADATA_LAYER_HASHES
2138/// VALUES_TO_PROVE ; this is a list of BRANCHES in the merkle tree to prove (so as to prove a whole subtree)
2139/// proofs_of_inclusion
2140/// new_metadatas ; (root . etc)
2141/// new_metadata_updaters
2142/// new_inner_puzs
2143/// inner_solution
2144/// )
2145///
2146/// (include condition_codes.clib)
2147/// (include merkle_utils.clib)
2148/// (include curry-and-treehash.clib)
2149///
2150/// (defmacro assert items
2151/// (if (r items)
2152/// (list if (f items) (c assert (r items)) (q . (x)))
2153/// (f items)
2154/// )
2155/// )
2156///
2157/// (defun-inline construct_singleton (SINGLETON_STRUCT METADATA_LAYER_HASH new_metadata new_metadata_updater new_inner_puz)
2158/// (puzzle-hash-of-curried-function (f SINGLETON_STRUCT)
2159/// (puzzle-hash-of-curried-function METADATA_LAYER_HASH
2160/// new_inner_puz
2161/// (sha256tree new_metadata_updater)
2162/// (sha256tree new_metadata)
2163/// (sha256tree METADATA_LAYER_HASH)
2164/// )
2165/// (sha256tree SINGLETON_STRUCT)
2166/// )
2167/// )
2168///
2169/// (defun verify_proofs (new_root VALUES_TO_PROVE proofs_of_inclusion)
2170/// (if proofs_of_inclusion
2171/// (assert (= new_root (simplify_merkle_proof_after_leaf (f VALUES_TO_PROVE) (f proofs_of_inclusion)))
2172/// ; then
2173/// (verify_proofs new_root (r VALUES_TO_PROVE) (r proofs_of_inclusion))
2174/// )
2175/// 1
2176/// )
2177/// )
2178///
2179/// (defun loop_over_curried_params
2180/// (
2181/// SINGLETON_STRUCTS
2182/// METADATA_LAYER_HASHES
2183/// VALUES_TO_PROVE
2184/// proofs_of_inclusion
2185/// new_metadatas
2186/// new_metadata_updaters
2187/// new_inner_puzs
2188/// conditions
2189/// )
2190///
2191/// (if SINGLETON_STRUCTS
2192/// (assert (verify_proofs (f (f new_metadatas)) (f VALUES_TO_PROVE) (f proofs_of_inclusion))
2193/// ; then
2194/// (loop_over_curried_params
2195/// (r SINGLETON_STRUCTS)
2196/// (r METADATA_LAYER_HASHES)
2197/// (r VALUES_TO_PROVE)
2198/// (r proofs_of_inclusion)
2199/// (r new_metadatas)
2200/// (r new_metadata_updaters)
2201/// (r new_inner_puzs)
2202/// (c
2203/// (list
2204/// ASSERT_PUZZLE_ANNOUNCEMENT
2205/// (sha256
2206/// (construct_singleton (f SINGLETON_STRUCTS) (f METADATA_LAYER_HASHES) (f new_metadatas) (f new_metadata_updaters) (f new_inner_puzs))
2207/// '$'
2208/// )
2209/// )
2210/// conditions
2211/// )
2212/// )
2213/// )
2214/// conditions
2215/// )
2216/// )
2217///
2218/// (if proofs_of_inclusion
2219/// (loop_over_curried_params
2220/// SINGLETON_STRUCTS
2221/// METADATA_LAYER_HASHES
2222/// VALUES_TO_PROVE
2223/// proofs_of_inclusion
2224/// new_metadatas
2225/// new_metadata_updaters
2226/// new_inner_puzs
2227/// (a INNER_PUZZLE inner_solution)
2228/// )
2229/// ; You may want to run the puzzle without a raise to examine conditions so we'll make a "blessed" way to fail
2230/// (c (list ASSERT_MY_AMOUNT -1) (a INNER_PUZZLE inner_solution))
2231/// )
2232/// )
2233/// ```
2234pub const GRAFTROOT_DL_OFFERS: [u8; 922] = hex!("ff02ffff01ff02ffff03ff5fffff01ff02ff3affff04ff02ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ff81bfffff04ff82017fffff04ff8202ffffff04ffff02ff05ff8205ff80ff8080808080808080808080ffff01ff04ffff04ff10ffff01ff81ff8080ffff02ff05ff8205ff808080ff0180ffff04ffff01ffffff49ff3f02ff04ff0101ffff02ffff02ffff03ff05ffff01ff02ff2affff04ff02ffff04ff0dffff04ffff0bff12ffff0bff2cff1480ffff0bff12ffff0bff12ffff0bff2cff3c80ff0980ffff0bff12ff0bffff0bff2cff8080808080ff8080808080ffff010b80ff0180ff02ffff03ff05ffff01ff02ffff03ffff02ff3effff04ff02ffff04ff82011fffff04ff27ffff04ff4fff808080808080ffff01ff02ff3affff04ff02ffff04ff0dffff04ff1bffff04ff37ffff04ff6fffff04ff81dfffff04ff8201bfffff04ff82037fffff04ffff04ffff04ff28ffff04ffff0bffff02ff26ffff04ff02ffff04ff11ffff04ffff02ff26ffff04ff02ffff04ff13ffff04ff82027fffff04ffff02ff36ffff04ff02ffff04ff82013fff80808080ffff04ffff02ff36ffff04ff02ffff04ff819fff80808080ffff04ffff02ff36ffff04ff02ffff04ff13ff80808080ff8080808080808080ffff04ffff02ff36ffff04ff02ffff04ff09ff80808080ff808080808080ffff012480ff808080ff8202ff80ff8080808080808080808080ffff01ff088080ff0180ffff018202ff80ff0180ffffff0bff12ffff0bff2cff3880ffff0bff12ffff0bff12ffff0bff2cff3c80ff0580ffff0bff12ffff02ff2affff04ff02ffff04ff07ffff04ffff0bff2cff2c80ff8080808080ffff0bff2cff8080808080ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff36ffff04ff02ffff04ff09ff80808080ffff02ff36ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ffff02ffff03ff1bffff01ff02ff2effff04ff02ffff04ffff02ffff03ffff18ffff0101ff1380ffff01ff0bffff0102ff2bff0580ffff01ff0bffff0102ff05ff2b8080ff0180ffff04ffff04ffff17ff13ffff0181ff80ff3b80ff8080808080ffff010580ff0180ff02ffff03ff17ffff01ff02ffff03ffff09ff05ffff02ff2effff04ff02ffff04ff13ffff04ff27ff808080808080ffff01ff02ff3effff04ff02ffff04ff05ffff04ff1bffff04ff37ff808080808080ffff01ff088080ff0180ffff01ff010180ff0180ff018080");
2235pub const GRAFTROOT_DL_OFFERS_HASH: [u8; 32] =
2236 hex!("0893e36a88c064fddfa6f8abdb42c044584a98cb4273b80cccc83b4867b701a1");
2237
2238/// ```text
2239/// (mod (LAUNCHER_PH MINT_NUMBER MINT_TOTAL)
2240/// (include condition_codes.clib)
2241/// (list
2242/// (list CREATE_COIN LAUNCHER_PH 1)
2243/// (list CREATE_COIN_ANNOUNCEMENT (sha256 MINT_NUMBER MINT_TOTAL)))
2244/// )
2245/// ```
2246pub const CREATE_NFT_LAUNCHER_FROM_DID: [u8; 65] = hex!("ff02ffff01ff04ffff04ff04ffff04ff05ffff01ff01808080ffff04ffff04ff06ffff04ffff0bff0bff1780ff808080ff808080ffff04ffff01ff333cff018080");
2247pub const CREATE_NFT_LAUNCHER_FROM_DID_HASH: [u8; 32] =
2248 hex!("7a32d2d9571d3436791c0ad3d7fcfdb9c43ace2b0f0ff13f98d29f0cc093f445");
2249
2250/// ```text
2251/// (mod (LAUNCHER_PH MINT_NUMBER MINT_TOTAL)
2252/// (include condition_codes.clib)
2253/// (list
2254/// (list CREATE_COIN LAUNCHER_PH 1)
2255/// (list CREATE_COIN_ANNOUNCEMENT (sha256 MINT_NUMBER MINT_TOTAL)))
2256/// )
2257/// ```
2258pub const NFT_INTERMEDIATE_LAUNCHER: [u8; 65] = hex!("ff02ffff01ff04ffff04ff04ffff04ff05ffff01ff01808080ffff04ffff04ff06ffff04ffff0bff0bff1780ff808080ff808080ffff04ffff01ff333cff018080");
2259pub const NFT_INTERMEDIATE_LAUNCHER_HASH: [u8; 32] =
2260 hex!("7a32d2d9571d3436791c0ad3d7fcfdb9c43ace2b0f0ff13f98d29f0cc093f445");
2261
2262/// ```text
2263/// (mod (CURRENT_METADATA METADATA_UPDATER_PUZZLE_HASH (key . new_url))
2264///
2265/// ; METADATA and METADATA_UPDATER_PUZZLE_HASH are passed in as truths from the layer above
2266/// ; This program returns ((new_metadata new_metadata_updater_puzhash) conditions)
2267///
2268/// ; Add uri to a field
2269/// (defun add_url (METADATA key new_url)
2270/// (if METADATA
2271/// (if (= (f (f METADATA)) key)
2272/// (c (c key (c new_url (r (f METADATA)))) (r METADATA))
2273/// (c (f METADATA) (add_url (r METADATA) key new_url))
2274/// )
2275/// ()
2276/// )
2277/// )
2278/// ; main
2279/// ; returns ((new_metadata new_metadata_updater_puzhash) conditions)
2280/// (list
2281/// (list
2282/// (if (all key new_url)
2283/// (if (any (= key "mu") (= key "lu") (= key "u"))
2284/// (add_url CURRENT_METADATA key new_url)
2285/// CURRENT_METADATA
2286/// )
2287/// CURRENT_METADATA
2288/// )
2289/// METADATA_UPDATER_PUZZLE_HASH)
2290/// 0
2291/// )
2292/// )
2293/// ```
2294pub const NFT_METADATA_UPDATER_DEFAULT: [u8; 241] = hex!("ff02ffff01ff04ffff04ffff02ffff03ffff22ff27ff3780ffff01ff02ffff03ffff21ffff09ff27ffff01826d7580ffff09ff27ffff01826c7580ffff09ff27ffff01758080ffff01ff02ff02ffff04ff02ffff04ff05ffff04ff27ffff04ff37ff808080808080ffff010580ff0180ffff010580ff0180ffff04ff0bff808080ffff01ff808080ffff04ffff01ff02ffff03ff05ffff01ff02ffff03ffff09ff11ff0b80ffff01ff04ffff04ff0bffff04ff17ff198080ff0d80ffff01ff04ff09ffff02ff02ffff04ff02ffff04ff0dffff04ff0bffff04ff17ff8080808080808080ff0180ff8080ff0180ff018080");
2295pub const NFT_METADATA_UPDATER_DEFAULT_HASH: [u8; 32] =
2296 hex!("fe8a4b4e27a2e29a4d3fc7ce9d527adbcaccbab6ada3903ccf3ba9a769d2d78b");
2297
2298/// ```text
2299/// (mod (CURRENT_METADATA METADATA_UPDATER_PUZZLE_HASH solution)
2300///
2301/// ; solution is (new_url new_metadata_updater_puzhash)
2302///
2303/// ; METADATA and METADATA_UPDATER_PUZZLE_HASH are passed in as truths from the layer above
2304/// ; This program returns ((new_metadata new_metadata_updater_puzhash) conditions)
2305///
2306/// ; NOTE THIS PROGRAM IS FOR TESTING ONLY - USE IN DEPLOYMENT AT YOUR OWN PERIL
2307///
2308/// ; once we find 'u' we don't need to continue looping
2309/// (defun add_url (METADATA new_url)
2310/// (if METADATA
2311/// (if (= (f (f METADATA)) 'u')
2312/// (c (c 'u' (c new_url (r (f METADATA)))) (r METADATA))
2313/// (c (f METADATA) (add_url (r METADATA) new_url))
2314/// )
2315/// ()
2316/// )
2317/// )
2318///
2319/// (defun-inline assert_bytes32 (value)
2320/// (= (strlen value) 32)
2321/// )
2322///
2323/// ; main
2324/// ; returns ((new_metadata new_metadata_updater_puzhash) conditions)
2325/// (list (list (if (f solution) (add_url CURRENT_METADATA (f solution)) CURRENT_METADATA) (if (assert_bytes32 (f (r solution))) (f (r solution)) METADATA_UPDATER_PUZZLE_HASH)) 0)
2326/// )
2327/// ```
2328pub const NFT_METADATA_UPDATER_UPDATEABLE: [u8; 203] = hex!("ff02ffff01ff04ffff04ffff02ffff03ff27ffff01ff02ff02ffff04ff02ffff04ff05ffff04ff27ff8080808080ffff010580ff0180ffff04ffff02ffff03ffff09ffff0dff5780ffff012080ffff0157ffff010b80ff0180ff808080ffff01ff808080ffff04ffff01ff02ffff03ff05ffff01ff02ffff03ffff09ff11ffff017580ffff01ff04ffff04ffff0175ffff04ff0bff198080ff0d80ffff01ff04ff09ffff02ff02ffff04ff02ffff04ff0dffff04ff0bff80808080808080ff0180ff8080ff0180ff018080");
2329pub const NFT_METADATA_UPDATER_UPDATEABLE_HASH: [u8; 32] =
2330 hex!("0b1ffba1601777c06b78ab38636e9624f2f8da73be9b36e0ce17c8d8ef3bad9f");
2331
2332/// ```text
2333/// (mod (
2334/// NFT_OWNERSHIP_LAYER_MOD_HASH
2335/// CURRENT_OWNER
2336/// TRANSFER_PROGRAM
2337/// INNER_PUZZLE
2338/// inner_solution
2339/// )
2340///
2341/// (include condition_codes.clib)
2342/// (include curry-and-treehash.clib)
2343/// (include utility_macros.clib)
2344///
2345/// (defconstant NEW_OWNER_CONDITION -10)
2346/// (defconstant ANNOUNCEMENT_PREFIX 0xad4c) ; first 2 bytes of (sha256 "Ownership Layer")
2347///
2348/// (defun-inline nft_ownership_layer_puzzle_hash (NFT_OWNERSHIP_LAYER_MOD_HASH new_owner TRANSFER_PROGRAM inner_puzzle_hash)
2349/// (puzzle-hash-of-curried-function NFT_OWNERSHIP_LAYER_MOD_HASH
2350/// inner_puzzle_hash
2351/// (sha256tree TRANSFER_PROGRAM)
2352/// (sha256 ONE new_owner)
2353/// (sha256 ONE NFT_OWNERSHIP_LAYER_MOD_HASH)
2354/// )
2355/// )
2356///
2357/// (defun construct_end_conditions (NFT_OWNERSHIP_LAYER_MOD_HASH TRANSFER_PROGRAM odd_args (new_owner new_tp conditions))
2358/// (c
2359/// (c
2360/// CREATE_COIN
2361/// (c
2362/// (nft_ownership_layer_puzzle_hash NFT_OWNERSHIP_LAYER_MOD_HASH new_owner (if new_tp new_tp TRANSFER_PROGRAM) (f odd_args))
2363/// (r odd_args)
2364/// )
2365/// )
2366/// conditions
2367/// )
2368/// )
2369///
2370/// (defun wrap_odd_create_coins (NFT_OWNERSHIP_LAYER_MOD_HASH TRANSFER_PROGRAM CURRENT_OWNER all_conditions conditions odd_args tp_output)
2371/// (if conditions
2372/// (if (= (f (f conditions)) CREATE_COIN)
2373/// (if (= (logand (f (r (r (f conditions))))) ONE)
2374/// (assert (not odd_args)
2375/// ; then
2376/// (wrap_odd_create_coins NFT_OWNERSHIP_LAYER_MOD_HASH TRANSFER_PROGRAM CURRENT_OWNER all_conditions (r conditions) (r (f conditions)) tp_output)
2377/// )
2378/// (c (f conditions) (wrap_odd_create_coins NFT_OWNERSHIP_LAYER_MOD_HASH TRANSFER_PROGRAM CURRENT_OWNER all_conditions (r conditions) odd_args tp_output))
2379/// )
2380/// (if (= (f (f conditions)) NEW_OWNER_CONDITION)
2381/// (assert (not tp_output)
2382/// (c
2383/// (list CREATE_PUZZLE_ANNOUNCEMENT (concat ANNOUNCEMENT_PREFIX (sha256tree (r (f conditions)))))
2384/// (wrap_odd_create_coins NFT_OWNERSHIP_LAYER_MOD_HASH TRANSFER_PROGRAM CURRENT_OWNER all_conditions (r conditions) odd_args (a TRANSFER_PROGRAM (list CURRENT_OWNER all_conditions (r (f conditions)))))
2385/// )
2386/// )
2387/// (if (= (f (f conditions)) CREATE_PUZZLE_ANNOUNCEMENT)
2388/// (assert (not (and
2389/// (= 34 (strlen (f (r (f conditions)))))
2390/// (= (substr (f (r (f conditions))) 0 2) ANNOUNCEMENT_PREFIX) ; lazy eval
2391/// ))
2392/// ; then
2393/// (c (f conditions) (wrap_odd_create_coins NFT_OWNERSHIP_LAYER_MOD_HASH TRANSFER_PROGRAM CURRENT_OWNER all_conditions (r conditions) odd_args tp_output))
2394/// )
2395/// (c (f conditions) (wrap_odd_create_coins NFT_OWNERSHIP_LAYER_MOD_HASH TRANSFER_PROGRAM CURRENT_OWNER all_conditions (r conditions) odd_args tp_output))
2396/// )
2397/// )
2398/// )
2399/// ; odd_args is guaranteed to not be nil or else we'll have a path into atom error
2400/// (construct_end_conditions NFT_OWNERSHIP_LAYER_MOD_HASH TRANSFER_PROGRAM odd_args
2401/// (if tp_output
2402/// tp_output
2403/// (a TRANSFER_PROGRAM (list CURRENT_OWNER all_conditions ()))
2404/// )
2405/// )
2406/// )
2407/// )
2408///
2409/// (defun main (
2410/// NFT_OWNERSHIP_LAYER_MOD_HASH
2411/// TRANSFER_PROGRAM
2412/// CURRENT_OWNER
2413/// conditions
2414/// )
2415/// (wrap_odd_create_coins
2416/// NFT_OWNERSHIP_LAYER_MOD_HASH
2417/// TRANSFER_PROGRAM
2418/// CURRENT_OWNER
2419/// conditions
2420/// conditions
2421/// () ()
2422/// )
2423/// )
2424///
2425/// ; main
2426/// (main
2427/// NFT_OWNERSHIP_LAYER_MOD_HASH
2428/// TRANSFER_PROGRAM
2429/// CURRENT_OWNER
2430/// (a INNER_PUZZLE inner_solution)
2431/// )
2432/// )
2433/// ```
2434pub const NFT_OWNERSHIP_LAYER: [u8; 1226] = hex!("ff02ffff01ff02ff26ffff04ff02ffff04ff05ffff04ff17ffff04ff0bffff04ffff02ff2fff5f80ff80808080808080ffff04ffff01ffffff82ad4cff0233ffff3e04ff81f601ffffff0102ffff02ffff03ff05ffff01ff02ff2affff04ff02ffff04ff0dffff04ffff0bff32ffff0bff3cff3480ffff0bff32ffff0bff32ffff0bff3cff2280ff0980ffff0bff32ff0bffff0bff3cff8080808080ff8080808080ffff010b80ff0180ff04ffff04ff38ffff04ffff02ff36ffff04ff02ffff04ff05ffff04ff27ffff04ffff02ff2effff04ff02ffff04ffff02ffff03ff81afffff0181afffff010b80ff0180ff80808080ffff04ffff0bff3cff4f80ffff04ffff0bff3cff0580ff8080808080808080ff378080ff82016f80ffffff02ff3effff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ff2fffff04ff2fffff01ff80ff808080808080808080ff0bff32ffff0bff3cff2880ffff0bff32ffff0bff32ffff0bff3cff2280ff0580ffff0bff32ffff02ff2affff04ff02ffff04ff07ffff04ffff0bff3cff3c80ff8080808080ffff0bff3cff8080808080ffff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff2effff04ff02ffff04ff09ff80808080ffff02ff2effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff02ffff03ff5fffff01ff02ffff03ffff09ff82011fff3880ffff01ff02ffff03ffff09ffff18ff82059f80ff3c80ffff01ff02ffff03ffff20ff81bf80ffff01ff02ff3effff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ff2fffff04ff81dfffff04ff82019fffff04ff82017fff80808080808080808080ffff01ff088080ff0180ffff01ff04ff819fffff02ff3effff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ff2fffff04ff81dfffff04ff81bfffff04ff82017fff808080808080808080808080ff0180ffff01ff02ffff03ffff09ff82011fff2c80ffff01ff02ffff03ffff20ff82017f80ffff01ff04ffff04ff24ffff04ffff0eff10ffff02ff2effff04ff02ffff04ff82019fff8080808080ff808080ffff02ff3effff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ff2fffff04ff81dfffff04ff81bfffff04ffff02ff0bffff04ff17ffff04ff2fffff04ff82019fff8080808080ff8080808080808080808080ffff01ff088080ff0180ffff01ff02ffff03ffff09ff82011fff2480ffff01ff02ffff03ffff20ffff02ffff03ffff09ffff0122ffff0dff82029f8080ffff01ff02ffff03ffff09ffff0cff82029fff80ffff010280ff1080ffff01ff0101ff8080ff0180ff8080ff018080ffff01ff04ff819fffff02ff3effff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ff2fffff04ff81dfffff04ff81bfffff04ff82017fff8080808080808080808080ffff01ff088080ff0180ffff01ff04ff819fffff02ff3effff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ff2fffff04ff81dfffff04ff81bfffff04ff82017fff808080808080808080808080ff018080ff018080ff0180ffff01ff02ff3affff04ff02ffff04ff05ffff04ff0bffff04ff81bfffff04ffff02ffff03ff82017fffff0182017fffff01ff02ff0bffff04ff17ffff04ff2fffff01ff808080808080ff0180ff8080808080808080ff0180ff018080");
2435pub const NFT_OWNERSHIP_LAYER_HASH: [u8; 32] =
2436 hex!("c5abea79afaa001b5427dfa0c8cf42ca6f38f5841b78f9b3c252733eb2de2726");
2437
2438/// ```text
2439/// (mod
2440/// (
2441/// SINGLETON_STRUCT
2442/// ROYALTY_ADDRESS
2443/// TRADE_PRICE_PERCENTAGE
2444/// Current_Owner ; Truth
2445/// conditions ; Truth
2446/// solution ; created from the NFT's inner puzzle - solution is (new_owner trade_prices_list new_did_inner_hash)
2447/// )
2448///
2449/// ; This is a transfer program - which must return (new_owner, Optional[new_transfer_program], conditions)
2450///
2451/// (include condition_codes.clib)
2452/// (include curry-and-treehash.clib)
2453///
2454/// (defconstant TEN_THOUSAND 10000)
2455///
2456/// ;; return the full puzzlehash for a singleton with the innerpuzzle curried in
2457/// ; puzzle-hash-of-curried-function is imported from curry-and-treehash.clib
2458/// (defun-inline calculate_full_puzzle_hash (SINGLETON_STRUCT inner_puzzle_hash)
2459/// (puzzle-hash-of-curried-function (f SINGLETON_STRUCT)
2460/// inner_puzzle_hash
2461/// (sha256tree SINGLETON_STRUCT)
2462/// )
2463/// )
2464///
2465/// ; Given a singleton ID, generate the singleton struct
2466/// (defun-inline get_singleton_struct (SINGLETON_STRUCT singleton_id)
2467/// (c (f SINGLETON_STRUCT) (c singleton_id (r (r SINGLETON_STRUCT))))
2468/// )
2469///
2470/// (defun-inline calculate_percentage (amount percentage)
2471/// (f (divmod (* amount percentage) TEN_THOUSAND))
2472/// )
2473///
2474/// ; Loop of the trade prices list and either assert a puzzle announcement or generate xck
2475/// (defun parse_trade_prices_list (ROYALTY_ADDRESS TRADE_PRICE_PERCENTAGE trade_prices_list my_nft_id)
2476/// (if trade_prices_list
2477/// (c
2478/// (list
2479/// ASSERT_PUZZLE_ANNOUNCEMENT
2480/// (sha256
2481/// (f (r (f trade_prices_list)))
2482/// (sha256tree (c my_nft_id (list (list ROYALTY_ADDRESS (calculate_percentage (f (f trade_prices_list)) TRADE_PRICE_PERCENTAGE) (list ROYALTY_ADDRESS)))))
2483/// )
2484/// )
2485/// (parse_trade_prices_list ROYALTY_ADDRESS TRADE_PRICE_PERCENTAGE (r trade_prices_list) my_nft_id)
2486/// )
2487/// ()
2488/// )
2489/// )
2490///
2491/// ; main
2492/// ; Returning (new_owner new_transfer_program conditions)
2493/// ; solution is (new_owner trade_prices_list new_did_inner_hash)
2494/// (if solution
2495/// (list
2496/// (f solution)
2497/// 0
2498/// (if (all (f solution) (not (= (f solution) Current_Owner)))
2499/// (c
2500/// (list
2501/// ASSERT_PUZZLE_ANNOUNCEMENT
2502/// (sha256
2503/// (calculate_full_puzzle_hash (get_singleton_struct SINGLETON_STRUCT (f solution)) (f (r (r solution))))
2504/// (f (r SINGLETON_STRUCT))
2505/// )
2506/// )
2507/// (parse_trade_prices_list ROYALTY_ADDRESS TRADE_PRICE_PERCENTAGE (f (r solution)) (f (r SINGLETON_STRUCT)))
2508/// )
2509/// (parse_trade_prices_list ROYALTY_ADDRESS TRADE_PRICE_PERCENTAGE (f (r solution)) (f (r SINGLETON_STRUCT)))
2510/// )
2511/// )
2512/// (list Current_Owner () ())
2513/// )
2514///
2515///
2516/// )
2517/// ```
2518pub const NFT_OWNERSHIP_TRANSFER_PROGRAM_ONE_WAY_CLAIM_WITH_ROYALTIES: [u8; 687] = hex!("ff02ffff01ff02ffff03ff81bfffff01ff04ff82013fffff04ff80ffff04ffff02ffff03ffff22ff82013fffff20ffff09ff82013fff2f808080ffff01ff04ffff04ff10ffff04ffff0bffff02ff2effff04ff02ffff04ff09ffff04ff8205bfffff04ffff02ff3effff04ff02ffff04ffff04ff09ffff04ff82013fff1d8080ff80808080ff808080808080ff1580ff808080ffff02ff16ffff04ff02ffff04ff0bffff04ff17ffff04ff8202bfffff04ff15ff8080808080808080ffff01ff02ff16ffff04ff02ffff04ff0bffff04ff17ffff04ff8202bfffff04ff15ff8080808080808080ff0180ff80808080ffff01ff04ff2fffff01ff80ff80808080ff0180ffff04ffff01ffffff3f02ff04ff0101ffff822710ff02ff02ffff03ff05ffff01ff02ff3affff04ff02ffff04ff0dffff04ffff0bff2affff0bff2cff1480ffff0bff2affff0bff2affff0bff2cff3c80ff0980ffff0bff2aff0bffff0bff2cff8080808080ff8080808080ffff010b80ff0180ffff02ffff03ff17ffff01ff04ffff04ff10ffff04ffff0bff81a7ffff02ff3effff04ff02ffff04ffff04ff2fffff04ffff04ff05ffff04ffff05ffff14ffff12ff47ff0b80ff128080ffff04ffff04ff05ff8080ff80808080ff808080ff8080808080ff808080ffff02ff16ffff04ff02ffff04ff05ffff04ff0bffff04ff37ffff04ff2fff8080808080808080ff8080ff0180ffff0bff2affff0bff2cff1880ffff0bff2affff0bff2affff0bff2cff3c80ff0580ffff0bff2affff02ff3affff04ff02ffff04ff07ffff04ffff0bff2cff2c80ff8080808080ffff0bff2cff8080808080ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff3effff04ff02ffff04ff09ff80808080ffff02ff3effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080");
2519pub const NFT_OWNERSHIP_TRANSFER_PROGRAM_ONE_WAY_CLAIM_WITH_ROYALTIES_HASH: [u8; 32] =
2520 hex!("025dee0fb1e9fa110302a7e9bfb6e381ca09618e2778b0184fa5c6b275cfce1f");
2521
2522/// ```text
2523/// (mod (
2524/// NFT_STATE_LAYER_MOD_HASH
2525/// METADATA
2526/// METADATA_UPDATER_PUZZLE_HASH
2527/// INNER_PUZZLE
2528/// inner_solution
2529/// )
2530///
2531/// (include condition_codes.clib)
2532/// (include curry-and-treehash.clib)
2533/// (include utility_macros.clib)
2534///
2535/// (defun-inline nft_state_layer_puzzle_hash (NFT_STATE_LAYER_MOD_HASH METADATA METADATA_UPDATER_PUZZLE_HASH inner_puzzle_hash)
2536/// (puzzle-hash-of-curried-function NFT_STATE_LAYER_MOD_HASH
2537/// inner_puzzle_hash
2538/// (sha256 ONE METADATA_UPDATER_PUZZLE_HASH)
2539/// (sha256tree METADATA)
2540/// (sha256 ONE NFT_STATE_LAYER_MOD_HASH)
2541/// )
2542/// )
2543///
2544///
2545/// ; this function does two things - it wraps the odd value create coins, and it also filters out all negative conditions
2546/// ; odd_coin_params is (puzhash amount ...)
2547/// ; new_metadata_info is ((METADATA METADATA_UPDATER_PUZZLE_HASH) conditions)
2548/// (defun wrap_odd_create_coins (NFT_STATE_LAYER_MOD_HASH conditions odd_coin_params new_metadata_info metadata_seen)
2549/// (if conditions
2550/// (if (= (f (f conditions)) CREATE_COIN)
2551/// (if (logand (f (r (r (f conditions)))) ONE)
2552/// (assert (not odd_coin_params)
2553/// (wrap_odd_create_coins NFT_STATE_LAYER_MOD_HASH (r conditions) (r (f conditions)) new_metadata_info metadata_seen)
2554/// )
2555/// (c (f conditions) (wrap_odd_create_coins NFT_STATE_LAYER_MOD_HASH (r conditions) odd_coin_params new_metadata_info metadata_seen))
2556/// )
2557/// (if (= (f (f conditions)) -24)
2558/// (wrap_odd_create_coins NFT_STATE_LAYER_MOD_HASH (r conditions) odd_coin_params
2559/// (assert (all
2560/// (= (sha256tree (f (r (f conditions)))) (f (r (f new_metadata_info))))
2561/// (not metadata_seen)
2562/// )
2563/// ; then
2564/// (a (f (r (f conditions))) (list (f (f new_metadata_info)) (f (r (f new_metadata_info))) (f (r (r (f conditions))))))
2565/// )
2566/// ONE ; the metadata update has been seen now
2567/// )
2568/// (c (f conditions) (wrap_odd_create_coins NFT_STATE_LAYER_MOD_HASH (r conditions) odd_coin_params new_metadata_info metadata_seen))
2569/// )
2570/// )
2571/// (c
2572/// (c CREATE_COIN
2573/// (c
2574/// (nft_state_layer_puzzle_hash
2575/// NFT_STATE_LAYER_MOD_HASH
2576/// (f (f new_metadata_info))
2577/// (f (r (f new_metadata_info)))
2578/// (f odd_coin_params) ; metadata updater solution
2579/// )
2580/// (r odd_coin_params)
2581/// )
2582/// )
2583/// (f (r new_metadata_info)) ; metadata_updater conditions
2584/// )
2585/// )
2586/// )
2587///
2588/// ; main
2589/// (wrap_odd_create_coins
2590/// NFT_STATE_LAYER_MOD_HASH
2591/// (a INNER_PUZZLE inner_solution)
2592/// ()
2593/// (list (list METADATA METADATA_UPDATER_PUZZLE_HASH) 0) ; if the magic condition is never seen, this is the information we us to recurry
2594/// ()
2595/// )
2596/// )
2597/// ```
2598pub const NFT_STATE_LAYER: [u8; 827] = hex!("ff02ffff01ff02ff3effff04ff02ffff04ff05ffff04ffff02ff2fff5f80ffff04ff80ffff04ffff04ffff04ff0bffff04ff17ff808080ffff01ff808080ffff01ff8080808080808080ffff04ffff01ffffff0233ff04ff0101ffff02ff02ffff03ff05ffff01ff02ff1affff04ff02ffff04ff0dffff04ffff0bff12ffff0bff2cff1480ffff0bff12ffff0bff12ffff0bff2cff3c80ff0980ffff0bff12ff0bffff0bff2cff8080808080ff8080808080ffff010b80ff0180ffff0bff12ffff0bff2cff1080ffff0bff12ffff0bff12ffff0bff2cff3c80ff0580ffff0bff12ffff02ff1affff04ff02ffff04ff07ffff04ffff0bff2cff2c80ff8080808080ffff0bff2cff8080808080ffff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff2effff04ff02ffff04ff09ff80808080ffff02ff2effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff02ffff03ff0bffff01ff02ffff03ffff09ff23ff1880ffff01ff02ffff03ffff18ff81b3ff2c80ffff01ff02ffff03ffff20ff1780ffff01ff02ff3effff04ff02ffff04ff05ffff04ff1bffff04ff33ffff04ff2fffff04ff5fff8080808080808080ffff01ff088080ff0180ffff01ff04ff13ffff02ff3effff04ff02ffff04ff05ffff04ff1bffff04ff17ffff04ff2fffff04ff5fff80808080808080808080ff0180ffff01ff02ffff03ffff09ff23ffff0181e880ffff01ff02ff3effff04ff02ffff04ff05ffff04ff1bffff04ff17ffff04ffff02ffff03ffff22ffff09ffff02ff2effff04ff02ffff04ff53ff80808080ff82014f80ffff20ff5f8080ffff01ff02ff53ffff04ff818fffff04ff82014fffff04ff81b3ff8080808080ffff01ff088080ff0180ffff04ff2cff8080808080808080ffff01ff04ff13ffff02ff3effff04ff02ffff04ff05ffff04ff1bffff04ff17ffff04ff2fffff04ff5fff80808080808080808080ff018080ff0180ffff01ff04ffff04ff18ffff04ffff02ff16ffff04ff02ffff04ff05ffff04ff27ffff04ffff0bff2cff82014f80ffff04ffff02ff2effff04ff02ffff04ff818fff80808080ffff04ffff0bff2cff0580ff8080808080808080ff378080ff81af8080ff0180ff018080");
2599pub const NFT_STATE_LAYER_HASH: [u8; 32] =
2600 hex!("a04d9f57764f54a43e4030befb4d80026e870519aaa66334aef8304f5d0393c2");
2601
2602/// ```text
2603/// (mod (CONDITIONS nonce)
2604/// (c (list 60 nonce) CONDITIONS)
2605/// )
2606/// ```
2607pub const CONDITIONS_W_FEE_ANNOUNCE: [u8; 21] = hex!("ff04ffff04ffff013cffff04ff05ff808080ff0280");
2608pub const CONDITIONS_W_FEE_ANNOUNCE_HASH: [u8; 32] =
2609 hex!("1a169582dc619f2542f8eb79f02823e1595ba0aca53820f503eda5ff20b47856");
2610
2611/// ```text
2612/// ; This is an outer puzzle for a coin that imposes a restriction that the coin can only be spent with an
2613/// ; announcement from a "verified credential" whose proofs are present due to a DID in a list of authorized providers.
2614///
2615/// ; A "verified credential" is defined as the following puzzle stack:
2616/// ; - singleton top layer
2617/// ; |_exigent metadata layer
2618/// ; |_eml transfer program covenant adapter
2619/// ; | |_covenant layer
2620/// ; | |_initial puzzle (hashed)
2621/// ; | | |_singleton top layer
2622/// ; | | |_exigent metadata layer
2623/// ; | | |_(mod (_ _ (provider tp)) (list (c provider ()) tp ())) (guaranteed metadata to be nil)
2624/// ; | | |_p2 announced delegated puzzle
2625/// ; | |_eml covenant morpher
2626/// ; | |_eml update metadata with DID
2627/// ; |_<inner puzzle>
2628/// ; The information to construct a VC is contained in a highly optimized way within CREDENTIAL_STRUCT
2629/// ;
2630/// ; This puzzle does many things:
2631/// ; - Tree hash of a partially revealed tree to come to a proof hash present in the accompanying VC singleton
2632/// ; - Validate the revealed proofs with a curried proofs checker
2633/// ; - Assert an announcement from a VC with a message of 0xca which signals this spend is ok
2634/// ; - Wrap all of its children in this layer
2635/// ; - Create an announcement in the 0xcd namespace of each output it is creating (for a VC to assert if it wishes)
2636/// ; - Block any announcements coming from the inner puzzle in the 0xcd namespace
2637/// (mod
2638/// (
2639/// ; We curry twice: first, all of the static information we need, then the hash of the program with all of that info
2640/// ; this allows use to be more efficient when calculating our own hash (a (q . SELF_HASH) (c SELF_HASH (x INNER_PUZZLE 1)))
2641/// ; curried first
2642/// CREDENTIAL_STRUCT
2643/// AUTHORIZED_PROVIDERS
2644/// PROOFS_CHECKER
2645/// ; curried second
2646/// SELF_HASH
2647/// INNER_PUZZLE
2648/// proof_of_inclusions ; Proof that key/value pairs exist in a tree (the root of the tree is implicit from this)
2649/// proof_checker_solution ; solution to PROOFS_CHECKER program
2650/// provider_id ; the DID that is curried into the metadata of the VC that is authorizing this coin
2651/// credential_id ; the launcher ID of the VC that is authorizing this coin
2652/// credential_inner_puzhash ; The <inner puzzle> (see above) of the VC that is authorizing this coin
2653/// my_coin_id ; This coin's ID
2654/// inner_solution
2655/// )
2656///
2657/// (include curry.clib)
2658/// (include condition_codes.clib)
2659/// (include utility_macros.clib)
2660///
2661/// ; take two lists and merge them into one
2662/// (defun merge_list (list_a list_b)
2663/// (if list_a
2664/// (c (f list_a) (merge_list (r list_a) list_b))
2665/// list_b
2666/// )
2667/// )
2668///
2669/// (defconstant announcement_namespace 0xcd)
2670/// (defconstant ONE 1)
2671///
2672/// (defun-inline wrap_puzhash
2673/// (
2674/// SELF_HASH
2675/// puzhash
2676/// )
2677///
2678/// (curry_hashes SELF_HASH
2679/// (sha256 ONE SELF_HASH)
2680/// puzhash
2681/// )
2682/// )
2683///
2684/// ; Does three things:
2685/// ; 1) Wraps create coins with this layer
2686/// ; 2) Announces those create coins in a namespace
2687/// ; 3) Raises on announcements from the inner puzzle that could possibly be in the namespace
2688/// (defun process_conditions
2689/// (
2690/// SELF_HASH
2691/// conditions
2692/// )
2693/// (if conditions
2694/// (if (= (f (f conditions)) CREATE_COIN)
2695/// (c
2696/// (list
2697/// CREATE_COIN_ANNOUNCEMENT
2698/// (concat
2699/// announcement_namespace
2700/// (sha256 (f (r (f conditions))) (f (r (r (f conditions)))))
2701/// )
2702/// )
2703/// (c
2704/// (c
2705/// CREATE_COIN
2706/// (c
2707/// (wrap_puzhash SELF_HASH (f (r (f conditions))))
2708/// (r (r (f conditions)))
2709/// )
2710/// )
2711/// (process_conditions SELF_HASH (r conditions))
2712/// )
2713/// )
2714/// ; else - not a create coin
2715/// (assert (or
2716/// (not (= (f (f conditions)) CREATE_COIN_ANNOUNCEMENT)) ; some coin announcements should be blocked
2717/// (not (= 33 (strlen (f (r (f conditions)))))) ; we only care about blocking 0xcd + some_hash
2718/// (not (= announcement_namespace (substr (f (r (f conditions))) 0 ONE))) ; block prefix 0xcd
2719/// )
2720/// ; then
2721/// (c
2722/// (f conditions)
2723/// (process_conditions SELF_HASH (r conditions))
2724/// )
2725/// )
2726/// )
2727/// ; else - end of list
2728/// ()
2729/// )
2730/// )
2731///
2732/// (defun create_vc_puzhash_stage_2
2733/// (
2734/// (
2735/// (
2736/// (
2737/// SINGLETON_MOD_HASH
2738/// .
2739/// SINGLETON_LAUNCHER_HASH
2740/// )
2741/// .
2742/// (
2743/// OWNERSHIP_LAYER_MOD_HASH
2744/// .
2745/// ADAPTER_MOD_HASH
2746/// )
2747/// )
2748/// .
2749/// (
2750/// INITIAL_SINGLETON_INNER_PUZHASH
2751/// .
2752/// (
2753/// TWO_AND_COVENANT_MOD_HASH ; (concat 2 COVENANT_MOD_HASH)
2754/// .
2755/// REST_COVENANT_ARGS_HASH ; ((c PARENT_MORPHER (c EML_DID_TP 1)) . ()) hashed
2756/// )
2757/// )
2758/// )
2759/// provider_id
2760/// credential_singleton_struct_hash
2761/// proof_hash
2762/// credential_inner_puzhash
2763/// tp_hash
2764/// )
2765///
2766/// (curry_hashes SINGLETON_MOD_HASH
2767/// credential_singleton_struct_hash
2768/// (curry_hashes OWNERSHIP_LAYER_MOD_HASH
2769/// (sha256 ONE OWNERSHIP_LAYER_MOD_HASH)
2770/// (sha256 TWO
2771/// (sha256 ONE provider_id)
2772/// (sha256 ONE proof_hash)
2773/// )
2774/// tp_hash
2775/// (sha256 ONE tp_hash)
2776/// credential_inner_puzhash
2777/// )
2778/// )
2779/// )
2780///
2781/// (defun create_vc_puzhash
2782/// (
2783/// CREDENTIAL_STRUCT
2784/// provider_id
2785/// credential_singleton_struct_hash
2786/// proof_hash
2787/// credential_inner_puzhash
2788/// )
2789///
2790/// (create_vc_puzhash_stage_2
2791/// CREDENTIAL_STRUCT
2792/// provider_id
2793/// credential_singleton_struct_hash
2794/// proof_hash
2795/// credential_inner_puzhash
2796/// (curry_hashes (r (r (f CREDENTIAL_STRUCT))) ; ADAPTER_MOD_HASH
2797/// (sha256
2798/// ; apply
2799/// (two_sha256_one_a_kw)
2800/// (sha256
2801/// ; func
2802/// (f (r (r CREDENTIAL_STRUCT))) ; TWO_AND_COVENANT_MOD_HASH
2803/// (sha256 TWO
2804/// ; args
2805/// (sha256
2806/// (two_sha256_one_c_kw)
2807/// (sha256 TWO
2808/// (sha256 TWO
2809/// (sha256_one_one)
2810/// (sha256 ONE (curry_hashes (f (f (f CREDENTIAL_STRUCT))) ; SINGLETON_MOD_HASH
2811/// credential_singleton_struct_hash
2812/// (f (r CREDENTIAL_STRUCT)) ; INITIAL_SINGLETON_INNER_PUZHASH
2813/// ))
2814/// )
2815/// (r (r (r CREDENTIAL_STRUCT))) ; REST_COVENANT_ARGS_HASH
2816/// )
2817/// )
2818/// (sha256_one)
2819/// )
2820/// )
2821/// )
2822/// )
2823/// )
2824/// )
2825///
2826/// ; utility function that turns the output of two calls to collapse_tree_and_note_leaf_info into a single return value
2827/// (defun branch_hash_and_merge_info ((TREE1 PROOFS1) (TREE2 PROOFS2))
2828/// (list
2829/// (sha256 TWO TREE1 TREE2)
2830/// (merge_list PROOFS1 PROOFS2)
2831/// )
2832/// )
2833///
2834/// (defun collapse_tree_and_note_leaf_info (TREE PROOFS)
2835/// (if (l TREE)
2836/// (if (or (l (f TREE)) (l (r TREE))) ; If either side is a cons, we have not reached a leaf pair yet
2837/// (branch_hash_and_merge_info
2838/// (collapse_tree_and_note_leaf_info (f TREE) ())
2839/// ; we favor right because merge_list merges from left
2840/// (collapse_tree_and_note_leaf_info (r TREE) PROOFS)
2841/// )
2842/// ; else - both first and rest are atoms, we are at a key/value pair
2843/// (branch_hash_and_merge_info
2844/// (list (sha256 ONE (f TREE)) ())
2845/// (list (sha256 ONE (r TREE)) (c TREE PROOFS))
2846/// )
2847/// )
2848/// (list TREE PROOFS) ; All atoms that we reach must be pre-hashed subtrees
2849/// )
2850/// )
2851///
2852/// (defun main
2853/// (
2854/// CREDENTIAL_STRUCT
2855/// AUTHORIZED_PROVIDERS
2856/// PROOFS_CHECKER
2857/// SELF_HASH
2858/// proof_checker_solution
2859/// provider_id
2860/// credential_id
2861/// credential_inner_puzhash
2862/// my_coin_id
2863/// conditions
2864/// (tree_hash proofs)
2865/// )
2866///
2867/// (assert
2868/// ; Run proof checker to make sure it doesn't return () (fail)
2869/// (a PROOFS_CHECKER (list proofs proof_checker_solution))
2870/// (in provider_id AUTHORIZED_PROVIDERS) ; VC needs to be in authorized list
2871/// ; then
2872/// (c
2873/// (list ASSERT_MY_COIN_ID my_coin_id)
2874/// (c
2875/// (list ASSERT_PUZZLE_ANNOUNCEMENT
2876/// (sha256
2877/// (create_vc_puzhash
2878/// CREDENTIAL_STRUCT
2879/// provider_id
2880/// (sha256 TWO
2881/// (sha256 ONE (f (f (f CREDENTIAL_STRUCT)))) ; SINGLETON_MOD_HASH
2882/// (sha256 TWO
2883/// (sha256 ONE credential_id)
2884/// (sha256 ONE (r (f (f CREDENTIAL_STRUCT)))) ; SINGLETON_LAUNCHER_HASH
2885/// )
2886/// )
2887/// tree_hash
2888/// credential_inner_puzhash
2889/// )
2890/// (sha256 my_coin_id 0xca) ; my_coin_id because VC must announce specifically to us
2891/// )
2892/// )
2893/// (process_conditions
2894/// SELF_HASH
2895/// conditions
2896/// )
2897/// )
2898/// )
2899/// )
2900/// )
2901///
2902/// (main
2903/// CREDENTIAL_STRUCT
2904/// AUTHORIZED_PROVIDERS
2905/// PROOFS_CHECKER
2906/// SELF_HASH
2907/// proof_checker_solution
2908/// provider_id
2909/// credential_id
2910/// credential_inner_puzhash
2911/// my_coin_id
2912/// (a INNER_PUZZLE inner_solution)
2913/// (collapse_tree_and_note_leaf_info proof_of_inclusions ())
2914/// )
2915/// )
2916/// ```
2917pub const CREDENTIAL_RESTRICTION: [u8; 1648] = hex!("ff02ffff01ff02ff2effff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ff2fffff04ff82017fffff04ff8202ffffff04ff8205ffffff04ff820bffffff04ff8217ffffff04ffff02ff5fff822fff80ffff04ffff02ff22ffff04ff02ffff04ff81bfffff01ff8080808080ff8080808080808080808080808080ffff04ffff01ffffffff463fff333cffff0102ff81cdffff04ffff0bff34ff09ff1380ffff04ffff02ff5effff04ff02ffff04ff15ffff04ff2bff8080808080ff808080ff02ffff03ff05ffff01ff0bff81f2ffff02ff26ffff04ff02ffff04ff09ffff04ffff02ff7cffff04ff02ffff04ff0dff80808080ff808080808080ffff0181d280ff0180ffffffff02ffff03ffff07ff0580ffff01ff02ffff03ffff02ffff03ffff07ff0980ffff01ff0101ffff01ff02ffff03ffff07ff0d80ffff01ff0101ff8080ff018080ff0180ffff01ff02ff5cffff04ff02ffff04ffff02ff22ffff04ff02ffff04ff09ffff01ff8080808080ffff04ffff02ff22ffff04ff02ffff04ff0dffff04ff0bff8080808080ff8080808080ffff01ff02ff5cffff04ff02ffff04ffff04ffff0bff24ff0980ffff01ff808080ffff04ffff04ffff0bff24ff0d80ffff04ffff04ff05ff0b80ff808080ff808080808080ff0180ffff01ff04ff05ffff04ff0bff80808080ff0180ffffa04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459aa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ffa102a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222a102a8d5dd63fba471ebcb1f3e8f7c1e1879b7152a6e7298a91ce119a63400ade7c5ffff02ff5affff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ffff02ff7affff04ff02ffff04ff39ffff04ffff0bff81b2ffff0bff2dffff0bff34ffff0bff81f2ffff0bff34ffff0bff34ff81d2ffff0bff24ffff02ff7affff04ff02ffff04ff21ffff04ff17ffff04ff15ff8080808080808080ff3d8080ff8192808080ff8080808080ff808080808080808080ffff02ff7affff04ff02ffff04ff21ffff04ff17ffff04ffff02ff7affff04ff02ffff04ff29ffff04ffff0bff24ff2980ffff04ffff0bff34ffff0bff24ff0b80ffff0bff24ff2f8080ffff04ff81bfffff04ffff0bff24ff81bf80ffff04ff5fff808080808080808080ff808080808080ff0bff81b2ffff02ff26ffff04ff02ffff04ff05ffff04ffff02ff7cffff04ff02ffff04ff07ff80808080ff808080808080ffffff0bff34ffff0bff34ff81d2ff0580ffff0bff34ff0bff81928080ff02ffff03ff0bffff01ff03ffff09ff05ff1380ffff0101ffff02ff36ffff04ff02ffff04ff05ffff04ff1bff808080808080ff8080ff0180ffff02ffff03ffff02ff17ffff04ff8257ffffff04ff5fff80808080ffff01ff02ffff03ffff02ff36ffff04ff02ffff04ff81bfffff04ff0bff8080808080ffff01ff04ffff04ff20ffff04ff8205ffff808080ffff04ffff04ff30ffff04ffff0bffff02ff2affff04ff02ffff04ff05ffff04ff81bfffff04ffff0bff34ffff0bff24ff2180ffff0bff34ffff0bff24ff82017f80ffff0bff24ff31808080ffff04ff8227ffffff04ff8202ffff8080808080808080ffff0bff8205ffffff0181ca8080ff808080ffff02ff7effff04ff02ffff04ff2fffff04ff820bffff80808080808080ffff01ff088080ff0180ffff01ff088080ff0180ffff02ffff03ff05ffff01ff04ff09ffff02ff5effff04ff02ffff04ff0dffff04ff0bff808080808080ffff010b80ff0180ff02ffff03ff0bffff01ff02ffff03ffff09ff23ff2880ffff01ff04ffff04ff38ffff04ffff0eff2cffff0bff53ff81b38080ff808080ffff04ffff04ff28ffff04ffff02ff7affff04ff02ffff04ff05ffff04ffff0bff24ff0580ffff04ff53ff808080808080ff738080ffff02ff7effff04ff02ffff04ff05ffff04ff1bff80808080808080ffff01ff02ffff03ffff02ffff03ffff20ffff09ff23ff388080ffff01ff0101ffff01ff02ffff03ffff20ffff09ffff0121ffff0dff53808080ffff01ff0101ffff01ff02ffff03ffff20ffff09ff2cffff0cff53ff80ff24808080ffff01ff0101ff8080ff018080ff018080ff0180ffff01ff04ff13ffff02ff7effff04ff02ffff04ff05ffff04ff1bff808080808080ffff01ff088080ff018080ff0180ff8080ff0180ff018080");
2918pub const CREDENTIAL_RESTRICTION_HASH: [u8; 32] =
2919 hex!("2fdfc1f058cfd65e7ec4e253bfeb394da163ecd0036f508df8629b0a2b8fde96");
2920
2921/// ```text
2922/// ; This is a PROOFS_CHECKER for use with credential_restriction.clsp
2923/// ;
2924/// ; In an attempt to be as simple as possible, this puzzle is curried a list of key/value pairs sorted by keys. This sort
2925/// ; is crucial to the program functioning as the key/value pairs of the proofs will be sorted before being compared to
2926/// ; the curried list.
2927/// (mod
2928/// (
2929/// FLAGS ; must be sorted
2930/// proofs ; will be sorted
2931/// solution ; unused
2932/// )
2933///
2934/// (include utility_macros.clib)
2935///
2936/// (defun insertion_sort_by_keys (sorted insertions)
2937/// (if insertions
2938/// (if (or (not sorted) (>s (f (f insertions)) (f (f sorted))))
2939/// (insertion_sort_by_keys (c (f insertions) sorted) (r insertions))
2940/// (insertion_sort_by_keys (c (f sorted) (insertion_sort_by_keys (r sorted) (list (f insertions)))) (r insertions))
2941/// )
2942/// sorted
2943/// )
2944/// )
2945///
2946/// (defun merge_insertion_sort (proofs)
2947/// (if (r proofs)
2948/// (insertion_sort_by_keys (merge_insertion_sort (r proofs)) (merge_insertion_sort (list (f proofs))))
2949/// proofs
2950/// )
2951/// )
2952///
2953/// ; This function checks that the revealed proofs START WITH the same key/value pairs as are in FLAGS. This is not for
2954/// ; any particular reason except optimization. We don't really care if EXTRA proof pairs are revealed.
2955/// (defun compare_first_pairs_against_flags (subject comp)
2956/// (if subject
2957/// (if (logand (= (f (f subject)) (f (f comp))) (= (r (f subject)) (r (f comp))))
2958/// (compare_first_pairs_against_flags (r subject) (r comp))
2959/// ()
2960/// )
2961/// 1
2962/// )
2963/// )
2964///
2965/// (compare_first_pairs_against_flags FLAGS (merge_insertion_sort proofs))
2966/// )
2967/// ```
2968pub const FLAG_PROOFS_CHECKER: [u8; 399] = hex!("ff02ffff01ff02ff04ffff04ff02ffff04ff05ffff04ffff02ff0effff04ff02ffff04ff0bff80808080ff8080808080ffff04ffff01ffff02ffff03ff05ffff01ff02ffff03ffff18ffff09ff11ff2380ffff09ff19ff338080ffff01ff02ff04ffff04ff02ffff04ff0dffff04ff1bff8080808080ff8080ff0180ffff01ff010180ff0180ffff02ffff03ff0bffff01ff02ffff03ffff02ffff03ffff20ff0580ffff01ff0101ffff01ff02ffff03ffff0aff23ff1180ffff01ff0101ff8080ff018080ff0180ffff01ff02ff0affff04ff02ffff04ffff04ff13ff0580ffff04ff1bff8080808080ffff01ff02ff0affff04ff02ffff04ffff04ff09ffff02ff0affff04ff02ffff04ff0dffff04ffff04ff13ff8080ff808080808080ffff04ff1bff808080808080ff0180ffff010580ff0180ff02ffff03ff0dffff01ff02ff0affff04ff02ffff04ffff02ff0effff04ff02ffff04ff0dff80808080ffff04ffff02ff0effff04ff02ffff04ffff04ff09ff8080ff80808080ff8080808080ffff010580ff0180ff018080");
2969pub const FLAG_PROOFS_CHECKER_HASH: [u8; 32] =
2970 hex!("fe2e3c631562fbb9be095297f762bf573705a0197164e9361ad5d50e045ba241");
2971
2972/// ```text
2973/// ; This is a utility layer for a coin that allows it to prove that it came from some INITIAL_PUZZLE_HASH
2974/// (mod
2975/// (
2976/// INITIAL_PUZZLE_HASH ; The ancestor's puzzle hash this layer is evidence of
2977/// PARENT_MORPHER ; Defines how to wrap a parent inner puzzle hash to prove that it had this layer running inside it
2978/// INNER_PUZZLE
2979/// lineage_proof ; parent id, parent inner puzzle hash (wrapped with PARENT_MORPHER), parent amount
2980/// morpher_solution ; solution to PARENT_MORPHER
2981/// inner_solution
2982/// )
2983///
2984/// (include condition_codes.clib)
2985///
2986/// (c
2987/// (list ASSERT_MY_PARENT_ID
2988/// (sha256
2989/// (f lineage_proof)
2990/// (if (r (r lineage_proof)) ; different logic based on whether the lineage proof is 2 or 3 elements long
2991/// (a PARENT_MORPHER (c INITIAL_PUZZLE_HASH (c (f (r lineage_proof)) morpher_solution)))
2992/// INITIAL_PUZZLE_HASH
2993/// )
2994/// (if (r (r lineage_proof)) ; different logic based on whether the lineage proof is 2 or 3 elements long
2995/// (f (r (r lineage_proof)))
2996/// (f (r lineage_proof))
2997/// )
2998/// )
2999/// )
3000/// (a INNER_PUZZLE inner_solution)
3001/// )
3002/// )
3003/// ```
3004pub const COVENANT_LAYER: [u8; 110] = hex!("ff02ffff01ff04ffff04ff02ffff04ffff0bff4fffff02ffff03ff81efffff01ff02ff0bffff04ff05ffff04ff81afff5f808080ffff010580ff0180ffff02ffff03ff81efffff0182016fffff0181af80ff018080ff808080ffff02ff17ff81bf8080ffff04ffff0147ff018080");
3005pub const COVENANT_LAYER_HASH: [u8; 32] =
3006 hex!("b982796850336aabf9ab17c3f21e299f0c633444117ab5e9ebeafadf1860d9fc");
3007
3008/// ```text
3009/// ; This is a PARENT_MORPHER for use with covenant_layer.clsp
3010///
3011/// ; It is used to prove that the parent was a singleton -> exigent metadata layer (w/ covenant_layer in TP) puzzle stack
3012/// (mod
3013/// (
3014/// ; We curry twice: first, all of the static information we need, then the hash of the program with all of that info
3015/// ; this allows use to be more efficient when calculating our own hash (a (q . SELF_HASH) (c SELF_HASH 1))
3016/// ; curried first - a bunch of info to create a singleton -> ownership layer puzzle stack
3017/// COVENANT_MOD_HASH
3018/// EML_MOD_HASH
3019/// ADAPTER_MOD_HASH
3020/// SINGLETON_MOD_HASH
3021/// SINGLETON_LAUNCHER_HASH_HASH
3022/// TP_HASH
3023/// ; curried second
3024/// SELF_HASH ; tree hash of all the other hashes above
3025/// ; Truths
3026/// COVENANT_INITIAL_PUZZLE_HASH
3027/// PREVIOUS_INNER_PUZHASH
3028/// ; solution
3029/// previous_metadata_hash ; pre-treehashed METADATA from our parent's EML
3030/// my_singleton_id ; no need to commit to this, our parent is guaranteed to be a singleton with the same ID as ours
3031/// )
3032///
3033/// (include curry.clib)
3034///
3035/// (defconstant ONE 1)
3036///
3037/// (defun main
3038/// (
3039/// EML_MOD_HASH
3040/// SINGLETON_MOD_HASH
3041/// SINGLETON_LAUNCHER_HASH_HASH
3042/// PREVIOUS_INNER_PUZHASH
3043/// previous_metadata_hash
3044/// my_singleton_id
3045/// tp_hash
3046/// )
3047///
3048/// (curry_hashes SINGLETON_MOD_HASH
3049/// (sha256 TWO
3050/// (sha256 ONE SINGLETON_MOD_HASH)
3051/// (sha256 TWO
3052/// (sha256 ONE my_singleton_id)
3053/// SINGLETON_LAUNCHER_HASH_HASH
3054/// )
3055/// )
3056/// (curry_hashes EML_MOD_HASH
3057/// (sha256 ONE EML_MOD_HASH)
3058/// previous_metadata_hash
3059/// tp_hash
3060/// (sha256 ONE tp_hash)
3061/// PREVIOUS_INNER_PUZHASH
3062/// )
3063/// )
3064/// )
3065///
3066/// (main
3067/// EML_MOD_HASH
3068/// SINGLETON_MOD_HASH
3069/// SINGLETON_LAUNCHER_HASH_HASH
3070/// PREVIOUS_INNER_PUZHASH
3071/// previous_metadata_hash
3072/// my_singleton_id
3073/// (curry_hashes ADAPTER_MOD_HASH
3074/// (curry_hashes COVENANT_MOD_HASH
3075/// (sha256 ONE COVENANT_INITIAL_PUZZLE_HASH)
3076/// (curry_hashes SELF_HASH
3077/// (sha256 ONE SELF_HASH)
3078/// )
3079/// TP_HASH
3080/// )
3081/// )
3082/// )
3083/// )
3084/// ```
3085pub const EML_COVENANT_MORPHER: [u8; 589] = hex!("ff02ffff01ff02ff1effff04ff02ffff04ff0bffff04ff2fffff04ff5fffff04ff8205ffffff04ff820bffffff04ff8217ffffff04ffff02ff1affff04ff02ffff04ff17ffff04ffff02ff1affff04ff02ffff04ff05ffff04ffff0bff08ff8202ff80ffff04ffff02ff1affff04ff02ffff04ff82017fffff04ffff0bff08ff82017f80ff8080808080ffff04ff81bfff80808080808080ff8080808080ff80808080808080808080ffff04ffff01ffff01ff02ff02ffff03ff05ffff01ff0bff72ffff02ff16ffff04ff02ffff04ff09ffff04ffff02ff1cffff04ff02ffff04ff0dff80808080ff808080808080ffff016280ff0180ffffffffa04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459aa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ffa102a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222a102a8d5dd63fba471ebcb1f3e8f7c1e1879b7152a6e7298a91ce119a63400ade7c5ff0bff52ffff02ff16ffff04ff02ffff04ff05ffff04ffff02ff1cffff04ff02ffff04ff07ff80808080ff808080808080ffff0bff14ffff0bff14ff62ff0580ffff0bff14ff0bff428080ff02ff1affff04ff02ffff04ff0bffff04ffff0bff14ffff0bff08ff0b80ffff0bff14ffff0bff08ff81bf80ff178080ffff04ffff02ff1affff04ff02ffff04ff05ffff04ffff0bff08ff0580ffff04ff5fffff04ff82017fffff04ffff0bff08ff82017f80ffff04ff2fff808080808080808080ff808080808080ff018080");
3086pub const EML_COVENANT_MORPHER_HASH: [u8; 32] =
3087 hex!("6a87946257f555ae82aca6a11b5205058b844f634ecb6c7dc6b0c54eb2996308");
3088
3089/// ```text
3090/// ; This is a layer that adapts the API between an ownership layer and its transfer program when the transfer program is
3091/// ; wrapped with a covenant layer.
3092/// (mod
3093/// (
3094/// COVENANT_LAYER
3095/// METADATA ; Truth
3096/// CONDITIONS ; Truth
3097/// ; covenant layer solution
3098/// (
3099/// lineage_proof
3100/// morpher_solution
3101/// inner_solution
3102/// )
3103/// )
3104///
3105/// ; Solution from covenant layer comes back like so:
3106/// ; ((ASSERT_MY_PARENT_ID 0x...) new_metadata new_tp conditions)
3107/// ; so we need to move that ASSERT_MY_PARENT_ID to the returned conditions from the TP
3108/// (defun fix_condition ((parent_assertion . (new_owner new_tp conditions)))
3109/// (list new_owner new_tp (c parent_assertion conditions))
3110/// )
3111///
3112/// (fix_condition (a
3113/// COVENANT_LAYER
3114/// (list
3115/// lineage_proof
3116/// morpher_solution
3117/// ; Covenant layer doesn't know about truths so we need to pass those down to the inner tp solution
3118/// (list METADATA CONDITIONS inner_solution)
3119/// )
3120/// ))
3121/// )
3122/// ```
3123pub const EML_TRANSFER_PROGRAM_COVENANT_ADAPTER: [u8; 104] = hex!("ff02ffff01ff02ff02ffff04ff02ffff04ffff02ff05ffff04ff4fffff04ff81afffff04ffff04ff0bffff04ff17ffff04ff82016fff80808080ff8080808080ff80808080ffff04ffff01ff04ff15ffff04ff2dffff04ffff04ff09ff5d80ff80808080ff018080");
3124pub const EML_TRANSFER_PROGRAM_COVENANT_ADAPTER_HASH: [u8; 32] =
3125 hex!("4218fbebbb6f3c0907ebe8a672fa5d1e4bc655645a3a0073601e6c9b50b07c47");
3126
3127/// ```text
3128/// ; This is a TRANSFER_PROGRAM for use with exigent_metadata_layer.clsp
3129///
3130/// ; Given a DID's singleton struct, assert its announcement of any changes. If no DID's innerpuz is provided, then just
3131/// ; return the same metadata and transfer program with no conditions
3132///
3133/// ; This TP also allows metadata to be cleared and transfer program to be reset simultaneously, no DID required
3134/// (mod
3135/// (
3136/// SINGLETON_MOD_HASH
3137/// SINGLETON_LAUNCHER_HASH
3138/// (provider_id . metadata) ; Truth
3139/// conditions ; Truth
3140/// ; tp_solution looks like this in the case of a DID update
3141/// (
3142/// provider_innerpuzhash
3143/// my_coin_id
3144/// new_metadata
3145/// new_transfer_program_hash
3146/// )
3147/// ; tp_solution could also be () or new_transfer_program_hash for two other cases:
3148/// ; - () == continue with the same metadata we currently have
3149/// ; - new_transfer_program_hash == update the transfer program to whatever, but clear the metadata
3150/// )
3151///
3152/// (include condition_codes.clib)
3153/// (include curry.clib)
3154/// (include sha256tree.clib)
3155/// (include utility_macros.clib)
3156///
3157/// (defconstant ONE 1)
3158///
3159/// (defun-inline create_did_puzhash
3160/// (
3161/// SINGLETON_MOD_HASH
3162/// SINGLETON_LAUNCHER_HASH
3163/// provider_id
3164/// provider_innerpuzhash
3165/// )
3166///
3167/// (curry_hashes_inline SINGLETON_MOD_HASH
3168/// ; calculate the singleton struct
3169/// (sha256 TWO
3170/// (sha256 ONE SINGLETON_MOD_HASH)
3171/// (sha256 TWO
3172/// (sha256 ONE provider_id)
3173/// (sha256 ONE SINGLETON_LAUNCHER_HASH)
3174/// )
3175/// )
3176/// provider_innerpuzhash
3177/// )
3178/// )
3179///
3180/// ; Returning (new_metadata new_transfer_program_hash conditions)
3181/// (if (l (f (r (r (r (r (r @))))))) ; If a tp solution was provided
3182/// (list
3183/// (i new_metadata (c provider_id new_metadata) ())
3184/// new_transfer_program_hash
3185/// (list
3186/// (list ASSERT_MY_COIN_ID my_coin_id)
3187/// ; get an announcement from the DID in the EML's metadata to update to a new metadata and transfer program
3188/// (list ASSERT_PUZZLE_ANNOUNCEMENT
3189/// (sha256
3190/// (create_did_puzhash SINGLETON_MOD_HASH SINGLETON_LAUNCHER_HASH provider_id provider_innerpuzhash)
3191/// (sha256
3192/// my_coin_id
3193/// (sha256tree new_metadata)
3194/// new_transfer_program_hash
3195/// )
3196/// )
3197/// )
3198/// )
3199/// )
3200/// ; else - the tp_solution is an atom
3201/// (if (f (r (r (r (r (r @)))))) ; If a new_transfer_program_hash was provided
3202/// (list () (f (r (r (r (r (r @)))))) ())
3203/// ; else - No new TP was provided, continue with current metadata
3204/// (list (c provider_id metadata) () ())
3205/// )
3206/// )
3207/// )
3208/// ```
3209pub const EML_UPDATE_METADATA_WITH_DID: [u8; 552] = hex!("ff02ffff01ff02ffff03ffff07ff5f80ffff01ff04ffff03ff8202dfffff04ff27ff8202df80ff8080ffff04ff8205dfffff04ffff04ffff04ff08ffff04ff82015fff808080ffff04ffff04ff14ffff04ffff0bffff0bff56ffff0bff0affff0bff0aff66ff0580ffff0bff0affff0bff76ffff0bff0affff0bff0aff66ffff0bff0affff0bff1cff0580ffff0bff0affff0bff1cff2780ffff0bff1cff0b80808080ffff0bff0affff0bff76ffff0bff0affff0bff0aff66ff819f80ffff0bff0aff66ff46808080ff46808080ff46808080ffff0bff82015fffff02ff1effff04ff02ffff04ff8202dfff80808080ff8205df8080ff808080ff808080ff80808080ffff01ff02ffff03ff5fffff01ff04ff80ffff04ff5fffff01ff80808080ffff01ff04ffff04ff27ff3780ffff01ff80ff80808080ff018080ff0180ffff04ffff01ffff46ff3f01ff02ffffffa04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459aa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ffa102a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222a102a8d5dd63fba471ebcb1f3e8f7c1e1879b7152a6e7298a91ce119a63400ade7c5ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff1effff04ff02ffff04ff09ff80808080ffff02ff1effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080");
3210pub const EML_UPDATE_METADATA_WITH_DID_HASH: [u8; 32] =
3211 hex!("d3a9a1fc20f247d009b4b0e941707d50b91885c99d0b27ef882e1294e771139d");
3212
3213/// ```text
3214/// ; This layer is an outer puzzle that keeps some metadata that must be reaffirmed by a "transfer program" on every spend.
3215/// ;
3216/// ; In a way, this puzzle acts as a p2_merkle_tree puzzle where there are always two leaves and BOTH must run every spend.
3217/// ;
3218/// ; The inner puzzle runs first and actually supplies the solution to the transfer program.
3219/// ;
3220/// ; Likely, the transfer program is placed into the EML by a party who does not currently control the coin, to enforce
3221/// ; that certain behaviors regarding the curried metadata are followed.
3222/// (mod
3223/// (
3224/// THIS_MOD_HASH
3225/// METADATA ; The metadata can be anything. It is passed to the transfer program and new metadata is returned.
3226/// TRANSFER_PROGRAM ; Runs every spend, solution supplied by the inner puzzle
3227/// TRANSFER_PROGRAM_HASH ; we also include the hash for efficiency's sake when re-calculating our own hash
3228/// INNER_PUZZLE
3229/// inner_solution
3230/// )
3231///
3232/// (include condition_codes.clib)
3233/// (include curry-and-treehash.clib)
3234/// (include utility_macros.clib)
3235///
3236/// (defun-inline nft_ownership_layer_puzzle_hash
3237/// (
3238/// THIS_MOD_HASH
3239/// new_owner
3240/// TRANSFER_PROGRAM_HASH
3241/// inner_puzzle_hash
3242/// )
3243/// (puzzle-hash-of-curried-function THIS_MOD_HASH
3244/// inner_puzzle_hash
3245/// (sha256 ONE TRANSFER_PROGRAM_HASH)
3246/// TRANSFER_PROGRAM_HASH
3247/// (sha256tree new_owner)
3248/// (sha256 ONE THIS_MOD_HASH)
3249/// )
3250/// )
3251///
3252/// (defun-inline construct_end_conditions
3253/// (
3254/// THIS_MOD_HASH
3255/// TRANSFER_PROGRAM
3256/// TRANSFER_PROGRAM_HASH
3257/// odd_args
3258/// (new_owner new_tp_hash conditions)
3259/// )
3260/// (c
3261/// (c
3262/// CREATE_COIN
3263/// (c
3264/// (nft_ownership_layer_puzzle_hash
3265/// THIS_MOD_HASH
3266/// new_owner
3267/// (if new_tp_hash new_tp_hash TRANSFER_PROGRAM_HASH)
3268/// (f odd_args)
3269/// )
3270/// (r odd_args)
3271/// )
3272/// )
3273/// conditions
3274/// )
3275/// )
3276///
3277/// (defun process_conditions
3278/// (
3279/// THIS_MOD_HASH
3280/// TRANSFER_PROGRAM
3281/// TRANSFER_PROGRAM_HASH
3282/// METADATA
3283/// all_conditions
3284/// conditions
3285/// ; These args all start at ()
3286/// (
3287/// odd_args
3288/// tp_output
3289/// condition_to_prepend
3290/// )
3291/// )
3292/// ; This loop works a bit differently than most condition wrapping loops
3293/// ;
3294/// ; We expect an invalid condition (-10) that we must strip out, but we must also wrap the odd create coin based on
3295/// ; information from that condition.
3296/// ;
3297/// ; To facilitate this, each iteration of the loop calls the next iteration with the condition it wishes to prepend
3298/// ; to the list. If we want to strip out a condition, we call the next iteration with () as condition_to_prepend
3299/// ; which will cause an empty REMARK condition to be prepended as a no-op instead. The two conditions that will
3300/// ; trigger this are the magic condition (-10) and the odd create coin condition. The magic condition never makes it
3301/// ; back into the list, but the CREATE_COIN is re-created wrapped by construct_end_conditions.
3302/// (c
3303/// (i condition_to_prepend condition_to_prepend (list REMARK))
3304/// (if conditions
3305/// (process_conditions
3306/// THIS_MOD_HASH
3307/// TRANSFER_PROGRAM
3308/// TRANSFER_PROGRAM_HASH
3309/// METADATA
3310/// all_conditions
3311/// (r conditions)
3312/// (if (= (f (f conditions)) CREATE_COIN)
3313/// (if (logand (f (r (r (f conditions)))) 1)
3314/// (assert (not odd_args)
3315/// ; then
3316/// (list (r (f conditions)) tp_output ())
3317/// )
3318/// ; else - amount is not odd
3319/// (list odd_args tp_output (f conditions))
3320/// )
3321/// ; else - condition is not a create coin
3322/// (if (= (f (f conditions)) -10) ; -10 is "magic" opcode for running transfer program
3323/// (assert (not tp_output)
3324/// ; then
3325/// (list
3326/// odd_args
3327/// (a TRANSFER_PROGRAM (list METADATA all_conditions (r (f conditions))))
3328/// ()
3329/// )
3330/// )
3331/// ; else - condition is not a create coin nor a NEW_OWNER_CONDITION
3332/// (list odd_args tp_output (f conditions))
3333/// )
3334/// )
3335/// )
3336/// ; else - we have no more conditions
3337/// ; odd_args and tp_solution are guaranteed to not be nil or else we'll have a path into atom error
3338/// (construct_end_conditions
3339/// THIS_MOD_HASH
3340/// TRANSFER_PROGRAM
3341/// TRANSFER_PROGRAM_HASH
3342/// odd_args
3343/// tp_output
3344/// )
3345/// )
3346/// )
3347/// )
3348///
3349/// (defun main
3350/// (
3351/// THIS_MOD_HASH
3352/// TRANSFER_PROGRAM
3353/// TRANSFER_PROGRAM_HASH
3354/// METADATA
3355/// conditions
3356/// )
3357/// (process_conditions
3358/// THIS_MOD_HASH
3359/// TRANSFER_PROGRAM
3360/// TRANSFER_PROGRAM_HASH
3361/// METADATA
3362/// conditions
3363/// conditions
3364/// (list () () ())
3365/// )
3366/// )
3367///
3368/// ; main
3369/// (main
3370/// THIS_MOD_HASH
3371/// TRANSFER_PROGRAM
3372/// TRANSFER_PROGRAM_HASH
3373/// METADATA
3374/// (a INNER_PUZZLE inner_solution)
3375/// )
3376/// )
3377/// ```
3378pub const EXIGENT_METADATA_LAYER: [u8; 888] = hex!("ff02ffff01ff02ff3affff04ff02ffff04ff05ffff04ff17ffff04ff2fffff04ff0bffff04ffff02ff5fff81bf80ff8080808080808080ffff04ffff01ffffff02ff3304ff01ff0101ffff02ffff02ffff03ff05ffff01ff02ff2affff04ff02ffff04ff0dffff04ffff0bff12ffff0bff14ff3880ffff0bff12ffff0bff12ffff0bff14ff2c80ff0980ffff0bff12ff0bffff0bff14ff8080808080ff8080808080ffff010b80ff0180ff02ff16ffff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ff5fffff01ffff80ff80ff8080808080808080808080ffff04ffff03ff820b7fff820b7fffff04ff3cff808080ffff02ffff03ff81bfffff01ff02ff16ffff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ff8201bfffff04ffff02ffff03ffff09ff82023fff2880ffff01ff02ffff03ffff18ff820b3fffff010180ffff01ff02ffff03ffff20ff82027f80ffff01ff04ff82033fffff04ff82057fffff01ff80808080ffff01ff088080ff0180ffff01ff04ff82027fffff04ff82057fffff04ff82013fff8080808080ff0180ffff01ff02ffff03ffff09ff82023fffff0181f680ffff01ff02ffff03ffff20ff82057f80ffff01ff04ff82027fffff04ffff02ff0bffff04ff2fffff04ff5fffff04ff82033fff8080808080ffff01ff80808080ffff01ff088080ff0180ffff01ff04ff82027fffff04ff82057fffff04ff82013fff8080808080ff018080ff0180ff80808080808080808080ffff01ff04ffff04ff28ffff04ffff02ff2effff04ff02ffff04ff05ffff04ff82047fffff04ffff0bff14ffff02ffff03ff82157fffff0182157fffff011780ff018080ffff04ffff02ffff03ff82157fffff0182157fffff011780ff0180ffff04ffff02ff3effff04ff02ffff04ff82097fff80808080ffff04ffff0bff14ff0580ff808080808080808080ff82067f8080ff822d7f8080ff018080ffff0bff12ffff0bff14ff1080ffff0bff12ffff0bff12ffff0bff14ff2c80ff0580ffff0bff12ffff02ff2affff04ff02ffff04ff07ffff04ffff0bff14ff1480ff8080808080ffff0bff14ff8080808080ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff3effff04ff02ffff04ff09ff80808080ffff02ff3effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080");
3379pub const EXIGENT_METADATA_LAYER_HASH: [u8; 32] =
3380 hex!("d5fd32e069fda83e230ccd8f6a7c4f652231aed5c755514b3d996cbeff4182b8");
3381
3382/// ```text
3383/// ; This is a generalization of the idea behind singleton_launcher.clsp
3384///
3385/// ; Given a delegated puzzle and solution, just run them and announce the hash of the delegated puzzle.
3386/// ; A parent can rely on this announcement so if the exact delegated_puzzle it is expecting is not run, the whole bundle
3387/// ; fails due to a grandparent paradox.
3388/// (mod
3389/// (
3390/// delegated_puzzle
3391/// delegated_solution
3392/// )
3393///
3394/// (include condition_codes.clib)
3395/// (include sha256tree.clib)
3396///
3397/// (c (list CREATE_COIN_ANNOUNCEMENT (sha256tree delegated_puzzle)) (a delegated_puzzle delegated_solution))
3398/// )
3399/// ```
3400pub const P2_ANNOUNCED_DELEGATED_PUZZLE: [u8; 137] = hex!("ff02ffff01ff04ffff04ff04ffff04ffff02ff06ffff04ff02ffff04ff05ff80808080ff808080ffff02ff05ff0b8080ffff04ffff01ff3cff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff06ffff04ff02ffff04ff09ff80808080ffff02ff06ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080");
3401pub const P2_ANNOUNCED_DELEGATED_PUZZLE_HASH: [u8; 32] =
3402 hex!("c4d24c3c5349376f3e8f3aba202972091713b4ec4915f0f26192ae4ace0bd04d");
3403
3404/// ```text
3405/// ; This is the standard puzzle that a VerifiedCredential provider will put into the revocation layer slot of revocation_layer.clsp
3406///
3407/// ; The goal of this puzzle is to recreate the VC exactly as it is except for three things:
3408/// ; 1) There is no longer a revocation layer
3409/// ; 2) The metadata in the ownership layer becomes ()
3410/// ; 3) The transfer program in the ownership layer becomes a curried default
3411/// (mod
3412/// (
3413/// SINGLETON_MOD_HASH
3414/// SINGLETON_LAUNCHER_HASH_HASH
3415/// OWNERSHIP_LAYER_MOD_HASH
3416/// REVOCATION_LAYER_MOD_HASH
3417/// DEFAULT_TRANSFER_PROGRAM_HASH
3418/// ; most of the specific information is solved rather than curried in because we don't care about committing to it
3419/// launcher_id ; of the singleton this is inside of
3420/// metadata_hash ; of the EML this is inside of
3421/// tp_hash ; of the EML this is inside of
3422/// this_hash_hash ; the hash of this puzzle with all of its curried arguments hashed AGAIN with (sha256 1 this_hash)
3423/// inner_puzzle_hash ; that determines ownership of this coin
3424/// my_amount ; this coin's amount
3425/// ownership_lineage_proof ; need to solve the covenant layer one last time
3426/// previous_metadata_hash ; like metadata_hash above but for the previous coin
3427/// announcement_nonce ; Anything to announce (for fees/DID to hook onto)
3428/// (
3429/// provider_innerpuzhash ; DID needs to authorize the transfer program (and therefore this revocation layer)
3430/// my_coin_id
3431/// )
3432/// )
3433///
3434/// (include condition_codes.clib)
3435/// (include curry.clib)
3436///
3437/// (defconstant ONE 1)
3438///
3439/// (list
3440/// ; The purpose of this condition is just to make sure we're telling the truth about the current inner puzzle hash
3441/// (list ASSERT_MY_PUZZLEHASH
3442/// (curry_hashes SINGLETON_MOD_HASH
3443/// (sha256 TWO
3444/// (sha256 ONE SINGLETON_MOD_HASH)
3445/// (sha256 TWO
3446/// (sha256 ONE launcher_id)
3447/// SINGLETON_LAUNCHER_HASH_HASH
3448/// )
3449/// )
3450/// (curry_hashes OWNERSHIP_LAYER_MOD_HASH
3451/// (sha256 ONE OWNERSHIP_LAYER_MOD_HASH)
3452/// metadata_hash
3453/// tp_hash
3454/// (sha256 ONE tp_hash)
3455/// (curry_hashes REVOCATION_LAYER_MOD_HASH
3456/// (sha256 ONE REVOCATION_LAYER_MOD_HASH)
3457/// this_hash_hash
3458/// (sha256 ONE inner_puzzle_hash)
3459/// )
3460/// )
3461/// )
3462/// )
3463/// (list ASSERT_MY_AMOUNT my_amount)
3464/// (list CREATE_COIN inner_puzzle_hash my_amount)
3465/// (list CREATE_COIN_ANNOUNCEMENT announcement_nonce) ; For fee hooks
3466/// (list
3467/// -10
3468/// ownership_lineage_proof ; for covenant layer
3469/// (list previous_metadata_hash launcher_id) ; for covenant layer parent morpher
3470/// (list ; for transfer program
3471/// provider_innerpuzhash
3472/// my_coin_id
3473/// ()
3474/// DEFAULT_TRANSFER_PROGRAM_HASH
3475/// )
3476/// )
3477/// )
3478/// )
3479/// ```
3480pub const STANDARD_VC_REVOCATION_PUZZLE: [u8; 652] = hex!("ff02ffff01ff04ffff04ff18ffff04ffff02ff2effff04ff02ffff04ff05ffff04ffff0bff12ffff0bff3cff0580ffff0bff12ffff0bff3cff81bf80ff0b8080ffff04ffff02ff2effff04ff02ffff04ff17ffff04ffff0bff3cff1780ffff04ff82017fffff04ff8202ffffff04ffff0bff3cff8202ff80ffff04ffff02ff2effff04ff02ffff04ff2fffff04ffff0bff3cff2f80ffff04ff8205ffffff04ffff0bff3cff820bff80ff80808080808080ff808080808080808080ff808080808080ff808080ffff04ffff04ff10ffff04ff8217ffff808080ffff04ffff04ff14ffff04ff820bffffff04ff8217ffff80808080ffff04ffff04ff2cffff04ff82bfffff808080ffff04ffff04ffff0181f6ffff04ff822fffffff04ffff04ff825fffffff04ff81bfff808080ffff04ffff04ff83027fffffff04ff83057fffffff04ff80ffff04ff5fff8080808080ff8080808080ff808080808080ffff04ffff01ffffff4948ff33ff3c01ffff02ff02ffff03ff05ffff01ff0bff76ffff02ff3effff04ff02ffff04ff09ffff04ffff02ff1affff04ff02ffff04ff0dff80808080ff808080808080ffff016680ff0180ffffffa04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459aa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ffa102a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222a102a8d5dd63fba471ebcb1f3e8f7c1e1879b7152a6e7298a91ce119a63400ade7c5ffff0bff56ffff02ff3effff04ff02ffff04ff05ffff04ffff02ff1affff04ff02ffff04ff07ff80808080ff808080808080ff0bff12ffff0bff12ff66ff0580ffff0bff12ff0bff468080ff018080");
3481pub const STANDARD_VC_REVOCATION_PUZZLE_HASH: [u8; 32] =
3482 hex!("fbce76408ebaf9b3d0b8cd90cc68607755eeca67cd7432d5eea85f3f498cc002");
3483
3484/// ```text
3485/// ; This is a PARENT_MORPHER for use with covenant_layer.clsp
3486///
3487/// ; You would use this morpher when the covenant layer is the outermost layer of the coin
3488/// (mod
3489/// (
3490/// THIS_MOD_HASH
3491/// COVENANT_MOD_HASH
3492/// COVENANT_INITIAL_PUZZLE_HASH
3493/// inner_puzhash
3494/// )
3495///
3496/// (include curry.clib)
3497///
3498/// (curry_hashes_inline COVENANT_MOD_HASH
3499/// (sha256 1 COVENANT_INITIAL_PUZZLE_HASH)
3500/// (curry_hashes_inline THIS_MOD_HASH
3501/// (sha256 1 THIS_MOD_HASH)
3502/// (sha256 1 COVENANT_MOD_HASH)
3503/// (sha256 1 COVENANT_INITIAL_PUZZLE_HASH)
3504/// )
3505/// inner_puzhash
3506/// )
3507/// )
3508/// ```
3509pub const STD_PARENT_MORPHER: [u8; 427] = hex!("ff02ffff01ff0bff16ffff0bff04ffff0bff04ff1aff0b80ffff0bff04ffff0bff1effff0bff04ffff0bff04ff1affff0bffff0101ff178080ffff0bff04ffff0bff1effff0bff04ffff0bff04ff1affff0bff16ffff0bff04ffff0bff04ff1aff0580ffff0bff04ffff0bff1effff0bff04ffff0bff04ff1affff0bffff0101ff058080ffff0bff04ffff0bff1effff0bff04ffff0bff04ff1affff0bffff0101ff0b8080ffff0bff04ffff0bff1effff0bff04ffff0bff04ff1affff0bffff0101ff178080ffff0bff04ff1aff12808080ff12808080ff12808080ff1280808080ffff0bff04ffff0bff1effff0bff04ffff0bff04ff1aff2f80ffff0bff04ff1aff12808080ff12808080ff12808080ff12808080ffff04ffff01ff02ffffa04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459aa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ffa102a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222a102a8d5dd63fba471ebcb1f3e8f7c1e1879b7152a6e7298a91ce119a63400ade7c5ff018080");
3510pub const STD_PARENT_MORPHER_HASH: [u8; 32] =
3511 hex!("8c3f1dc2e46c0d7ec4c2cbd007e23c0368ff8f80c5bc0101647a5c27626ebce6");
3512
3513/// ```text
3514/// ; This layer ensures that a second puzzle hash or "revocation layer" that can be used without the inner puzzle's permission
3515/// ; travels with each generation of a coin.
3516///
3517/// ; The hidden puzzle is responsible for recreating this layer if it wishes, this layer will not wrap its outputs.
3518/// (mod
3519/// (
3520/// THIS_MOD_HASH
3521/// HIDDEN_PUZZLE_HASH
3522/// INNER_PUZZLE_HASH ; must be a hash so that the revocation layer has enough info to create a puzzle reveal to spend the coin
3523/// hidden ; bool for whether or not to run the hidden puzzle
3524/// inner_or_hidden_puzzle_reveal
3525/// inner_or_hidden_solution
3526/// )
3527///
3528/// (include condition_codes.clib)
3529/// (include curry.clib)
3530/// (include sha256tree.clib)
3531/// (include utility_macros.clib)
3532///
3533/// (defconstant ONE 1)
3534///
3535/// (defun-inline wrap_puzhash
3536/// (
3537/// THIS_MOD_HASH
3538/// HIDDEN_PUZZLE_HASH
3539/// new_inner_puzzle_hash
3540/// )
3541///
3542/// (curry_hashes_inline THIS_MOD_HASH
3543/// (sha256 ONE THIS_MOD_HASH)
3544/// (sha256 ONE HIDDEN_PUZZLE_HASH)
3545/// (sha256 ONE new_inner_puzzle_hash)
3546/// )
3547/// )
3548///
3549/// (defun wrap_create_coins
3550/// (
3551/// THIS_MOD_HASH
3552/// HIDDEN_PUZZLE_HASH
3553/// conditions
3554/// )
3555/// (if conditions
3556/// (if (= (f (f conditions)) CREATE_COIN)
3557/// (c
3558/// (c CREATE_COIN (c (wrap_puzhash THIS_MOD_HASH HIDDEN_PUZZLE_HASH (f (r (f conditions)))) (r (r (f conditions)))))
3559/// (wrap_create_coins THIS_MOD_HASH HIDDEN_PUZZLE_HASH (r conditions))
3560/// )
3561/// (c (f conditions) (wrap_create_coins THIS_MOD_HASH HIDDEN_PUZZLE_HASH (r conditions)))
3562/// )
3563/// ()
3564/// )
3565/// )
3566///
3567/// (if hidden
3568/// (assert (= HIDDEN_PUZZLE_HASH (sha256tree inner_or_hidden_puzzle_reveal))
3569/// ; then
3570/// (a inner_or_hidden_puzzle_reveal inner_or_hidden_solution)
3571/// )
3572/// (assert (= INNER_PUZZLE_HASH (sha256tree inner_or_hidden_puzzle_reveal))
3573/// ; then
3574/// (wrap_create_coins THIS_MOD_HASH HIDDEN_PUZZLE_HASH (a inner_or_hidden_puzzle_reveal inner_or_hidden_solution))
3575/// )
3576/// )
3577/// )
3578/// ```
3579pub const REVOCATION_LAYER: [u8; 653] = hex!("ff02ffff01ff02ffff03ff2fffff01ff02ffff03ffff09ff0bffff02ff16ffff04ff02ffff04ff5fff8080808080ffff01ff02ff5fff81bf80ffff01ff088080ff0180ffff01ff02ffff03ffff09ff17ffff02ff16ffff04ff02ffff04ff5fff8080808080ffff01ff02ff1effff04ff02ffff04ff05ffff04ff0bffff04ffff02ff5fff81bf80ff808080808080ffff01ff088080ff018080ff0180ffff04ffff01ffff33ff0102ffffffa04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459aa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ffa102a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222a102a8d5dd63fba471ebcb1f3e8f7c1e1879b7152a6e7298a91ce119a63400ade7c5ffff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff16ffff04ff02ffff04ff09ff80808080ffff02ff16ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff02ffff03ff17ffff01ff02ffff03ffff09ff47ff0880ffff01ff04ffff04ff08ffff04ffff0bff2affff0bff1cffff0bff1cff32ff0580ffff0bff1cffff0bff3affff0bff1cffff0bff1cff32ffff0bff14ff058080ffff0bff1cffff0bff3affff0bff1cffff0bff1cff32ffff0bff14ff0b8080ffff0bff1cffff0bff3affff0bff1cffff0bff1cff32ffff0bff14ff81a78080ffff0bff1cff32ff22808080ff22808080ff22808080ff22808080ff81e78080ffff02ff1effff04ff02ffff04ff05ffff04ff0bffff04ff37ff80808080808080ffff01ff04ff27ffff02ff1effff04ff02ffff04ff05ffff04ff0bffff04ff37ff8080808080808080ff0180ff8080ff0180ff018080");
3580pub const REVOCATION_LAYER_HASH: [u8; 32] =
3581 hex!("00848115554ea674131f89f311707a959ad3f4647482648f3fe91ba289131f51");
3582
3583/// ```text
3584/// (mod (METADATA conditions . solution) (if solution solution (list METADATA () ())))
3585/// ```
3586pub const ACS_TRANSFER_PROGRAM: [u8; 31] =
3587 hex!("ff02ffff03ff07ffff0107ffff01ff04ff02ffff01ff80ff80808080ff0180");
3588pub const ACS_TRANSFER_PROGRAM_HASH: [u8; 32] =
3589 hex!("664e6e57ac6a184334a3e743c446c5d28c0dd2ae6f84bad6dacec29ab7a0bd43");
3590
3591/// ```text
3592/// (mod
3593/// (
3594/// CONDITION
3595/// INNER_PUZZLE
3596/// inner_solution
3597/// )
3598///
3599/// (c
3600/// CONDITION
3601/// (a INNER_PUZZLE inner_solution)
3602/// )
3603///
3604/// )
3605/// ```
3606pub const AUGMENTED_CONDITION: [u8; 13] = hex!("ff04ff02ffff02ff05ff0b8080");
3607pub const AUGMENTED_CONDITION_HASH: [u8; 32] =
3608 hex!("d303eafa617bedf0bc05850dd014e10fbddf622187dc07891a2aacba9d8a93f6");
3609
3610/// ```text
3611/// (mod (
3612/// TARGET
3613/// AMOUNT
3614/// )
3615/// (include condition_codes.clib)
3616/// (list (list CREATE_COIN TARGET AMOUNT) (list CREATE_COIN_ANNOUNCEMENT ()))
3617/// )
3618/// ```
3619pub const NOTIFICATION: [u8; 59] = hex!("ff02ffff01ff04ffff04ff04ffff04ff05ffff04ff0bff80808080ffff04ffff04ff06ffff01ff808080ff808080ffff04ffff01ff333cff018080");
3620pub const NOTIFICATION_HASH: [u8; 32] =
3621 hex!("b8b9d8ffca6d5cba5422ead7f477ecfc8f6aaaa1c024b8c3aeb1956b24a0ab1e");
3622
3623/// ```text
3624/// (mod
3625/// (
3626/// MERKLE_ROOT
3627/// merkle_proof
3628/// puzzle_to_execute
3629/// inner_solution
3630/// )
3631///
3632/// (include utility_macros.clib)
3633/// (include merkle_utils.clib)
3634///
3635/// ; takes a lisp tree and returns the hash of it
3636/// (defun sha256tree (TREE)
3637/// (if (l TREE)
3638/// (sha256 2 (sha256tree (f TREE)) (sha256tree (r TREE)))
3639/// (sha256 1 TREE)))
3640///
3641/// (assert (= MERKLE_ROOT (simplify_merkle_proof (sha256tree puzzle_to_execute) merkle_proof))
3642/// (a puzzle_to_execute inner_solution)
3643/// )
3644///
3645/// )
3646/// ```
3647pub const P2_1_OF_N: [u8; 280] = hex!("ff02ffff01ff02ffff03ffff09ff05ffff02ff06ffff04ff02ffff04ffff0bffff0101ffff02ff04ffff04ff02ffff04ff17ff8080808080ffff04ff0bff808080808080ffff01ff02ff17ff2f80ffff01ff088080ff0180ffff04ffff01ffff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff04ffff04ff02ffff04ff09ff80808080ffff02ff04ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff02ffff03ff1bffff01ff02ff06ffff04ff02ffff04ffff02ffff03ffff18ffff0101ff1380ffff01ff0bffff0102ff2bff0580ffff01ff0bffff0102ff05ff2b8080ff0180ffff04ffff04ffff17ff13ffff0181ff80ff3b80ff8080808080ffff010580ff0180ff018080");
3648pub const P2_1_OF_N_HASH: [u8; 32] =
3649 hex!("46b29fd87fbeb6737600c4543931222a6c1ed3db6fa5601a3ca284a9f4efe780");
3650
3651/// ```text
3652/// (mod (conditions)
3653/// (qq (q . (unquote conditions)))
3654/// )
3655/// ```
3656pub const P2_CONDITIONS: [u8; 9] = hex!("ff04ffff0101ff0280");
3657pub const P2_CONDITIONS_HASH: [u8; 32] =
3658 hex!("1c77d7d5efde60a7a1d2d27db6d746bc8e568aea1ef8586ca967a0d60b83cc36");
3659
3660/// ```text
3661/// (mod
3662/// (public_key conditions)
3663///
3664/// (include condition_codes.clib)
3665///
3666/// ;; hash a tree
3667/// ;; This is used to calculate a puzzle hash given a puzzle program.
3668/// (defun sha256tree1
3669/// (TREE)
3670/// (if (l TREE)
3671/// (sha256 2 (sha256tree1 (f TREE)) (sha256tree1 (r TREE)))
3672/// (sha256 1 TREE)
3673/// )
3674/// )
3675///
3676/// (c (list AGG_SIG_ME public_key (sha256tree1 conditions)) conditions)
3677///
3678/// )
3679/// ```
3680pub const P2_DELEGATED_CONDITIONS: [u8; 137] = hex!("ff02ffff01ff04ffff04ff04ffff04ff05ffff04ffff02ff06ffff04ff02ffff04ff0bff80808080ff80808080ff0b80ffff04ffff01ff32ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff06ffff04ff02ffff04ff09ff80808080ffff02ff06ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080");
3681pub const P2_DELEGATED_CONDITIONS_HASH: [u8; 32] =
3682 hex!("0ff94726f1a8dea5c3f70d3121945190778d3b2b3fcda3735a1f290977e98341");
3683
3684/// ```text
3685/// ; build a pay-to delegated puzzle or hidden puzzle
3686/// ; coins can be unlocked by signing a delegated puzzle and its solution
3687/// ; OR by revealing the hidden puzzle and the underlying original key
3688///
3689/// ; glossary of parameter names:
3690///
3691/// ; hidden_puzzle: a "hidden puzzle" that can be revealed and used as an alternate
3692/// ; way to unlock the underlying funds
3693/// ;
3694/// ; synthetic_key_offset: a private key cryptographically generated using the hidden
3695/// ; puzzle and as inputs `original_public_key`
3696/// ;
3697/// ; SYNTHETIC_PUBLIC_KEY: the public key that is the sum of `original_public_key` and the
3698/// ; public key corresponding to `synthetic_key_offset`
3699/// ;
3700/// ; original_public_key: a public key, where knowledge of the corresponding private key
3701/// ; represents ownership of the file
3702/// ;
3703/// ; delegated_puzzle: a delegated puzzle, as in "graftroot", which should return the
3704/// ; desired conditions.
3705/// ;
3706/// ; solution: the solution to the delegated puzzle
3707///
3708///
3709/// (mod
3710/// ; A puzzle should commit to `SYNTHETIC_PUBLIC_KEY`
3711/// ;
3712/// ; The solution should pass in 0 for `original_public_key` if it wants to use
3713/// ; an arbitrary `delegated_puzzle` (and `solution`) signed by the
3714/// ; `SYNTHETIC_PUBLIC_KEY` (whose corresponding private key can be calculated
3715/// ; if you know the private key for `original_public_key`)
3716/// ;
3717/// ; Or you can solve the hidden puzzle by revealing the `original_public_key`,
3718/// ; the hidden puzzle in `delegated_puzzle`, and a solution to the hidden puzzle.
3719///
3720/// (SYNTHETIC_PUBLIC_KEY original_public_key delegated_puzzle solution)
3721///
3722/// ; "assert" is a macro that wraps repeated instances of "if"
3723/// ; usage: (assert A0 A1 ... An R)
3724/// ; all of A0, A1, ... An must evaluate to non-null, or an exception is raised
3725/// ; return the value of R (if we get that far)
3726///
3727/// (defmacro assert items
3728/// (if (r items)
3729/// (list if (f items) (c assert (r items)) (q . (x)))
3730/// (f items)
3731/// )
3732/// )
3733///
3734/// (include condition_codes.clib)
3735///
3736/// ;; hash a tree
3737/// ;; This is used to calculate a puzzle hash given a puzzle program.
3738/// (defun sha256tree1
3739/// (TREE)
3740/// (if (l TREE)
3741/// (sha256 2 (sha256tree1 (f TREE)) (sha256tree1 (r TREE)))
3742/// (sha256 1 TREE)
3743/// )
3744/// )
3745///
3746/// ; "is_hidden_puzzle_correct" returns true iff the hidden puzzle is correctly encoded
3747///
3748/// (defun-inline is_hidden_puzzle_correct (SYNTHETIC_PUBLIC_KEY original_public_key delegated_puzzle)
3749/// (=
3750/// SYNTHETIC_PUBLIC_KEY
3751/// (point_add
3752/// original_public_key
3753/// (pubkey_for_exp (sha256 original_public_key (sha256tree1 delegated_puzzle)))
3754/// )
3755/// )
3756/// )
3757///
3758/// ; "possibly_prepend_aggsig" is the main entry point
3759///
3760/// (defun-inline possibly_prepend_aggsig (SYNTHETIC_PUBLIC_KEY original_public_key delegated_puzzle conditions)
3761/// (if original_public_key
3762/// (assert
3763/// (is_hidden_puzzle_correct SYNTHETIC_PUBLIC_KEY original_public_key delegated_puzzle)
3764/// conditions
3765/// )
3766/// (c (list AGG_SIG_ME SYNTHETIC_PUBLIC_KEY (sha256tree1 delegated_puzzle)) conditions)
3767/// )
3768/// )
3769///
3770/// ; main entry point
3771///
3772/// (possibly_prepend_aggsig
3773/// SYNTHETIC_PUBLIC_KEY original_public_key delegated_puzzle
3774/// (a delegated_puzzle solution))
3775/// )
3776/// ```
3777pub const P2_DELEGATED_PUZZLE_OR_HIDDEN_PUZZLE: [u8; 227] = hex!("ff02ffff01ff02ffff03ff0bffff01ff02ffff03ffff09ff05ffff1dff0bffff1effff0bff0bffff02ff06ffff04ff02ffff04ff17ff8080808080808080ffff01ff02ff17ff2f80ffff01ff088080ff0180ffff01ff04ffff04ff04ffff04ff05ffff04ffff02ff06ffff04ff02ffff04ff17ff80808080ff80808080ffff02ff17ff2f808080ff0180ffff04ffff01ff32ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff06ffff04ff02ffff04ff09ff80808080ffff02ff06ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080");
3778pub const P2_DELEGATED_PUZZLE_OR_HIDDEN_PUZZLE_HASH: [u8; 32] =
3779 hex!("e9aaa49f45bad5c889b86ee3341550c155cfdd10c3a6757de618d20612fffd52");
3780
3781/// ```text
3782/// (mod
3783///
3784/// (public_key delegated_puzzle delegated_puzzle_solution)
3785///
3786/// (include condition_codes.clib)
3787///
3788/// ;; hash a tree
3789/// ;; This is used to calculate a puzzle hash given a puzzle program.
3790/// (defun sha256tree1
3791/// (TREE)
3792/// (if (l TREE)
3793/// (sha256 2 (sha256tree1 (f TREE)) (sha256tree1 (r TREE)))
3794/// (sha256 1 TREE)
3795/// )
3796/// )
3797///
3798/// (c (list AGG_SIG_ME public_key (sha256tree1 delegated_puzzle))
3799/// (a delegated_puzzle delegated_puzzle_solution))
3800/// )
3801/// ```
3802pub const P2_DELEGATED_PUZZLE: [u8; 143] = hex!("ff02ffff01ff04ffff04ff04ffff04ff05ffff04ffff02ff06ffff04ff02ffff04ff0bff80808080ff80808080ffff02ff0bff178080ffff04ffff01ff32ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff06ffff04ff02ffff04ff09ff80808080ffff02ff06ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080");
3803pub const P2_DELEGATED_PUZZLE_HASH: [u8; 32] =
3804 hex!("542cde70d1102cd1b763220990873efc8ab15625ded7eae22cc11e21ef2e2f7c");
3805
3806/// ```text
3807/// ; build an M of N multisig puzzle
3808/// ; coins are locked by N public keys, any M of which can delegate a sub-puzzle
3809///
3810///
3811/// ; glossary of parameter names:
3812///
3813/// ; public_key_list: a list of N public keys
3814///
3815/// ; M: the M in "M of N"
3816///
3817/// ; selectors: a list up of 0s and 1s up to size N where exactly M are 1s
3818/// ; It's used to select public keys from public_key_list
3819///
3820/// ; delegated_puzzle: the puzzle signed by the M public keys
3821/// ; This puzzle must return a list of conditions
3822///
3823/// ; solution: the solution to the delegated puzzle
3824///
3825///
3826/// (mod
3827/// (M public_key_list selectors delegated_puzzle solution)
3828///
3829/// (include condition_codes.clib)
3830///
3831/// ;; hash a tree
3832/// ;; This is used to calculate a puzzle hash given a puzzle program.
3833/// (defun sha256tree1
3834/// (TREE)
3835/// (if (l TREE)
3836/// (sha256 2 (sha256tree1 (f TREE)) (sha256tree1 (r TREE)))
3837/// (sha256 1 TREE)
3838/// )
3839/// )
3840///
3841/// ; "assert" is a macro that wraps repeated instances of "if"
3842/// ; usage: (assert A0 A1 ... An R)
3843/// ; all of A0, A1, ... An must evaluate to non-null, or an exception is raised
3844/// ; return the value of R (if we get that far)
3845///
3846/// (defmacro assert items
3847/// (if (r items)
3848/// (list if (f items) (c assert (r items)) (q . (x)))
3849/// (f items)
3850/// )
3851/// )
3852///
3853/// ; add_aggsig returns a list of conditions. It includes M AGG_SIG conditions
3854/// ; corresponding to the given list of public keys (with the given hash)
3855/// ; plus the conditions that come out of the delegated puzzle.
3856/// ;
3857/// ; hash is the hash of delegated_puzzle.
3858/// ; Yes it's redundant since we include the delegated_puzzle itself,
3859/// ; but we don't want to recalculate the hash multiple times as its expensive to do so
3860///
3861/// (defun add_aggsig (public_key_list hash delegated_puzzle solution)
3862/// (if public_key_list
3863/// (c (list AGG_SIG_UNSAFE (f public_key_list) hash)
3864/// (add_aggsig (r public_key_list) hash delegated_puzzle solution)
3865/// )
3866/// (a delegated_puzzle solution)
3867/// )
3868/// )
3869///
3870/// ; choose_keys takes a list of selectors and the N public keys and
3871/// ; returns a list of the M public keys chosen by the selectors
3872///
3873/// (defun choose_keys (selectors public_key_list)
3874/// (if selectors
3875/// (if (f selectors)
3876/// (c (f public_key_list) (choose_keys (r selectors) (r public_key_list)))
3877/// (choose_keys (r selectors) (r public_key_list)))
3878/// ()
3879/// )
3880/// )
3881///
3882///
3883/// ; count the number of non-0 values in the list of selectors and return it as an integer
3884///
3885/// (defun count_selectors (selectors)
3886/// (if selectors
3887/// (+
3888/// (count_selectors (r selectors))
3889/// (if (f selectors) 1 0)
3890/// )
3891/// 0
3892/// )
3893/// )
3894///
3895/// ; "solve_puzzle" is the main entry point
3896///
3897/// (defun-inline solve_puzzle (M public_key_list selectors delegated_puzzle solution)
3898/// ; make sure we have exactly M selectors
3899/// (assert (= M (count_selectors selectors))
3900/// ; return the AGG_SIG conditions plus the conditions from the delegated_puzzle
3901/// (add_aggsig (choose_keys selectors public_key_list)
3902/// (sha256tree1 delegated_puzzle)
3903/// delegated_puzzle
3904/// solution)
3905/// )
3906/// )
3907///
3908/// ; main entry point
3909///
3910/// (solve_puzzle
3911/// M public_key_list
3912/// selectors delegated_puzzle solution
3913/// )
3914/// )
3915/// ```
3916pub const P2_M_OF_N_DELEGATE_DIRECT: [u8; 453] = hex!("ff02ffff01ff02ffff03ffff09ff05ffff02ff16ffff04ff02ffff04ff17ff8080808080ffff01ff02ff0cffff04ff02ffff04ffff02ff0affff04ff02ffff04ff17ffff04ff0bff8080808080ffff04ffff02ff1effff04ff02ffff04ff2fff80808080ffff04ff2fffff04ff5fff80808080808080ffff01ff088080ff0180ffff04ffff01ffff31ff02ffff03ff05ffff01ff04ffff04ff08ffff04ff09ffff04ff0bff80808080ffff02ff0cffff04ff02ffff04ff0dffff04ff0bffff04ff17ffff04ff2fff8080808080808080ffff01ff02ff17ff2f8080ff0180ffff02ffff03ff05ffff01ff02ffff03ff09ffff01ff04ff13ffff02ff0affff04ff02ffff04ff0dffff04ff1bff808080808080ffff01ff02ff0affff04ff02ffff04ff0dffff04ff1bff808080808080ff0180ff8080ff0180ffff02ffff03ff05ffff01ff10ffff02ff16ffff04ff02ffff04ff0dff80808080ffff02ffff03ff09ffff01ff0101ff8080ff018080ff8080ff0180ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff1effff04ff02ffff04ff09ff80808080ffff02ff1effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080");
3917pub const P2_M_OF_N_DELEGATE_DIRECT_HASH: [u8; 32] =
3918 hex!("0f199d5263ac1a62b077c159404a71abd3f9691cc57520bf1d4c5cb501504457");
3919
3920/// ```text
3921/// (mod
3922/// (
3923/// MORPHER ; For no morphing, 1
3924/// parent_parent_id
3925/// parent_inner_puz
3926/// parent_amount
3927/// parent_solution
3928/// )
3929///
3930/// (include condition_codes.clib)
3931/// (include curry-and-treehash.clib)
3932///
3933/// (c
3934/// (list ASSERT_MY_PARENT_ID
3935/// (calculate_coin_id parent_parent_id (a MORPHER (sha256tree parent_inner_puz)) parent_amount)
3936/// )
3937/// (a parent_inner_puz parent_solution)
3938/// )
3939/// )
3940/// ```
3941pub const P2_PARENT: [u8; 242] = hex!("ff02ffff01ff04ffff04ff08ffff04ffff02ff0affff04ff02ffff04ff0bffff04ffff02ff05ffff02ff0effff04ff02ffff04ff17ff8080808080ffff04ff2fff808080808080ff808080ffff02ff17ff5f8080ffff04ffff01ffff4720ffff02ffff03ffff22ffff09ffff0dff0580ff0c80ffff09ffff0dff0b80ff0c80ffff15ff17ffff0181ff8080ffff01ff0bff05ff0bff1780ffff01ff088080ff0180ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff0effff04ff02ffff04ff09ff80808080ffff02ff0effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080");
3942pub const P2_PARENT_HASH: [u8; 32] =
3943 hex!("b10ce2d0b18dcf8c21ddfaf55d9b9f0adcbf1e0beb55b1a8b9cad9bbff4e5f22");
3944
3945/// ```text
3946/// ;; Works with p2_singleton_via_delegated_puzzle
3947/// ;; When we have many p2_singleton coins and want to aggregate them together
3948///
3949/// ;; all coins make announcements of their puzhash, amount, and ID
3950/// ;; the aggregator coin (the one creating the output) creates an announcement of the ID of each merge coin
3951/// ;; each merge coin asserts that the aggregator has an announcement of their (the merge coin's) ID
3952/// ;; The merge coins each create an announcement of 0 (equivalent to announcing their coin ID)
3953/// ;; The aggregator asserts that there is a 0 announcement from each of the merge coins
3954///
3955/// ;; merge coin announces 0 <-> aggregator asserts that merge coin ID announces 0
3956/// ;; aggregator announces merge coin ID <-> merge coin asserts that aggregator announces my_id
3957///
3958/// (mod
3959/// (
3960/// my_id
3961/// my_puzhash
3962/// my_amount
3963/// list_of_parent_puzhash_amounts ; list of (parent_id puzhash amount) for the merge
3964/// output_parent_amount ; (parent_id amount) of the coin creating the output
3965/// )
3966///
3967/// (include condition_codes.clib)
3968/// (include curry-and-treehash.clib)
3969/// (include *standard-cl-21*)
3970///
3971/// (defun cons_announcements_to_output (coin_id output)
3972/// (c
3973/// (list ASSERT_COIN_ANNOUNCEMENT (sha256 coin_id 0))
3974/// (c
3975/// (list CREATE_COIN_ANNOUNCEMENT coin_id)
3976/// output
3977/// )
3978/// )
3979/// )
3980///
3981/// (defun for_parent_puzhash_amounts
3982/// (
3983/// my_puzhash
3984/// (@ coin_info_list ((@ first (parent puzhash amount)) . rest))
3985/// total
3986/// )
3987/// (if coin_info_list
3988/// (cons_announcements_to_output
3989/// (calculate_coin_id parent puzhash amount)
3990/// (for_parent_puzhash_amounts my_puzhash rest (+ total amount))
3991/// )
3992/// (list
3993/// (list ASSERT_HEIGHT_RELATIVE 5) ; TODO: should this be higher or lower?
3994/// (list CREATE_COIN my_puzhash total (list my_puzhash))
3995/// )
3996/// )
3997/// )
3998///
3999/// (defun-inline give_self_to_merge (my_id my_puzhash (@ output_info (parent amount)))
4000/// ;; Coins being merged are asserting the output coin id, and insisting it has the same puzhash as them
4001/// ;; This ensures that the puzzle which issues the CREATE_COIN condition is the same as this puzzle.
4002/// (list
4003/// (list CREATE_COIN_ANNOUNCEMENT 0)
4004/// (list ASSERT_COIN_ANNOUNCEMENT (sha256 (calculate_coin_id parent my_puzhash amount) my_id))
4005/// )
4006/// )
4007///
4008///
4009///
4010/// (c
4011/// (list ASSERT_MY_AMOUNT my_amount)
4012/// (c
4013/// (list ASSERT_MY_PUZZLEHASH my_puzhash)
4014/// (c
4015/// (list ASSERT_MY_COIN_ID my_id)
4016/// (if list_of_parent_puzhash_amounts
4017/// ; we are making the output
4018/// (for_parent_puzhash_amounts my_puzhash list_of_parent_puzhash_amounts my_amount)
4019/// ; we are letting another coin make the output
4020/// (give_self_to_merge my_id my_puzhash output_parent_amount)
4021/// )
4022/// )
4023/// )
4024/// )
4025///
4026/// )
4027/// ```
4028pub const P2_SINGLETON_AGGREGATOR: [u8; 574] = hex!("ff02ffff01ff04ffff04ffff0149ffff04ff17ffff01808080ffff04ffff04ffff0148ffff04ff0bffff01808080ffff04ffff04ffff0146ffff04ff05ffff01808080ffff02ffff03ff2fffff01ff02ffff01ff02ff0effff04ff02ffff04ff0bffff04ff2fffff04ff17ff808080808080ff0180ffff01ff02ffff01ff04ffff04ffff013cffff04ffff0180ffff01808080ffff04ffff04ffff013dffff04ffff0bffff02ff04ffff04ff02ffff04ffff05ff5f80ffff04ff0bffff04ffff05ffff06ff5f8080ff808080808080ff0580ffff01808080ffff01808080ff018080ff0180808080ffff04ffff01ffff02ffff03ffff22ffff09ffff0dff0580ffff012080ffff09ffff0dff0b80ffff012080ffff15ff17ffff0181ff8080ffff01ff02ffff01ff0bff05ff0bff1780ff0180ffff01ff02ffff01ff0880ff018080ff0180ffff04ffff04ffff013dffff04ffff0bff05ff8080ff808080ffff04ffff04ffff013cffff04ff05ff808080ff0b8080ff02ffff03ff0bffff01ff02ffff01ff02ff0affff04ff02ffff04ffff02ff04ffff04ff02ffff04ff23ffff04ff53ffff04ff8200b3ff808080808080ffff04ffff02ff0effff04ff02ffff04ff05ffff04ff1bffff04ffff10ff17ff8200b380ff808080808080ff8080808080ff0180ffff01ff02ffff01ff04ffff04ffff0152ffff04ffff0105ffff01808080ffff04ffff04ffff0133ffff04ff05ffff04ff17ffff04ffff04ff05ffff018080ffff018080808080ffff01808080ff018080ff0180ff018080");
4029pub const P2_SINGLETON_AGGREGATOR_HASH: [u8; 32] =
4030 hex!("f79a31fcfe3736cc75720617b4cdcb4376b4b8f8f71108617710612b909a4924");
4031
4032/// ```text
4033/// (mod (SINGLETON_MOD_HASH LAUNCHER_ID LAUNCHER_PUZZLE_HASH SECONDS_DELAY DELAYED_PUZZLE_HASH p1 my_id)
4034///
4035/// ;; This puzzle has two escape conditions: the regular "claim via singleton", and the
4036/// ;; delayed "claim via puzzle hash", delayed by a fixed number of seconds.
4037///
4038/// ; SINGLETON_MOD_HASH is the mod-hash for the singleton_top_layer puzzle
4039/// ; LAUNCHER_ID is the ID of the singleton we are committed to paying to
4040/// ; LAUNCHER_PUZZLE_HASH is the puzzle hash of the launcher
4041/// ; SECONDS_DELAY is the number of seconds before the coin can be spent with `DELAYED_PUZZLE_HASH`
4042/// ; DELAYED_PUZZLE_HASH is the puzzle hash of the delayed puzzle
4043/// ; if my_id is passed in as () then this signals that we are trying to do a delayed spend case
4044/// ; p1's meaning changes depending upon which case we're using
4045/// ; if we are paying to singleton then p1 is singleton_inner_puzzle_hash
4046/// ; if we are running the delayed case then p1 is the amount to output
4047///
4048/// (include condition_codes.clib)
4049/// (include curry-and-treehash.clib)
4050///
4051/// ;; return the full puzzlehash for a singleton with the innerpuzzle curried in
4052/// ; puzzle-hash-of-curried-function is imported from curry-and-treehash.clib
4053/// (defun-inline delayed_spend (SECONDS_DELAY DELAYED_PUZZLE_HASH amount)
4054/// (list
4055/// (list ASSERT_SECONDS_RELATIVE SECONDS_DELAY)
4056/// (list CREATE_COIN DELAYED_PUZZLE_HASH amount)
4057/// (list ASSERT_MY_AMOUNT amount)
4058/// )
4059/// )
4060///
4061/// ;; return the full puzzlehash for a singleton with the innerpuzzle curried in
4062/// ; puzzle-hash-of-curried-function is imported from curry-and-treehash.clib
4063/// (defun-inline calculate_full_puzzle_hash (SINGLETON_MOD_HASH LAUNCHER_ID LAUNCHER_PUZZLE_HASH inner_puzzle_hash)
4064/// (puzzle-hash-of-curried-function SINGLETON_MOD_HASH
4065/// inner_puzzle_hash
4066/// (sha256tree (c SINGLETON_MOD_HASH (c LAUNCHER_ID LAUNCHER_PUZZLE_HASH)))
4067/// )
4068/// )
4069///
4070/// (defun-inline claim_rewards (SINGLETON_MOD_HASH LAUNCHER_ID LAUNCHER_PUZZLE_HASH singleton_inner_puzzle_hash my_id)
4071/// (list
4072/// (list ASSERT_PUZZLE_ANNOUNCEMENT (sha256 (calculate_full_puzzle_hash SINGLETON_MOD_HASH LAUNCHER_ID LAUNCHER_PUZZLE_HASH singleton_inner_puzzle_hash) my_id))
4073/// (list CREATE_COIN_ANNOUNCEMENT '$')
4074/// (list ASSERT_MY_COIN_ID my_id))
4075/// )
4076///
4077/// ; main
4078/// (if my_id
4079/// (claim_rewards SINGLETON_MOD_HASH LAUNCHER_ID LAUNCHER_PUZZLE_HASH p1 my_id)
4080/// (delayed_spend SECONDS_DELAY DELAYED_PUZZLE_HASH p1)
4081/// )
4082/// )
4083/// ```
4084pub const P2_SINGLETON_OR_DELAYED_PUZHASH: [u8; 496] = hex!("ff02ffff01ff02ffff03ff82017fffff01ff04ffff04ff38ffff04ffff0bffff02ff2effff04ff02ffff04ff05ffff04ff81bfffff04ffff02ff3effff04ff02ffff04ffff04ff05ffff04ff0bff178080ff80808080ff808080808080ff82017f80ff808080ffff04ffff04ff3cffff01ff248080ffff04ffff04ff28ffff04ff82017fff808080ff80808080ffff01ff04ffff04ff24ffff04ff2fff808080ffff04ffff04ff2cffff04ff5fffff04ff81bfff80808080ffff04ffff04ff10ffff04ff81bfff808080ff8080808080ff0180ffff04ffff01ffffff49ff463fffff5002ff333cffff04ff0101ffff02ff02ffff03ff05ffff01ff02ff36ffff04ff02ffff04ff0dffff04ffff0bff26ffff0bff2aff1280ffff0bff26ffff0bff26ffff0bff2aff3a80ff0980ffff0bff26ff0bffff0bff2aff8080808080ff8080808080ffff010b80ff0180ffff0bff26ffff0bff2aff3480ffff0bff26ffff0bff26ffff0bff2aff3a80ff0580ffff0bff26ffff02ff36ffff04ff02ffff04ff07ffff04ffff0bff2aff2a80ff8080808080ffff0bff2aff8080808080ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff3effff04ff02ffff04ff09ff80808080ffff02ff3effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080");
4085pub const P2_SINGLETON_OR_DELAYED_PUZHASH_HASH: [u8; 32] =
4086 hex!("adb656e0211e2ab4f42069a4c5efc80dc907e7062be08bf1628c8e5b6d94d25b");
4087
4088/// ```text
4089/// ;; This puzzle holds an amount which can be spent via two spend paths:
4090/// ;; 1. to a delegated puzzle provided our owner singleton creates a puzzle announcement of this coin's id and the delegated puzzle.
4091/// ;; 2. coins of this puzzle type can be merged together without the owner singleton's permission. This spend type is useful for DAOs which use this puzzle to custody funds and want to keep a reasonable limit on the number of coins tracked by DAO wallets.
4092/// ;; The AGGREGATOR_PUZZLE is curried in to preserve generality and so its logic can be updated without requiring any change to the spend to delegated path. Optionally the Aggregator puzzle can be `(x)` to close off this spend path
4093///
4094/// (mod (
4095/// SINGLETON_STRUCT
4096/// AGGREGATOR_PUZZLE
4097/// aggregator_solution ; (my_id my_puzhash list_of_parent_puzhash_amounts my_amount)
4098/// singleton_inner_puzhash
4099/// delegated_puzzle
4100/// delegated_solution
4101/// my_id
4102/// )
4103///
4104/// (include condition_codes.clib)
4105/// (include curry-and-treehash.clib)
4106///
4107/// (defun-inline calculate_full_puzzle_hash (SINGLETON_STRUCT singleton_inner_puzhash)
4108/// (puzzle-hash-of-curried-function (f SINGLETON_STRUCT)
4109/// singleton_inner_puzhash
4110/// (sha256tree SINGLETON_STRUCT)
4111/// )
4112/// )
4113///
4114/// (if aggregator_solution
4115/// ; we are merging coins to make a larger coin
4116/// (a AGGREGATOR_PUZZLE aggregator_solution)
4117/// ; we are being spent by our singleton
4118/// (c
4119/// (list
4120/// ASSERT_PUZZLE_ANNOUNCEMENT
4121/// (sha256
4122/// (calculate_full_puzzle_hash SINGLETON_STRUCT singleton_inner_puzhash)
4123/// (sha256tree (list my_id (sha256tree delegated_puzzle)))
4124/// )
4125/// )
4126/// (c
4127/// (list CREATE_COIN_ANNOUNCEMENT '$')
4128/// (c
4129/// (list ASSERT_MY_COIN_ID my_id)
4130/// (a delegated_puzzle delegated_solution)
4131/// )
4132/// )
4133/// )
4134/// )
4135/// )
4136/// ```
4137pub const P2_SINGLETON_VIA_DELEGATED_PUZZLE: [u8; 474] = hex!("ff02ffff01ff02ffff03ff17ffff01ff02ff0bff1780ffff01ff04ffff04ff18ffff04ffff0bffff02ff2effff04ff02ffff04ff09ffff04ff2fffff04ffff02ff3effff04ff02ffff04ff05ff80808080ff808080808080ffff02ff3effff04ff02ffff04ffff04ff82017fffff04ffff02ff3effff04ff02ffff04ff5fff80808080ff808080ff8080808080ff808080ffff04ffff04ff2cffff01ff248080ffff04ffff04ff10ffff04ff82017fff808080ffff02ff5fff81bf8080808080ff0180ffff04ffff01ffffff463fff02ff3c04ffff01ff0102ffff02ffff03ff05ffff01ff02ff16ffff04ff02ffff04ff0dffff04ffff0bff3affff0bff12ff3c80ffff0bff3affff0bff3affff0bff12ff2a80ff0980ffff0bff3aff0bffff0bff12ff8080808080ff8080808080ffff010b80ff0180ffff0bff3affff0bff12ff1480ffff0bff3affff0bff3affff0bff12ff2a80ff0580ffff0bff3affff02ff16ffff04ff02ffff04ff07ffff04ffff0bff12ff1280ff8080808080ffff0bff12ff8080808080ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff3effff04ff02ffff04ff09ff80808080ffff02ff3effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080");
4138pub const P2_SINGLETON_VIA_DELEGATED_PUZZLE_HASH: [u8; 32] =
4139 hex!("9590eaa169e45b655a31d3c06bbd355a3e2b2e3e410d3829748ce08ab249c39e");
4140
4141/// ```text
4142/// (mod (SINGLETON_MOD_HASH LAUNCHER_ID LAUNCHER_PUZZLE_HASH singleton_inner_puzzle_hash my_id)
4143///
4144/// ; SINGLETON_MOD_HASH is the mod-hash for the singleton_top_layer puzzle
4145/// ; LAUNCHER_ID is the ID of the singleton we are committed to paying to
4146/// ; LAUNCHER_PUZZLE_HASH is the puzzle hash of the launcher
4147/// ; singleton_inner_puzzle_hash is the innerpuzzlehash for our singleton at the current time
4148/// ; my_id is the coin_id of the coin that this puzzle is locked into
4149///
4150/// (include condition_codes.clib)
4151/// (include curry-and-treehash.clib)
4152///
4153/// ;; return the full puzzlehash for a singleton with the innerpuzzle curried in
4154/// ; puzzle-hash-of-curried-function is imported from curry-and-treehash.clib
4155/// (defun-inline calculate_full_puzzle_hash (SINGLETON_MOD_HASH LAUNCHER_ID LAUNCHER_PUZZLE_HASH inner_puzzle_hash)
4156/// (puzzle-hash-of-curried-function SINGLETON_MOD_HASH
4157/// inner_puzzle_hash
4158/// (sha256tree (c SINGLETON_MOD_HASH (c LAUNCHER_ID LAUNCHER_PUZZLE_HASH)))
4159/// )
4160/// )
4161///
4162/// (defun-inline claim_rewards (SINGLETON_MOD_HASH LAUNCHER_ID LAUNCHER_PUZZLE_HASH singleton_inner_puzzle_hash my_id)
4163/// (list
4164/// (list ASSERT_PUZZLE_ANNOUNCEMENT (sha256 (calculate_full_puzzle_hash SINGLETON_MOD_HASH LAUNCHER_ID LAUNCHER_PUZZLE_HASH singleton_inner_puzzle_hash) my_id))
4165/// (list CREATE_COIN_ANNOUNCEMENT '$')
4166/// (list ASSERT_MY_COIN_ID my_id))
4167/// )
4168///
4169/// ; main
4170/// (claim_rewards SINGLETON_MOD_HASH LAUNCHER_ID LAUNCHER_PUZZLE_HASH singleton_inner_puzzle_hash my_id)
4171/// )
4172/// ```
4173pub const P2_SINGLETON: [u8; 403] = hex!("ff02ffff01ff04ffff04ff18ffff04ffff0bffff02ff2effff04ff02ffff04ff05ffff04ff2fffff04ffff02ff3effff04ff02ffff04ffff04ff05ffff04ff0bff178080ff80808080ff808080808080ff5f80ff808080ffff04ffff04ff2cffff01ff248080ffff04ffff04ff10ffff04ff5fff808080ff80808080ffff04ffff01ffffff463fff02ff3c04ffff01ff0102ffff02ffff03ff05ffff01ff02ff16ffff04ff02ffff04ff0dffff04ffff0bff3affff0bff12ff3c80ffff0bff3affff0bff3affff0bff12ff2a80ff0980ffff0bff3aff0bffff0bff12ff8080808080ff8080808080ffff010b80ff0180ffff0bff3affff0bff12ff1480ffff0bff3affff0bff3affff0bff12ff2a80ff0580ffff0bff3affff02ff16ffff04ff02ffff04ff07ffff04ffff0bff12ff1280ff8080808080ffff0bff12ff8080808080ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff3effff04ff02ffff04ff09ff80808080ffff02ff3effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080");
4174pub const P2_SINGLETON_HASH: [u8; 32] =
4175 hex!("40f828d8dd55603f4ff9fbf6b73271e904e69406982f4fbefae2c8dcceaf9834");
4176
4177/// ```text
4178/// (mod
4179/// (inner_puzzle_hash inner_puzzle inner_puzzle_solution)
4180///
4181/// ;; hash a tree
4182/// ;; This is used to calculate a puzzle hash given a puzzle program.
4183/// (defun sha256tree1
4184/// (TREE)
4185/// (if (l TREE)
4186/// (sha256 2 (sha256tree1 (f TREE)) (sha256tree1 (r TREE)))
4187/// (sha256 1 TREE)
4188/// )
4189/// )
4190///
4191/// (if (= inner_puzzle_hash (sha256tree1 inner_puzzle))
4192/// (a inner_puzzle inner_puzzle_solution)
4193/// (x)
4194/// )
4195/// )
4196/// ```
4197pub const P2_PUZZLE_HASH: [u8; 143] = hex!("ff02ffff01ff02ffff03ffff09ff05ffff02ff02ffff04ff02ffff04ff0bff8080808080ffff01ff02ff0bff1780ffff01ff088080ff0180ffff04ffff01ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff02ffff04ff02ffff04ff09ff80808080ffff02ff02ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080");
4198pub const P2_PUZZLE_HASH_HASH: [u8; 32] =
4199 hex!("13e29a62b42cd2ef72a79e4bacdc59733ca6310d65af83d349360d36ec622363");
4200
4201/// ```text
4202/// (mod notarized_payments
4203/// ;; `notarized_payments` is a list of notarized coin payments
4204/// ;; a notarized coin payment is `(nonce . ((puzzle_hash amount ...) (puzzle_hash amount ...) ...))`
4205/// ;; Each notarized coin payment creates some `(CREATE_COIN puzzle_hash amount ...)` payments
4206/// ;; and a `(CREATE_PUZZLE_ANNOUNCEMENT (sha256tree notarized_coin_payment))` announcement
4207/// ;; The idea is the other side of this trade requires observing the announcement from a
4208/// ;; `settlement_payments` puzzle hash as a condition of one or more coin spends.
4209///
4210/// (include condition_codes.clib)
4211/// (include utility_macros.clib)
4212///
4213/// (defun sha256tree (TREE)
4214/// (if (l TREE)
4215/// (sha256 2 (sha256tree (f TREE)) (sha256tree (r TREE)))
4216/// (sha256 1 TREE)
4217/// )
4218/// )
4219///
4220/// (defun create_coins_for_payment (payment_params so_far)
4221/// (if payment_params
4222/// (assert (> (f (r (f payment_params))) 0) ; assert the amount is positive
4223/// ; then
4224/// (c (c CREATE_COIN (f payment_params)) (create_coins_for_payment (r payment_params) so_far))
4225/// )
4226/// so_far
4227/// )
4228/// )
4229///
4230/// (defun-inline create_announcement_for_payment (notarized_payment)
4231/// (list CREATE_PUZZLE_ANNOUNCEMENT
4232/// (sha256tree notarized_payment))
4233/// )
4234///
4235/// (defun-inline augment_condition_list (notarized_payment so_far)
4236/// (c
4237/// (create_announcement_for_payment notarized_payment)
4238/// (create_coins_for_payment (r notarized_payment) so_far)
4239/// )
4240/// )
4241///
4242/// (defun construct_condition_list (notarized_payments)
4243/// (if notarized_payments
4244/// (augment_condition_list (f notarized_payments) (construct_condition_list (r notarized_payments)))
4245/// ()
4246/// )
4247/// )
4248///
4249/// (construct_condition_list notarized_payments)
4250/// )
4251/// ```
4252pub const SETTLEMENT_PAYMENT: [u8; 293] = hex!("ff02ffff01ff02ff0affff04ff02ffff04ff03ff80808080ffff04ffff01ffff333effff02ffff03ff05ffff01ff04ffff04ff0cffff04ffff02ff1effff04ff02ffff04ff09ff80808080ff808080ffff02ff16ffff04ff02ffff04ff19ffff04ffff02ff0affff04ff02ffff04ff0dff80808080ff808080808080ff8080ff0180ffff02ffff03ff05ffff01ff02ffff03ffff15ff29ff8080ffff01ff04ffff04ff08ff0980ffff02ff16ffff04ff02ffff04ff0dffff04ff0bff808080808080ffff01ff088080ff0180ffff010b80ff0180ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff1effff04ff02ffff04ff09ff80808080ffff02ff1effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080");
4253pub const SETTLEMENT_PAYMENT_HASH: [u8; 32] =
4254 hex!("cfbfdeed5c4ca2de3d0bf520b9cb4bb7743a359bd2e6a188d19ce7dffc21d3e7");
4255
4256/// ```text
4257/// (mod (singleton_full_puzzle_hash amount key_value_list)
4258///
4259/// (include condition_codes.clib)
4260///
4261/// ; takes a lisp tree and returns the hash of it
4262/// (defun sha256tree1 (TREE)
4263/// (if (l TREE)
4264/// (sha256 2 (sha256tree1 (f TREE)) (sha256tree1 (r TREE)))
4265/// (sha256 1 TREE)
4266/// )
4267/// )
4268///
4269/// ; main
4270/// (list (list CREATE_COIN singleton_full_puzzle_hash amount)
4271/// (list CREATE_COIN_ANNOUNCEMENT (sha256tree1 (list singleton_full_puzzle_hash amount key_value_list))))
4272/// )
4273/// ```
4274pub const SINGLETON_LAUNCHER: [u8; 175] = hex!("ff02ffff01ff04ffff04ff04ffff04ff05ffff04ff0bff80808080ffff04ffff04ff0affff04ffff02ff0effff04ff02ffff04ffff04ff05ffff04ff0bffff04ff17ff80808080ff80808080ff808080ff808080ffff04ffff01ff33ff3cff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff0effff04ff02ffff04ff09ff80808080ffff02ff0effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080");
4275pub const SINGLETON_LAUNCHER_HASH: [u8; 32] =
4276 hex!("eff07522495060c066f66f32acc2a77e3a3e737aca8baea4d1a64ea4cdc13da9");
4277
4278/// ```text
4279/// (mod (SINGLETON_STRUCT INNER_PUZZLE lineage_proof my_amount inner_solution)
4280///
4281/// ;; SINGLETON_STRUCT = (MOD_HASH . (LAUNCHER_ID . LAUNCHER_PUZZLE_HASH))
4282///
4283/// ; SINGLETON_STRUCT, INNER_PUZZLE are curried in by the wallet
4284///
4285/// ; EXAMPLE SOLUTION '(0xfadeddab 0xdeadbeef 1 (0xdeadbeef 200) 50 ((51 0xfadeddab 100) (60 "trash") (51 deadbeef 0)))'
4286///
4287///
4288/// ; This puzzle is a wrapper around an inner smart puzzle which guarantees uniqueness.
4289/// ; It takes its singleton identity from a coin with a launcher puzzle which guarantees that it is unique.
4290///
4291/// (include condition_codes.clib)
4292/// (include curry-and-treehash.clib) ; also imports the constant ONE == 1
4293/// (include singleton_truths.clib)
4294/// (include utility_macros.clib)
4295///
4296/// (defun-inline mod_hash_for_singleton_struct (SINGLETON_STRUCT) (f SINGLETON_STRUCT))
4297/// (defun-inline launcher_id_for_singleton_struct (SINGLETON_STRUCT) (f (r SINGLETON_STRUCT)))
4298/// (defun-inline launcher_puzzle_hash_for_singleton_struct (SINGLETON_STRUCT) (r (r SINGLETON_STRUCT)))
4299///
4300/// ;; return the full puzzlehash for a singleton with the innerpuzzle curried in
4301/// ; puzzle-hash-of-curried-function is imported from curry-and-treehash.clib
4302/// (defun-inline calculate_full_puzzle_hash (SINGLETON_STRUCT inner_puzzle_hash)
4303/// (puzzle-hash-of-curried-function (mod_hash_for_singleton_struct SINGLETON_STRUCT)
4304/// inner_puzzle_hash
4305/// (sha256tree SINGLETON_STRUCT)
4306/// )
4307/// )
4308///
4309/// (defun-inline morph_condition (condition SINGLETON_STRUCT)
4310/// (c (f condition) (c (calculate_full_puzzle_hash SINGLETON_STRUCT (f (r condition))) (r (r condition))))
4311/// )
4312///
4313/// (defun is_odd_create_coin (condition)
4314/// (and (= (f condition) CREATE_COIN) (logand (f (r (r condition))) 1))
4315/// )
4316///
4317/// ; Assert exactly one output with odd value exists - ignore it if value is -113
4318///
4319/// ;; this function iterates over the output conditions from the inner puzzle & solution
4320/// ;; and both checks that exactly one unique singleton child is created (with odd valued output),
4321/// ;; and wraps the inner puzzle with this same singleton wrapper puzzle
4322/// ;;
4323/// ;; The special case where the output value is -113 means a child singleton is intentionally
4324/// ;; *NOT* being created, thus forever ending this singleton's existence
4325///
4326/// (defun check_and_morph_conditions_for_singleton (SINGLETON_STRUCT conditions has_odd_output_been_found)
4327/// (if conditions
4328/// ; check if it's an odd create coin
4329/// (if (is_odd_create_coin (f conditions))
4330/// ; check that we haven't already found one
4331/// (assert (not has_odd_output_been_found)
4332/// ; then
4333/// (if (= (f (r (r (f conditions)))) -113)
4334/// ; If it's the melt condition we don't bother prepending this condition
4335/// (check_and_morph_conditions_for_singleton SINGLETON_STRUCT (r conditions) ONE)
4336/// ; If it isn't the melt condition, we morph it and prepend it
4337/// (c (morph_condition (f conditions) SINGLETON_STRUCT) (check_and_morph_conditions_for_singleton SINGLETON_STRUCT (r conditions) ONE))
4338/// )
4339/// )
4340/// (c (f conditions) (check_and_morph_conditions_for_singleton SINGLETON_STRUCT (r conditions) has_odd_output_been_found))
4341/// )
4342/// (assert has_odd_output_been_found ())
4343/// )
4344/// )
4345///
4346/// ; assert that either the lineage proof is for a parent singleton, or, if it's for the launcher, verify it matched our launcher ID
4347/// ; then return a condition asserting it actually is our parent ID
4348/// (defun verify_lineage_proof (SINGLETON_STRUCT parent_id is_not_launcher)
4349/// (assert (any is_not_launcher (= parent_id (launcher_id_for_singleton_struct SINGLETON_STRUCT)))
4350/// ; then
4351/// (list ASSERT_MY_PARENT_ID parent_id)
4352/// )
4353/// )
4354///
4355/// ; main
4356///
4357/// ; if our value is not an odd amount then we are invalid
4358/// (assert (logand my_amount ONE)
4359/// ; then
4360/// (c
4361/// (list ASSERT_MY_AMOUNT my_amount)
4362/// (c
4363/// ; Verify the lineage proof by asserting our parent's ID
4364/// (verify_lineage_proof
4365/// SINGLETON_STRUCT
4366/// ; calculate our parent's ID
4367/// (calculate_coin_id
4368/// (parent_info_for_lineage_proof lineage_proof)
4369/// (if (is_not_eve_proof lineage_proof) ; The PH calculation changes based on the lineage proof
4370/// (calculate_full_puzzle_hash SINGLETON_STRUCT (puzzle_hash_for_lineage_proof lineage_proof)) ; wrap the innerpuz in a singleton
4371/// (launcher_puzzle_hash_for_singleton_struct SINGLETON_STRUCT) ; Use the static launcher puzzle hash
4372/// )
4373/// (if (is_not_eve_proof lineage_proof) ; The position of "amount" changes based on the type on lineage proof
4374/// (amount_for_lineage_proof lineage_proof)
4375/// (amount_for_eve_proof lineage_proof)
4376/// )
4377/// )
4378/// (is_not_eve_proof lineage_proof)
4379/// )
4380/// ; finally check all of the conditions for a single odd output to wrap
4381/// (check_and_morph_conditions_for_singleton SINGLETON_STRUCT (a INNER_PUZZLE inner_solution) 0)
4382/// )
4383/// )
4384/// )
4385/// )
4386/// ```
4387pub const SINGLETON_TOP_LAYER_V1_1: [u8; 967] = hex!("ff02ffff01ff02ffff03ffff18ff2fff3480ffff01ff04ffff04ff20ffff04ff2fff808080ffff04ffff02ff3effff04ff02ffff04ff05ffff04ffff02ff2affff04ff02ffff04ff27ffff04ffff02ffff03ff77ffff01ff02ff36ffff04ff02ffff04ff09ffff04ff57ffff04ffff02ff2effff04ff02ffff04ff05ff80808080ff808080808080ffff011d80ff0180ffff04ffff02ffff03ff77ffff0181b7ffff015780ff0180ff808080808080ffff04ff77ff808080808080ffff02ff3affff04ff02ffff04ff05ffff04ffff02ff0bff5f80ffff01ff8080808080808080ffff01ff088080ff0180ffff04ffff01ffffffff4947ff0233ffff0401ff0102ffffff20ff02ffff03ff05ffff01ff02ff32ffff04ff02ffff04ff0dffff04ffff0bff3cffff0bff34ff2480ffff0bff3cffff0bff3cffff0bff34ff2c80ff0980ffff0bff3cff0bffff0bff34ff8080808080ff8080808080ffff010b80ff0180ffff02ffff03ffff22ffff09ffff0dff0580ff2280ffff09ffff0dff0b80ff2280ffff15ff17ffff0181ff8080ffff01ff0bff05ff0bff1780ffff01ff088080ff0180ff02ffff03ff0bffff01ff02ffff03ffff02ff26ffff04ff02ffff04ff13ff80808080ffff01ff02ffff03ffff20ff1780ffff01ff02ffff03ffff09ff81b3ffff01818f80ffff01ff02ff3affff04ff02ffff04ff05ffff04ff1bffff04ff34ff808080808080ffff01ff04ffff04ff23ffff04ffff02ff36ffff04ff02ffff04ff09ffff04ff53ffff04ffff02ff2effff04ff02ffff04ff05ff80808080ff808080808080ff738080ffff02ff3affff04ff02ffff04ff05ffff04ff1bffff04ff34ff8080808080808080ff0180ffff01ff088080ff0180ffff01ff04ff13ffff02ff3affff04ff02ffff04ff05ffff04ff1bffff04ff17ff8080808080808080ff0180ffff01ff02ffff03ff17ff80ffff01ff088080ff018080ff0180ffffff02ffff03ffff09ff09ff3880ffff01ff02ffff03ffff18ff2dffff010180ffff01ff0101ff8080ff0180ff8080ff0180ff0bff3cffff0bff34ff2880ffff0bff3cffff0bff3cffff0bff34ff2c80ff0580ffff0bff3cffff02ff32ffff04ff02ffff04ff07ffff04ffff0bff34ff3480ff8080808080ffff0bff34ff8080808080ffff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff2effff04ff02ffff04ff09ff80808080ffff02ff2effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff02ffff03ffff21ff17ffff09ff0bff158080ffff01ff04ff30ffff04ff0bff808080ffff01ff088080ff0180ff018080");
4388pub const SINGLETON_TOP_LAYER_V1_1_HASH: [u8; 32] =
4389 hex!("7faa3253bfddd1e0decb0906b2dc6247bbc4cf608f58345d173adb63e8b47c9f");
4390
4391/// ```text
4392/// (mod (SINGLETON_STRUCT INNER_PUZZLE lineage_proof my_amount inner_solution)
4393///
4394/// ;; SINGLETON_STRUCT = (MOD_HASH . (LAUNCHER_ID . LAUNCHER_PUZZLE_HASH))
4395///
4396/// ; SINGLETON_STRUCT, INNER_PUZZLE are curried in by the wallet
4397///
4398/// ; EXAMPLE SOLUTION '(0xfadeddab 0xdeadbeef 1 (0xdeadbeef 200) 50 ((51 0xfadeddab 100) (60 "trash") (51 deadbeef 0)))'
4399///
4400///
4401/// ; This puzzle is a wrapper around an inner smart puzzle which guarantees uniqueness.
4402/// ; It takes its singleton identity from a coin with a launcher puzzle which guarantees that it is unique.
4403///
4404/// (include condition_codes.clib)
4405/// (include curry-and-treehash.clib)
4406/// (include singleton_truths.clib)
4407///
4408/// ; takes a lisp tree and returns the hash of it
4409/// (defun sha256tree1 (TREE)
4410/// (if (l TREE)
4411/// (sha256 2 (sha256tree1 (f TREE)) (sha256tree1 (r TREE)))
4412/// (sha256 1 TREE)
4413/// )
4414/// )
4415///
4416/// ; "assert" is a macro that wraps repeated instances of "if"
4417/// ; usage: (assert A0 A1 ... An R)
4418/// ; all of A0, A1, ... An must evaluate to non-null, or an exception is raised
4419/// ; return the value of R (if we get that far)
4420///
4421/// (defmacro assert items
4422/// (if (r items)
4423/// (list if (f items) (c assert (r items)) (q . (x)))
4424/// (f items)
4425/// )
4426/// )
4427///
4428/// (defun-inline mod_hash_for_singleton_struct (SINGLETON_STRUCT) (f SINGLETON_STRUCT))
4429/// (defun-inline launcher_id_for_singleton_struct (SINGLETON_STRUCT) (f (r SINGLETON_STRUCT)))
4430/// (defun-inline launcher_puzzle_hash_for_singleton_struct (SINGLETON_STRUCT) (r (r SINGLETON_STRUCT)))
4431///
4432/// ;; return the full puzzlehash for a singleton with the innerpuzzle curried in
4433/// ; puzzle-hash-of-curried-function is imported from curry-and-treehash.clib
4434/// (defun-inline calculate_full_puzzle_hash (SINGLETON_STRUCT inner_puzzle_hash)
4435/// (puzzle-hash-of-curried-function (mod_hash_for_singleton_struct SINGLETON_STRUCT)
4436/// inner_puzzle_hash
4437/// (sha256tree1 SINGLETON_STRUCT)
4438/// )
4439/// )
4440///
4441/// ; assembles information from the solution to create our own full ID including asserting our parent is a singleton
4442/// (defun create_my_ID (SINGLETON_STRUCT full_puzzle_hash parent_parent parent_inner_puzzle_hash parent_amount my_amount)
4443/// (sha256 (sha256 parent_parent (calculate_full_puzzle_hash SINGLETON_STRUCT parent_inner_puzzle_hash) parent_amount)
4444/// full_puzzle_hash
4445/// my_amount)
4446/// )
4447///
4448/// ;; take a boolean and a non-empty list of conditions
4449/// ;; strip off the first condition if a boolean is set
4450/// ;; this is used to remove `(CREATE_COIN xxx -113)`
4451/// ;; pretty sneaky, eh?
4452/// (defun strip_first_condition_if (boolean condition_list)
4453/// (if boolean
4454/// (r condition_list)
4455/// condition_list
4456/// )
4457/// )
4458///
4459/// (defun-inline morph_condition (condition SINGLETON_STRUCT)
4460/// (list (f condition) (calculate_full_puzzle_hash SINGLETON_STRUCT (f (r condition))) (f (r (r condition))))
4461/// )
4462///
4463/// ;; return the value of the coin created if this is a `CREATE_COIN` condition, or 0 otherwise
4464/// (defun-inline created_coin_value_or_0 (condition)
4465/// (if (= (f condition) CREATE_COIN)
4466/// (f (r (r condition)))
4467/// 0
4468/// )
4469/// )
4470///
4471/// ;; Returns a (bool . bool)
4472/// (defun odd_cons_m113 (output_amount)
4473/// (c
4474/// (= (logand output_amount 1) 1) ;; is it odd?
4475/// (= output_amount -113) ;; is it the escape value?
4476/// )
4477/// )
4478///
4479/// ; Assert exactly one output with odd value exists - ignore it if value is -113
4480///
4481/// ;; this function iterates over the output conditions from the inner puzzle & solution
4482/// ;; and both checks that exactly one unique singleton child is created (with odd valued output),
4483/// ;; and wraps the inner puzzle with this same singleton wrapper puzzle
4484/// ;;
4485/// ;; The special case where the output value is -113 means a child singleton is intentionally
4486/// ;; *NOT* being created, thus forever ending this singleton's existence
4487///
4488/// (defun check_and_morph_conditions_for_singleton (SINGLETON_STRUCT conditions has_odd_output_been_found)
4489/// (if conditions
4490/// (morph_next_condition SINGLETON_STRUCT conditions has_odd_output_been_found (odd_cons_m113 (created_coin_value_or_0 (f conditions))))
4491/// (if has_odd_output_been_found
4492/// 0
4493/// (x) ;; no odd output found
4494/// )
4495/// )
4496/// )
4497///
4498/// ;; a continuation of `check_and_morph_conditions_for_singleton` with booleans `is_output_odd` and `is_output_m113`
4499/// ;; precalculated
4500/// (defun morph_next_condition (SINGLETON_STRUCT conditions has_odd_output_been_found (is_output_odd . is_output_m113))
4501/// (assert
4502/// (not (all is_output_odd has_odd_output_been_found))
4503/// (strip_first_condition_if
4504/// is_output_m113
4505/// (c (if is_output_odd
4506/// (morph_condition (f conditions) SINGLETON_STRUCT)
4507/// (f conditions)
4508/// )
4509/// (check_and_morph_conditions_for_singleton SINGLETON_STRUCT (r conditions) (any is_output_odd has_odd_output_been_found))
4510/// )
4511/// )
4512/// )
4513/// )
4514///
4515/// ; this final stager asserts our ID
4516/// ; it also runs the innerpuz with the innersolution with the "truths" added
4517/// ; it then passes that output conditions from the innerpuz to the morph conditions function
4518/// (defun stager_three (SINGLETON_STRUCT lineage_proof my_id full_puzhash innerpuzhash my_amount INNER_PUZZLE inner_solution)
4519/// (c (list ASSERT_MY_COIN_ID my_id) (check_and_morph_conditions_for_singleton SINGLETON_STRUCT (a INNER_PUZZLE (c (truth_data_to_truth_struct my_id full_puzhash innerpuzhash my_amount lineage_proof SINGLETON_STRUCT) inner_solution)) 0))
4520/// )
4521///
4522/// ; this checks whether we are an eve spend or not and calculates our full coin ID appropriately and passes it on to the final stager
4523/// ; if we are the eve spend it also adds the additional checks that our parent's puzzle is the standard launcher format and that out parent ID is the same as our singleton ID
4524///
4525/// (defun stager_two (SINGLETON_STRUCT lineage_proof full_puzhash innerpuzhash my_amount INNER_PUZZLE inner_solution)
4526/// (stager_three
4527/// SINGLETON_STRUCT
4528/// lineage_proof
4529/// (if (is_not_eve_proof lineage_proof)
4530/// (create_my_ID
4531/// SINGLETON_STRUCT
4532/// full_puzhash
4533/// (parent_info_for_lineage_proof lineage_proof)
4534/// (puzzle_hash_for_lineage_proof lineage_proof)
4535/// (amount_for_lineage_proof lineage_proof)
4536/// my_amount
4537/// )
4538/// (if (=
4539/// (launcher_id_for_singleton_struct SINGLETON_STRUCT)
4540/// (sha256 (parent_info_for_eve_proof lineage_proof) (launcher_puzzle_hash_for_singleton_struct SINGLETON_STRUCT) (amount_for_eve_proof lineage_proof))
4541/// )
4542/// (sha256 (launcher_id_for_singleton_struct SINGLETON_STRUCT) full_puzhash my_amount)
4543/// (x)
4544/// )
4545/// )
4546/// full_puzhash
4547/// innerpuzhash
4548/// my_amount
4549/// INNER_PUZZLE
4550/// inner_solution
4551/// )
4552/// )
4553///
4554/// ; this calculates our current full puzzle hash and passes it to stager two
4555/// (defun stager_one (SINGLETON_STRUCT lineage_proof my_innerpuzhash my_amount INNER_PUZZLE inner_solution)
4556/// (stager_two SINGLETON_STRUCT lineage_proof (calculate_full_puzzle_hash SINGLETON_STRUCT my_innerpuzhash) my_innerpuzhash my_amount INNER_PUZZLE inner_solution)
4557/// )
4558///
4559///
4560/// ; main
4561///
4562/// ; if our value is not an odd amount then we are invalid
4563/// ; this calculates my_innerpuzhash and passes all values to stager_one
4564/// (if (logand my_amount 1)
4565/// (stager_one SINGLETON_STRUCT lineage_proof (sha256tree1 INNER_PUZZLE) my_amount INNER_PUZZLE inner_solution)
4566/// (x)
4567/// )
4568/// )
4569/// ```
4570pub const SINGLETON_TOP_LAYER: [u8; 1168] = hex!("ff02ffff01ff02ffff03ffff18ff2fffff010180ffff01ff02ff36ffff04ff02ffff04ff05ffff04ff17ffff04ffff02ff26ffff04ff02ffff04ff0bff80808080ffff04ff2fffff04ff0bffff04ff5fff808080808080808080ffff01ff088080ff0180ffff04ffff01ffffffff4602ff3304ffff0101ff02ffff02ffff03ff05ffff01ff02ff5cffff04ff02ffff04ff0dffff04ffff0bff2cffff0bff24ff3880ffff0bff2cffff0bff2cffff0bff24ff3480ff0980ffff0bff2cff0bffff0bff24ff8080808080ff8080808080ffff010b80ff0180ff02ffff03ff0bffff01ff02ff32ffff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ffff02ff2affff04ff02ffff04ffff02ffff03ffff09ff23ff2880ffff0181b3ff8080ff0180ff80808080ff80808080808080ffff01ff02ffff03ff17ff80ffff01ff088080ff018080ff0180ffffffff0bffff0bff17ffff02ff3affff04ff02ffff04ff09ffff04ff2fffff04ffff02ff26ffff04ff02ffff04ff05ff80808080ff808080808080ff5f80ff0bff81bf80ff02ffff03ffff20ffff22ff4fff178080ffff01ff02ff7effff04ff02ffff04ff6fffff04ffff04ffff02ffff03ff4fffff01ff04ff23ffff04ffff02ff3affff04ff02ffff04ff09ffff04ff53ffff04ffff02ff26ffff04ff02ffff04ff05ff80808080ff808080808080ffff04ff81b3ff80808080ffff011380ff0180ffff02ff7cffff04ff02ffff04ff05ffff04ff1bffff04ffff21ff4fff1780ff80808080808080ff8080808080ffff01ff088080ff0180ffff04ffff09ffff18ff05ffff010180ffff010180ffff09ff05ffff01818f8080ff0bff2cffff0bff24ff3080ffff0bff2cffff0bff2cffff0bff24ff3480ff0580ffff0bff2cffff02ff5cffff04ff02ffff04ff07ffff04ffff0bff24ff2480ff8080808080ffff0bff24ff8080808080ffffff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff26ffff04ff02ffff04ff09ff80808080ffff02ff26ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff02ff5effff04ff02ffff04ff05ffff04ff0bffff04ffff02ff3affff04ff02ffff04ff09ffff04ff17ffff04ffff02ff26ffff04ff02ffff04ff05ff80808080ff808080808080ffff04ff17ffff04ff2fffff04ff5fffff04ff81bfff80808080808080808080ffff04ffff04ff20ffff04ff17ff808080ffff02ff7cffff04ff02ffff04ff05ffff04ffff02ff82017fffff04ffff04ffff04ff17ff2f80ffff04ffff04ff5fff81bf80ffff04ff0bff05808080ff8202ff8080ffff01ff80808080808080ffff02ff2effff04ff02ffff04ff05ffff04ff0bffff04ffff02ffff03ff3bffff01ff02ff22ffff04ff02ffff04ff05ffff04ff17ffff04ff13ffff04ff2bffff04ff5bffff04ff5fff808080808080808080ffff01ff02ffff03ffff09ff15ffff0bff13ff1dff2b8080ffff01ff0bff15ff17ff5f80ffff01ff088080ff018080ff0180ffff04ff17ffff04ff2fffff04ff5fffff04ff81bfffff04ff82017fff8080808080808080808080ff02ffff03ff05ffff011bffff010b80ff0180ff018080");
4571pub const SINGLETON_TOP_LAYER_HASH: [u8; 32] =
4572 hex!("24e044101e57b3d8c908b8a38ad57848afd29d3eecc439dba45f4412df4954fd");
4573
4574/// ```text
4575/// (mod
4576/// (
4577/// MERKLE_ROOT
4578/// delegated_puzzle_hash
4579/// merkle_proof
4580/// member_puzzle
4581/// member_solution
4582/// )
4583///
4584/// (include merkle_utils.clib)
4585///
4586/// ; takes a lisp tree and returns the hash of it
4587/// (defun sha256tree (TREE)
4588/// (if (l TREE)
4589/// (sha256 2 (sha256tree (f TREE)) (sha256tree (r TREE)))
4590/// (sha256 1 TREE)))
4591///
4592/// (if (= MERKLE_ROOT (simplify_merkle_proof (sha256tree member_puzzle) merkle_proof))
4593/// (a member_puzzle (c delegated_puzzle_hash member_solution))
4594/// (x)
4595/// )
4596///
4597/// )
4598/// ```
4599pub const ONE_OF_N: [u8; 286] = hex!("ff02ffff01ff02ffff03ffff09ff05ffff02ff06ffff04ff02ffff04ffff0bffff0101ffff02ff04ffff04ff02ffff04ff2fff8080808080ffff04ff17ff808080808080ffff01ff02ff2fffff04ff0bff5f8080ffff01ff088080ff0180ffff04ffff01ffff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff04ffff04ff02ffff04ff09ff80808080ffff02ff04ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff02ffff03ff1bffff01ff02ff06ffff04ff02ffff04ffff02ffff03ffff18ffff0101ff1380ffff01ff0bffff0102ff2bff0580ffff01ff0bffff0102ff05ff2b8080ff0180ffff04ffff04ffff17ff13ffff0181ff80ff3b80ff8080808080ffff010580ff0180ff018080");
4600pub const ONE_OF_N_HASH: [u8; 32] =
4601 hex!("bcb9aa74893bebcfa2da87271b0330bf2773b6391144ae72262b6824d9c55939");
4602
4603/// ```text
4604/// (mod
4605/// (
4606/// M ; the number of necessary puzzles to execute
4607/// MERKLE_ROOT ; A root of all available puzzles
4608/// delegated_puzzle_hash ; A puzzle hash to run that all members must agree to
4609/// member_proof ; A partially revealed merkle tree with only the leaves being used fully revealed
4610/// )
4611///
4612/// (include sha256tree.clib)
4613///
4614/// ; utility
4615/// (defun merge_list (list_a list_b)
4616/// (if list_a
4617/// (c (f list_a) (merge_list (r list_a) list_b))
4618/// list_b
4619/// )
4620/// )
4621///
4622/// ; delegated puzzle validation
4623/// (defun-inline branch_hash_and_merge_info ((tree1 conditions1 total1) (tree2 conditions2 total2))
4624/// (list
4625/// (sha256 2 tree1 tree2)
4626/// (merge_list conditions1 conditions2)
4627/// (+ total1 total2)
4628/// )
4629/// )
4630///
4631/// (defun handle_branch (branch delegated_puzzle_hash)
4632/// (if (l branch)
4633/// (hash_and_run branch delegated_puzzle_hash)
4634/// (list branch () 0)
4635/// )
4636/// )
4637///
4638/// (defun hash_and_run (tree delegated_puzzle_hash)
4639/// (if (f tree)
4640/// (branch_hash_and_merge_info (handle_branch (f tree) delegated_puzzle_hash) (handle_branch (r tree) delegated_puzzle_hash))
4641/// (list
4642/// (sha256 1 (sha256tree (f (r tree))))
4643/// (a (f (r tree)) (c delegated_puzzle_hash (r (r tree))))
4644/// 1
4645/// )
4646/// )
4647/// )
4648///
4649/// ; main checks
4650/// (defun run_delegated_puzzle
4651/// (
4652/// M
4653/// MERKLE_ROOT
4654/// (
4655/// proven_root
4656/// conditions
4657/// total_validations
4658/// )
4659/// )
4660///
4661/// (if (all (= M total_validations) (= MERKLE_ROOT proven_root))
4662/// conditions
4663/// (x)
4664/// )
4665/// )
4666///
4667/// ; enter main
4668/// (run_delegated_puzzle
4669/// M
4670/// MERKLE_ROOT
4671/// (hash_and_run member_proof delegated_puzzle_hash)
4672/// )
4673/// )
4674/// ```
4675pub const M_OF_N: [u8; 622] = hex!("ff02ffff01ff02ff16ffff04ff02ffff04ff05ffff04ff0bffff04ffff02ff0cffff04ff02ffff04ff2fffff04ff17ff8080808080ff808080808080ffff04ffff01ffffff02ffff03ffff07ff0580ffff01ff02ff0cffff04ff02ffff04ff05ffff04ff0bff8080808080ffff01ff04ff05ffff01ff80ff80808080ff0180ff02ffff03ff09ffff01ff04ffff0bffff0102ffff05ffff02ff08ffff04ff02ffff04ff09ffff04ff0bff808080808080ffff05ffff02ff08ffff04ff02ffff04ff0dffff04ff0bff80808080808080ffff04ffff02ff0affff04ff02ffff04ffff05ffff06ffff02ff08ffff04ff02ffff04ff09ffff04ff0bff80808080808080ffff04ffff05ffff06ffff02ff08ffff04ff02ffff04ff0dffff04ff0bff80808080808080ff8080808080ffff04ffff10ffff05ffff06ffff06ffff02ff08ffff04ff02ffff04ff09ffff04ff0bff8080808080808080ffff05ffff06ffff06ffff02ff08ffff04ff02ffff04ff0dffff04ff0bff808080808080808080ff80808080ffff01ff04ffff0bffff0101ffff02ff1effff04ff02ffff04ff15ff8080808080ffff04ffff02ff15ffff04ff0bff1d8080ffff01ff0180808080ff0180ffff02ffff03ff05ffff01ff04ff09ffff02ff0affff04ff02ffff04ff0dffff04ff0bff808080808080ffff010b80ff0180ffff02ffff03ffff22ffff09ff05ff81b780ffff09ff0bff278080ffff0157ffff01ff088080ff0180ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff1effff04ff02ffff04ff09ff80808080ffff02ff1effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080");
4676pub const M_OF_N_HASH: [u8; 32] =
4677 hex!("de27deb2ebc7f1e1b77e1d38cc2f9d90fbd54d4b13dd4e6fa1f659177e36ed4f");
4678
4679/// ```text
4680/// (mod
4681/// (
4682/// MEMBERS
4683/// delegated_puzzle_hash
4684/// member_solutions
4685/// )
4686///
4687/// ; utility
4688/// (include sha256tree.clib)
4689/// (defun merge_list (list_a list_b)
4690/// (if list_a
4691/// (c (f list_a) (merge_list (r list_a) list_b))
4692/// list_b
4693/// )
4694/// )
4695///
4696/// ; streamlined M of N
4697/// (defun run_member (MEMBER member_solution delegated_puzzle_hash)
4698/// (a MEMBER (c delegated_puzzle_hash member_solution))
4699/// )
4700///
4701/// (defun approve_delegated_puzzle (MEMBERS member_solutions delegated_puzzle_hash)
4702/// (if (r MEMBERS) ; assumes at least 1 member at start
4703/// (merge_list
4704/// (run_member (f MEMBERS) (f member_solutions) delegated_puzzle_hash)
4705/// (approve_delegated_puzzle (r MEMBERS) (r member_solutions) delegated_puzzle_hash)
4706/// )
4707/// (run_member (f MEMBERS) (f member_solutions) delegated_puzzle_hash)
4708/// )
4709/// )
4710///
4711/// ; main
4712/// (approve_delegated_puzzle MEMBERS member_solutions delegated_puzzle_hash)
4713/// )
4714/// ```
4715pub const N_OF_N: [u8; 243] = hex!("ff02ffff01ff02ff04ffff04ff02ffff04ff05ffff04ff17ffff04ff0bff808080808080ffff04ffff01ffff02ffff03ff0dffff01ff02ff0affff04ff02ffff04ffff02ff0effff04ff02ffff04ff09ffff04ff13ffff04ff17ff808080808080ffff04ffff02ff04ffff04ff02ffff04ff0dffff04ff1bffff04ff17ff808080808080ff8080808080ffff01ff02ff0effff04ff02ffff04ff09ffff04ff13ffff04ff17ff80808080808080ff0180ffff02ffff03ff05ffff01ff04ff09ffff02ff0affff04ff02ffff04ff0dffff04ff0bff808080808080ffff010b80ff0180ff02ff05ffff04ff17ff0b8080ff018080");
4716pub const N_OF_N_HASH: [u8; 32] =
4717 hex!("d4394f50cb1d6ef130788db2e69ab0087ef79b0737179f201c1d1d2a52df1e59");
4718
4719/// ```text
4720/// (mod
4721/// (
4722/// INNER_PUZZLE
4723/// delegated_puzzle
4724/// delegated_solution
4725/// .
4726/// inner_solution
4727/// )
4728///
4729/// (include sha256tree.clib)
4730///
4731/// (defun merge_list (list_a list_b)
4732/// (if list_a
4733/// (c (f list_a) (merge_list (r list_a) list_b))
4734/// list_b
4735/// )
4736/// )
4737///
4738/// (merge_list (a INNER_PUZZLE (c (sha256tree delegated_puzzle) inner_solution)) (a delegated_puzzle delegated_solution))
4739/// )
4740/// ```
4741pub const DELEGATED_PUZZLE_FEEDER: [u8; 203] = hex!("ff02ffff01ff02ff04ffff04ff02ffff04ffff02ff05ffff04ffff02ff06ffff04ff02ffff04ff0bff80808080ff1f8080ffff04ffff02ff0bff1780ff8080808080ffff04ffff01ffff02ffff03ff05ffff01ff04ff09ffff02ff04ffff04ff02ffff04ff0dffff04ff0bff808080808080ffff010b80ff0180ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff06ffff04ff02ffff04ff09ff80808080ffff02ff06ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080");
4742pub const DELEGATED_PUZZLE_FEEDER_HASH: [u8; 32] =
4743 hex!("9db33d93853179903d4dd272a00345ee6630dc94907dbcdd96368df6931060fd");
4744
4745/// ```text
4746/// (mod
4747/// (
4748/// MEMBER_VALIDATORS ; programs that look at the conditions allowed OUT
4749/// DPUZ_VALIDATORS ; programs that validate the delegated puzzle allowed IN
4750/// INNER_PUZZLE ; the program that generates the conditions
4751/// delegated_puzzle_hash
4752/// member_val_solutions
4753/// dpuz_val_solutions
4754/// inner_solution
4755/// )
4756///
4757/// (defun run_validators (VALIDATORS val_solutions thing_to_check)
4758/// (if VALIDATORS
4759/// (i () ; just using this as a hook to evaluate all children
4760/// (a (f VALIDATORS) (c thing_to_check (f val_solutions)))
4761/// (run_validators (r VALIDATORS) (r val_solutions) thing_to_check)
4762/// )
4763/// ; else
4764/// ()
4765/// )
4766/// )
4767///
4768/// (defun run_member_validators_and_return (MEMBER_VALIDATORS member_val_solutions inner_conditions)
4769/// (i () ; just using this as a hook to evaluate all children
4770/// (run_validators MEMBER_VALIDATORS member_val_solutions inner_conditions)
4771/// inner_conditions ; actually returned
4772/// )
4773/// )
4774///
4775/// (run_member_validators_and_return
4776/// MEMBER_VALIDATORS
4777/// member_val_solutions
4778/// (a INNER_PUZZLE (c delegated_puzzle_hash inner_solution))
4779/// ; not part of the function call but needs to run
4780/// (run_validators DPUZ_VALIDATORS dpuz_val_solutions delegated_puzzle_hash)
4781/// )
4782/// )
4783/// ```
4784pub const RESTRICTIONS: [u8; 204] = hex!("ff02ffff01ff02ff04ffff04ff02ffff04ff05ffff04ff5fffff04ffff02ff17ffff04ff2fff82017f8080ffff04ffff02ff06ffff04ff02ffff04ff0bffff04ff81bfffff04ff2fff808080808080ff80808080808080ffff04ffff01ffff03ff80ffff02ff06ffff04ff02ffff04ff05ffff04ff0bffff04ff17ff808080808080ff1780ff02ffff03ff05ffff01ff03ff80ffff02ff09ffff04ff17ff138080ffff02ff06ffff04ff02ffff04ff0dffff04ff1bffff04ff17ff80808080808080ff8080ff0180ff018080");
4785pub const RESTRICTIONS_HASH: [u8; 32] =
4786 hex!("a28d59d39f964a93159c986b1914694f6f2f1c9901178f91e8b0ba4045980eef");
4787
4788/// ```text
4789/// ; this puzzle follows the Managed Inner Puzzle Spec MIPS01 as a Member Puzzle
4790/// ; this code offers a secure approval of a delegated puzzle passed in as a Truth to be run elsewhere
4791///
4792/// (mod (PUBLIC_KEY Delegated_Puzzle) ; delegated puzzle is passed in from the above M of N layer
4793/// (include condition_codes.clib)
4794///
4795/// (list (list AGG_SIG_ME PUBLIC_KEY Delegated_Puzzle))
4796/// )
4797/// ```
4798pub const BLS_MEMBER: [u8; 41] =
4799 hex!("ff02ffff01ff04ffff04ff02ffff04ff05ffff04ff0bff80808080ff8080ffff04ffff0132ff018080");
4800pub const BLS_MEMBER_HASH: [u8; 32] =
4801 hex!("21a3ae8b3ce64d41ca98d6d8df8f465c9e1bfb19ab40284a5da8479ba7fade78");
4802
4803/// ```text
4804/// ; this puzzle follows the Managed Inner Puzzle Spec MIPS01 as a Member Puzzle
4805/// ; this code offers a secure approval of a delegated puzzle passed in as a Truth to be run elsewhere
4806///
4807/// ; Delegated_Puzzle_Hash is added to the solution in the above layer
4808/// ; original_public_key, hidden_puzzle and solution are only for use in the taproot case
4809/// ; set original_public_key to 0 for non-taproot case
4810/// (mod (SYNTHETIC_PUBLIC_KEY Delegated_Puzzle_Hash original_public_key hidden_puzzle)
4811/// (include condition_codes.clib)
4812///
4813/// (defmacro assert items
4814/// (if (r items)
4815/// (list if (f items) (c assert (r items)) (q . (x)))
4816/// (f items)
4817/// )
4818/// )
4819///
4820/// ; "is_hidden_puzzle_correct" returns true iff the hidden puzzle is correctly encoded
4821///
4822/// (defun-inline is_hidden_puzzle_correct (SYNTHETIC_PUBLIC_KEY original_public_key hidden_puzzle_hash)
4823/// (=
4824/// SYNTHETIC_PUBLIC_KEY
4825/// (point_add
4826/// original_public_key
4827/// (pubkey_for_exp (sha256 original_public_key hidden_puzzle_hash))
4828/// )
4829/// )
4830/// )
4831///
4832/// ; "possibly_prepend_aggsig" is the main entry point
4833///
4834/// (if original_public_key
4835/// (assert
4836/// (is_hidden_puzzle_correct SYNTHETIC_PUBLIC_KEY original_public_key Delegated_Puzzle_Hash)
4837/// ()
4838/// )
4839/// (list (list AGG_SIG_ME SYNTHETIC_PUBLIC_KEY Delegated_Puzzle_Hash))
4840/// )
4841/// )
4842/// ```
4843pub const BLS_WITH_TAPROOT_MEMBER: [u8; 99] = hex!("ff02ffff01ff02ffff03ff17ffff01ff02ffff03ffff09ff05ffff1dff17ffff1effff0bff17ff0b80808080ff80ffff01ff088080ff0180ffff01ff04ffff04ff02ffff04ff05ffff04ff0bff80808080ff808080ff0180ffff04ffff0132ff018080");
4844pub const BLS_WITH_TAPROOT_MEMBER_HASH: [u8; 32] =
4845 hex!("35d2ad31aaf0df91c965909e5112294c57a18354ee4a5aae80572080ec3b6842");
4846
4847/// ```text
4848/// (mod (FIXED_PUZZLE_HASH Delegated_Puzzle_Hash)
4849/// (if (= FIXED_PUZZLE_HASH Delegated_Puzzle_Hash)
4850/// ()
4851/// (x)
4852/// )
4853/// )
4854/// ```
4855pub const FIXED_PUZZLE_MEMBER: [u8; 25] =
4856 hex!("ff02ffff03ffff09ff02ff0580ff80ffff01ff088080ff0180");
4857pub const FIXED_PUZZLE_MEMBER_HASH: [u8; 32] =
4858 hex!("34ede3eadc52ed750e405f2b9dea9891506547f651290bb606356d997c64f219");
4859
4860/// ```text
4861/// ; member puzzle with SECP256-R1 signature provided by a passkey (ie Yubikey)
4862///
4863/// (mod (SECP_PK
4864/// Delegated_Puzzle_Hash
4865/// ; The WebAuthn authenticator data.
4866/// ; See https://www.w3.org/TR/webauthn-2/#dom-authenticatorassertionresponse-authenticatordata.
4867/// authenticator_data
4868/// ; The WebAuthn client data JSON.
4869/// ; See https://www.w3.org/TR/webauthn-2/#dom-authenticatorresponse-clientdatajson.
4870/// client_data_json
4871/// ; The index at which "challenge":"..." occurs in `clientDataJSON`.
4872/// challenge_index
4873/// ; the signature returned by the authenticator
4874/// signature
4875/// ; my puzzle hash
4876/// puzzle_hash
4877/// )
4878///
4879/// (include *standard-cl-23*)
4880/// (include condition_codes.clib)
4881/// (include sha256tree.clib)
4882///
4883/// (defconstant b64-charset "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_")
4884///
4885/// (defun map-triples (fun n blob)
4886/// (if (any (= n (strlen blob)) (> n (strlen blob)))
4887/// ()
4888/// (c (a fun (list (substr blob n (+ n 3)))) (map-triples fun (+ n 3) blob))
4889/// )
4890/// )
4891///
4892/// (defun flat-map (fun lst)
4893/// (if lst
4894/// (if (f lst)
4895/// (c (a fun (list (f (f lst)))) (flat-map fun (c (r (f lst)) (r lst))))
4896/// (flat-map fun (r lst))
4897/// )
4898/// ()
4899/// )
4900/// )
4901///
4902/// (defun lookup-b64 (byte)
4903/// (substr b64-charset byte (+ byte 1))
4904/// )
4905///
4906/// (defun-inline trim-padding (plen output)
4907/// (substr output 0 (- (strlen output) plen))
4908/// )
4909///
4910/// (defun-inline convert (int)
4911/// (if (> int -1) int (+ int 256))
4912/// )
4913///
4914/// (defun b64-encode-blob (blob)
4915/// (assign
4916/// pad_mod (r (divmod (strlen blob) 3))
4917/// padding (if pad_mod (- 3 pad_mod) 0)
4918/// bytes (concat blob (substr 0x000000 0 padding))
4919/// sextets
4920/// (map-triples (lambda ((& padding) bytes)
4921/// (assign
4922/// (fb_upper . fb_lower) (divmod (convert (substr bytes 0 1)) 4)
4923/// (sb_upper . sb_lower) (divmod (convert (substr bytes 1 2)) 16)
4924/// (tb_upper . tb_lower) (divmod (convert (substr bytes 2 3)) 64)
4925/// (list
4926/// fb_upper
4927/// (logior (ash fb_lower 4) sb_upper)
4928/// (logior (ash sb_lower 2) tb_upper)
4929/// tb_lower
4930/// )
4931/// )
4932/// )
4933/// 0
4934/// bytes
4935/// )
4936/// (trim-padding padding (a (c (list 14) (flat-map lookup-b64 sextets)) ()))
4937/// )
4938/// )
4939///
4940/// (assign
4941/// message (b64-encode-blob (sha256 Delegated_Puzzle_Hash puzzle_hash))
4942/// challenge (concat '"challenge":"' message '"')
4943/// (if (= (substr client_data_json challenge_index (+ challenge_index (strlen challenge))) challenge)
4944/// (c
4945/// (list ASSERT_MY_PUZZLEHASH puzzle_hash)
4946/// (secp256r1_verify SECP_PK (sha256 authenticator_data (sha256 client_data_json)) signature)
4947/// )
4948/// (x)
4949/// )
4950/// )
4951/// )
4952/// ```
4953pub const PASSKEY_MEMBER_PUZZLE_ASSERT: [u8; 1418] = hex!("ff02ffff01ff02ff3effff04ff02ffff04ff03ffff04ffff02ff2cffff04ff02ffff04ffff0bff0bff82017f80ff80808080ff8080808080ffff04ffff01ffffffff02ffff03ffff21ffff09ff0bffff0dff178080ffff15ff0bffff0dff17808080ffff01ff0180ffff01ff04ffff02ff05ffff04ffff0cff17ff0bffff10ff0bffff01038080ff808080ffff02ff10ffff04ff02ffff04ff05ffff04ffff10ff0bffff010380ffff04ff17ff8080808080808080ff0180ff02ffff03ff0bffff01ff02ffff03ff13ffff01ff04ffff02ff05ffff04ff23ff808080ffff02ff18ffff04ff02ffff04ff05ffff04ffff04ff33ff1b80ff808080808080ffff01ff02ff18ffff04ff02ffff04ff05ffff04ff1bff808080808080ff0180ffff01ff018080ff0180ffff0cffff01c0404142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392d5fff05ffff10ff05ffff01018080ffff02ff3cffff04ff02ffff04ff03ffff04ffff06ffff14ffff0dff0580ffff01038080ff8080808080ff02ff12ffff04ff02ffff04ff03ffff04ffff02ffff03ff0bffff01ff11ffff0103ff0b80ffff01ff018080ff0180ff8080808080ffffff02ff2affff04ff02ffff04ff03ffff04ffff0eff11ffff0cffff0183000000ff80ff0b8080ff8080808080ffff02ff2effff04ff02ffff04ff03ffff04ffff02ff10ffff04ff02ffff04ffff04ffff0102ffff04ffff04ffff0101ffff04ffff0102ffff04ffff04ffff0101ff1680ffff04ffff04ffff0104ffff04ffff04ffff0101ff0280ffff04ffff0101ff80808080ff8080808080ffff04ffff04ffff0104ffff04ffff04ffff0101ffff04ff15ff808080ffff04ffff0101ff80808080ff80808080ffff04ff80ffff04ff0bff808080808080ff8080808080ff04ff4fffff04ffff19ffff16ff6fffff010480ff2780ffff04ffff19ffff16ff37ffff010280ff1380ffff04ff1bff8080808080ffff02ff3affff04ff02ffff04ffff04ffff04ff09ff8080ffff04ff0bff808080ffff04ffff14ffff02ffff03ffff15ffff0cff0bffff0102ffff010380ffff0181ff80ffff01ff0cff0bffff0102ffff010380ffff01ff10ffff0cff0bffff0102ffff010380ffff018201008080ff0180ffff014080ffff04ffff14ffff02ffff03ffff15ffff0cff0bffff0101ffff010280ffff0181ff80ffff01ff0cff0bffff0101ffff010280ffff01ff10ffff0cff0bffff0101ffff010280ffff018201008080ff0180ffff011080ffff04ffff14ffff02ffff03ffff15ffff0cff0bff80ffff010180ffff0181ff80ffff01ff0cff0bff80ffff010180ffff01ff10ffff0cff0bff80ffff010180ffff018201008080ff0180ffff010480ff80808080808080ffff0cffff02ffff04ffff04ffff010eff8080ffff02ff18ffff04ff02ffff04ffff04ffff0102ffff04ffff04ffff0101ff1480ffff04ffff04ffff0104ffff04ffff04ffff0101ff0280ffff04ffff0101ff80808080ff80808080ffff04ff0bff808080808080ff8080ff80ffff11ffff0dffff02ffff04ffff04ffff010eff8080ffff02ff18ffff04ff02ffff04ffff04ffff0102ffff04ffff04ffff0101ff1480ffff04ffff04ffff0104ffff04ffff04ffff0101ff0280ffff04ffff0101ff80808080ff80808080ffff04ff0bff808080808080ff808080ff298080ff02ffff03ffff09ffff0cff5dff8200bdffff10ff8200bdffff0dffff0effff018d226368616c6c656e6765223a22ff0bffff012280808080ffff0effff018d226368616c6c656e6765223a22ff0bffff01228080ffff01ff04ffff04ffff0148ffff04ff8202fdff808080ffff841c3a8f00ff09ffff0bff2dffff0bff5d8080ff82017d8080ffff01ff088080ff0180ff018080");
4954pub const PASSKEY_MEMBER_PUZZLE_ASSERT_HASH: [u8; 32] =
4955 hex!("e6db5ba2eeded13c47216512a7a4662b95121c145580db6312cb711aaadcec32");
4956
4957/// ```text
4958/// ; member puzzle with SECP256-R1 signature provided by a passkey (ie Yubikey)
4959///
4960/// (mod (SECP_PK
4961/// Delegated_Puzzle_Hash
4962/// ; The WebAuthn authenticator data.
4963/// ; See https://www.w3.org/TR/webauthn-2/#dom-authenticatorassertionresponse-authenticatordata.
4964/// authenticator_data
4965/// ; The WebAuthn client data JSON.
4966/// ; See https://www.w3.org/TR/webauthn-2/#dom-authenticatorresponse-clientdatajson.
4967/// client_data_json
4968/// ; The index at which "challenge":"..." occurs in `clientDataJSON`.
4969/// challenge_index
4970/// ; the signature returned by the authenticator
4971/// signature
4972/// ; my coin id
4973/// coin_id
4974/// )
4975///
4976/// (include *standard-cl-23*)
4977/// (include condition_codes.clib)
4978/// (include sha256tree.clib)
4979///
4980/// (defconstant b64-charset "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_")
4981///
4982/// (defun map-triples (fun n blob)
4983/// (if (any (= n (strlen blob)) (> n (strlen blob)))
4984/// ()
4985/// (c (a fun (list (substr blob n (+ n 3)))) (map-triples fun (+ n 3) blob))
4986/// )
4987/// )
4988///
4989/// (defun flat-map (fun lst)
4990/// (if lst
4991/// (if (f lst)
4992/// (c (a fun (list (f (f lst)))) (flat-map fun (c (r (f lst)) (r lst))))
4993/// (flat-map fun (r lst))
4994/// )
4995/// ()
4996/// )
4997/// )
4998///
4999/// (defun lookup-b64 (byte)
5000/// (substr b64-charset byte (+ byte 1))
5001/// )
5002///
5003/// (defun-inline trim-padding (plen output)
5004/// (substr output 0 (- (strlen output) plen))
5005/// )
5006///
5007/// (defun-inline convert (int)
5008/// (if (> int -1) int (+ int 256))
5009/// )
5010///
5011/// (defun b64-encode-blob (blob)
5012/// (assign
5013/// pad_mod (r (divmod (strlen blob) 3))
5014/// padding (if pad_mod (- 3 pad_mod) 0)
5015/// bytes (concat blob (substr 0x000000 0 padding))
5016/// sextets
5017/// (map-triples (lambda ((& padding) bytes)
5018/// (assign
5019/// (fb_upper . fb_lower) (divmod (convert (substr bytes 0 1)) 4)
5020/// (sb_upper . sb_lower) (divmod (convert (substr bytes 1 2)) 16)
5021/// (tb_upper . tb_lower) (divmod (convert (substr bytes 2 3)) 64)
5022/// (list
5023/// fb_upper
5024/// (logior (ash fb_lower 4) sb_upper)
5025/// (logior (ash sb_lower 2) tb_upper)
5026/// tb_lower
5027/// )
5028/// )
5029/// )
5030/// 0
5031/// bytes
5032/// )
5033/// (trim-padding padding (a (c (list 14) (flat-map lookup-b64 sextets)) ()))
5034/// )
5035/// )
5036///
5037/// (assign
5038/// message (b64-encode-blob (sha256 Delegated_Puzzle_Hash coin_id))
5039/// challenge (concat '"challenge":"' message '"')
5040/// (if (= (substr client_data_json challenge_index (+ challenge_index (strlen challenge))) challenge)
5041/// (c
5042/// (list ASSERT_MY_COIN_ID coin_id)
5043/// (secp256r1_verify SECP_PK (sha256 authenticator_data (sha256 client_data_json)) signature)
5044/// )
5045/// (x)
5046/// )
5047/// )
5048/// )
5049/// ```
5050pub const PASSKEY_MEMBER: [u8; 1418] = hex!("ff02ffff01ff02ff3effff04ff02ffff04ff03ffff04ffff02ff2cffff04ff02ffff04ffff0bff0bff82017f80ff80808080ff8080808080ffff04ffff01ffffffff02ffff03ffff21ffff09ff0bffff0dff178080ffff15ff0bffff0dff17808080ffff01ff0180ffff01ff04ffff02ff05ffff04ffff0cff17ff0bffff10ff0bffff01038080ff808080ffff02ff10ffff04ff02ffff04ff05ffff04ffff10ff0bffff010380ffff04ff17ff8080808080808080ff0180ff02ffff03ff0bffff01ff02ffff03ff13ffff01ff04ffff02ff05ffff04ff23ff808080ffff02ff18ffff04ff02ffff04ff05ffff04ffff04ff33ff1b80ff808080808080ffff01ff02ff18ffff04ff02ffff04ff05ffff04ff1bff808080808080ff0180ffff01ff018080ff0180ffff0cffff01c0404142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392d5fff05ffff10ff05ffff01018080ffff02ff3cffff04ff02ffff04ff03ffff04ffff06ffff14ffff0dff0580ffff01038080ff8080808080ff02ff12ffff04ff02ffff04ff03ffff04ffff02ffff03ff0bffff01ff11ffff0103ff0b80ffff01ff018080ff0180ff8080808080ffffff02ff2affff04ff02ffff04ff03ffff04ffff0eff11ffff0cffff0183000000ff80ff0b8080ff8080808080ffff02ff2effff04ff02ffff04ff03ffff04ffff02ff10ffff04ff02ffff04ffff04ffff0102ffff04ffff04ffff0101ffff04ffff0102ffff04ffff04ffff0101ff1680ffff04ffff04ffff0104ffff04ffff04ffff0101ff0280ffff04ffff0101ff80808080ff8080808080ffff04ffff04ffff0104ffff04ffff04ffff0101ffff04ff15ff808080ffff04ffff0101ff80808080ff80808080ffff04ff80ffff04ff0bff808080808080ff8080808080ff04ff4fffff04ffff19ffff16ff6fffff010480ff2780ffff04ffff19ffff16ff37ffff010280ff1380ffff04ff1bff8080808080ffff02ff3affff04ff02ffff04ffff04ffff04ff09ff8080ffff04ff0bff808080ffff04ffff14ffff02ffff03ffff15ffff0cff0bffff0102ffff010380ffff0181ff80ffff01ff0cff0bffff0102ffff010380ffff01ff10ffff0cff0bffff0102ffff010380ffff018201008080ff0180ffff014080ffff04ffff14ffff02ffff03ffff15ffff0cff0bffff0101ffff010280ffff0181ff80ffff01ff0cff0bffff0101ffff010280ffff01ff10ffff0cff0bffff0101ffff010280ffff018201008080ff0180ffff011080ffff04ffff14ffff02ffff03ffff15ffff0cff0bff80ffff010180ffff0181ff80ffff01ff0cff0bff80ffff010180ffff01ff10ffff0cff0bff80ffff010180ffff018201008080ff0180ffff010480ff80808080808080ffff0cffff02ffff04ffff04ffff010eff8080ffff02ff18ffff04ff02ffff04ffff04ffff0102ffff04ffff04ffff0101ff1480ffff04ffff04ffff0104ffff04ffff04ffff0101ff0280ffff04ffff0101ff80808080ff80808080ffff04ff0bff808080808080ff8080ff80ffff11ffff0dffff02ffff04ffff04ffff010eff8080ffff02ff18ffff04ff02ffff04ffff04ffff0102ffff04ffff04ffff0101ff1480ffff04ffff04ffff0104ffff04ffff04ffff0101ff0280ffff04ffff0101ff80808080ff80808080ffff04ff0bff808080808080ff808080ff298080ff02ffff03ffff09ffff0cff5dff8200bdffff10ff8200bdffff0dffff0effff018d226368616c6c656e6765223a22ff0bffff012280808080ffff0effff018d226368616c6c656e6765223a22ff0bffff01228080ffff01ff04ffff04ffff0146ffff04ff8202fdff808080ffff841c3a8f00ff09ffff0bff2dffff0bff5d8080ff82017d8080ffff01ff088080ff0180ff018080");
5051pub const PASSKEY_MEMBER_HASH: [u8; 32] =
5052 hex!("1d66225b71ec6caf33e3771ebaa7fcd50826fd31844dc8258116b37b3ff3c7ae");
5053
5054/// ```text
5055/// ; this puzzle follows the Managed Inner Puzzle Spec MIPS01 as a Member Puzzle
5056/// ; this code offers a secure approval of a delegated puzzle passed in as a Truth to be run elsewhere
5057///
5058/// ; this code requires a signature including the coin's puzzle rather than the default which is the coin's id
5059/// ; this enables the signature to be used later, however users must be aware of replayability
5060///
5061/// (mod (SECP_PK Delegated_Puzzle_Hash my_puzhash signature) ; delegated puzzle is passed in from the above M of N layer
5062/// (include condition_codes.clib)
5063///
5064/// (c
5065/// (list ASSERT_MY_PUZZLEHASH my_puzhash)
5066/// (secp256k1_verify SECP_PK (sha256 Delegated_Puzzle_Hash my_puzhash) signature)
5067/// )
5068/// )
5069/// ```
5070pub const SECP256K1_MEMBER_PUZZLE_ASSERT: [u8; 53] = hex!("ff02ffff01ff04ffff04ff02ffff04ff17ff808080ffff8413d61f00ff05ffff0bff0bff1780ff2f8080ffff04ffff0148ff018080");
5071pub const SECP256K1_MEMBER_PUZZLE_ASSERT_HASH: [u8; 32] =
5072 hex!("67d591ffeb00571269d401f41a6a43ceb927b5087074ad4446ff22400a010e87");
5073
5074/// ```text
5075/// ; this puzzle follows the Managed Inner Puzzle Spec MIPS01 as a Member Puzzle
5076/// ; this code offers a secure approval of a delegated puzzle passed in as a Truth to be run elsewhere
5077///
5078/// (mod (SECP_PK Delegated_Puzzle_Hash my_id signature) ; delegated puzzle is passed in from the above M of N layer
5079/// (include condition_codes.clib)
5080///
5081/// (c
5082/// (list ASSERT_MY_COIN_ID my_id)
5083/// (secp256k1_verify SECP_PK (sha256 Delegated_Puzzle_Hash my_id) signature)
5084/// )
5085/// )
5086/// ```
5087pub const SECP256K1_MEMBER: [u8; 53] = hex!("ff02ffff01ff04ffff04ff02ffff04ff17ff808080ffff8413d61f00ff05ffff0bff0bff1780ff2f8080ffff04ffff0146ff018080");
5088pub const SECP256K1_MEMBER_HASH: [u8; 32] =
5089 hex!("2b05daf134c9163acc8f2ac05b61f7d8328fca3dcc963154a28e89bcfc4dbfca");
5090
5091/// ```text
5092/// ; this puzzle follows the Managed Inner Puzzle Spec MIPS01 as a Member Puzzle
5093/// ; this code offers a secure approval of a delegated puzzle passed in as a Truth to be run elsewhere
5094///
5095/// ; this code requires a signature including the coin's puzzle rather than the default which is the coin's id
5096/// ; this enables the signature to be used later, however users must be aware of replayability
5097///
5098/// (mod (SECP_PK Delegated_Puzzle_Hash my_puzhash signature) ; delegated puzzle is passed in from the above M of N layer
5099/// (include condition_codes.clib)
5100///
5101/// (c
5102/// (list ASSERT_MY_PUZZLEHASH my_puzhash)
5103/// (secp256r1_verify SECP_PK (sha256 Delegated_Puzzle_Hash my_puzhash) signature)
5104/// )
5105/// )
5106/// ```
5107pub const SECP256R1_MEMBER_PUZZLE_ASSERT: [u8; 53] = hex!("ff02ffff01ff04ffff04ff02ffff04ff17ff808080ffff841c3a8f00ff05ffff0bff0bff1780ff2f8080ffff04ffff0148ff018080");
5108pub const SECP256R1_MEMBER_PUZZLE_ASSERT_HASH: [u8; 32] =
5109 hex!("d77bbc050bff8dfe4eb4544fa2bf0d0fd0463b96801bf6445687bd35985e71db");
5110
5111/// ```text
5112/// ; this puzzle follows the Managed Inner Puzzle Spec MIPS01 as a Member Puzzle
5113/// ; this code offers a secure approval of a delegated puzzle passed in as a Truth to be run elsewhere
5114///
5115/// (mod (SECP_PK Delegated_Puzzle_Hash my_id signature) ; delegated puzzle is passed in from the above M of N layer
5116/// (include condition_codes.clib)
5117///
5118/// (c
5119/// (list ASSERT_MY_COIN_ID my_id)
5120/// (secp256r1_verify SECP_PK (sha256 Delegated_Puzzle_Hash my_id) signature)
5121/// )
5122/// )
5123/// ```
5124pub const SECP256R1_MEMBER: [u8; 53] = hex!("ff02ffff01ff04ffff04ff02ffff04ff17ff808080ffff841c3a8f00ff05ffff0bff0bff1780ff2f8080ffff04ffff0146ff018080");
5125pub const SECP256R1_MEMBER_HASH: [u8; 32] =
5126 hex!("05aaa1f2fb6c48b5bce952b09f3da99afa4241989878a9919aafb7d74b70ac54");
5127
5128/// ```text
5129/// (mod (SINGLETON_STRUCT Delegated_Puzzle singleton_innerpuzhash singleton_amount)
5130/// ; SINGLETON_STRUCT is ((SINGLETON_MOD_HASH, (LAUNCHER_ID, LAUNCHER_PUZZLE_HASH)))
5131///
5132/// (include condition_codes.clib)
5133/// (include curry-and-treehash.clib)
5134///
5135/// ; return the full puzzlehash for a singleton with the innerpuzzle curried in
5136/// ; puzzle-hash-of-curried-function is imported from curry-and-treehash.clib
5137/// (defun-inline calculate_full_puzzle_hash (SINGLETON_STRUCT inner_puzzle_hash)
5138/// (puzzle-hash-of-curried-function (f SINGLETON_STRUCT)
5139/// inner_puzzle_hash
5140/// (sha256tree SINGLETON_STRUCT)
5141/// )
5142/// )
5143///
5144/// (list (list
5145/// RECEIVE_MESSAGE
5146/// 0x17 ; mode = puzzle sender, coin receiver -> 0x00 010 111
5147/// Delegated_Puzzle
5148/// (calculate_full_puzzle_hash SINGLETON_STRUCT singleton_innerpuzhash)
5149/// ))
5150/// )
5151/// ```
5152pub const SINGLETON_MEMBER: [u8; 361] = hex!("ff02ffff01ff04ffff04ff12ffff04ffff0117ffff04ff0bffff04ffff02ff2effff04ff02ffff04ff09ffff04ff17ffff04ffff02ff3effff04ff02ffff04ff05ff80808080ff808080808080ff8080808080ff8080ffff04ffff01ffffff0204ff0101ffff4302ffff02ffff03ff05ffff01ff02ff16ffff04ff02ffff04ff0dffff04ffff0bff1affff0bff14ff1880ffff0bff1affff0bff1affff0bff14ff1c80ff0980ffff0bff1aff0bffff0bff14ff8080808080ff8080808080ffff010b80ff0180ffff0bff1affff0bff14ff1080ffff0bff1affff0bff1affff0bff14ff1c80ff0580ffff0bff1affff02ff16ffff04ff02ffff04ff07ffff04ffff0bff14ff1480ff8080808080ffff0bff14ff8080808080ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff3effff04ff02ffff04ff09ff80808080ffff02ff3effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080");
5153pub const SINGLETON_MEMBER_HASH: [u8; 32] =
5154 hex!("6f1cebc5a6d3661ad87d3558146259ca580729b244b7662757f8d1c34a6a9ad9");
5155
5156/// ```text
5157/// ; This is a highly specific puzzle that enforces that any new create coins are a 1of2 w/ a fixed left side
5158/// ; and a variable right side that is put under pre-committed restrictions.
5159/// ;
5160/// ; The framework this is designed to fit in doesn't really support subtree behavior like this, so the specificity and
5161/// ; limited flexibility of this puzzle is due to the fact that it's sort of a hack to support an existing feature with
5162/// ; a framework poorly designed for it.
5163/// (mod
5164/// (
5165/// DELEGATED_PUZZLE_FEEDER_MOD_HASH
5166/// 1_OF_N_MOD_HASH
5167/// LEFT_SIDE_SUBTREE_HASH_HASH
5168/// INDEX_WRAPPER_HASH
5169/// NONCE
5170/// RESTRICTION_MOD_HASH
5171/// MEMBER_VALIDATOR_LIST_HASH
5172/// DPUZ_VALIDATOR_LIST_HASH
5173/// Conditions
5174/// new_right_side_member_hash
5175/// )
5176///
5177/// (include curry.clib)
5178/// (include utility_macros.clib)
5179/// (include condition_codes.clib)
5180/// (defconstant ONE 1)
5181///
5182/// (defun check_coins (conditions fixed_puzzle_hash)
5183/// (if conditions
5184/// (if (and (= (f (f conditions)) CREATE_COIN) (not (= (f (r (f conditions))) fixed_puzzle_hash)))
5185/// (x)
5186/// (check_coins (r conditions) fixed_puzzle_hash)
5187/// )
5188/// 1 ; this will pass assert
5189/// )
5190/// )
5191///
5192/// (defun-inline calculate_fixed_puzzle_hash
5193/// (
5194/// DELEGATED_PUZZLE_FEEDER_MOD_HASH
5195/// 1_OF_N_MOD_HASH
5196/// LEFT_SIDE_SUBTREE_HASH_HASH
5197/// INDEX_WRAPPER_HASH
5198/// NONCE
5199/// RESTRICTION_MOD_HASH
5200/// MEMBER_VALIDATOR_LIST_HASH
5201/// DPUZ_VALIDATOR_LIST_HASH
5202/// new_right_side_member_hash
5203/// )
5204///
5205///
5206/// (curry_hashes INDEX_WRAPPER_HASH
5207/// (sha256 ONE NONCE)
5208/// (curry_hashes DELEGATED_PUZZLE_FEEDER_MOD_HASH
5209/// (curry_hashes 1_OF_N_MOD_HASH
5210/// (sha256 ONE (sha256 TWO
5211/// LEFT_SIDE_SUBTREE_HASH_HASH
5212/// ; right side calculation
5213/// (sha256 ONE (curry_hashes INDEX_WRAPPER_HASH
5214/// (sha256 ONE NONCE)
5215/// (curry_hashes RESTRICTION_MOD_HASH
5216/// MEMBER_VALIDATOR_LIST_HASH
5217/// DPUZ_VALIDATOR_LIST_HASH
5218/// new_right_side_member_hash
5219/// )
5220/// ))
5221/// ))
5222/// )
5223/// )
5224/// )
5225/// )
5226///
5227/// (assert
5228/// (check_coins
5229/// Conditions
5230/// (calculate_fixed_puzzle_hash
5231/// DELEGATED_PUZZLE_FEEDER_MOD_HASH
5232/// 1_OF_N_MOD_HASH
5233/// LEFT_SIDE_SUBTREE_HASH_HASH
5234/// INDEX_WRAPPER_HASH
5235/// NONCE
5236/// RESTRICTION_MOD_HASH
5237/// MEMBER_VALIDATOR_LIST_HASH
5238/// DPUZ_VALIDATOR_LIST_HASH
5239/// new_right_side_member_hash
5240/// )
5241/// )
5242/// ; then
5243/// Conditions
5244/// )
5245/// )
5246/// ```
5247pub const FORCE_1_OF_2_W_RESTRICTED_VARIABLE: [u8; 650] = hex!("ff02ffff01ff02ffff03ffff02ff12ffff04ff02ffff04ff8205ffffff04ffff02ff16ffff04ff02ffff04ff2fffff04ffff0bff18ff5f80ffff04ffff02ff16ffff04ff02ffff04ff05ffff04ffff02ff16ffff04ff02ffff04ff0bffff04ffff0bff18ffff0bff14ff17ffff0bff18ffff02ff16ffff04ff02ffff04ff2fffff04ffff0bff18ff5f80ffff04ffff02ff16ffff04ff02ffff04ff81bfffff04ff82017fffff04ff8202ffffff04ff820bffff80808080808080ff808080808080808080ff8080808080ff8080808080ff808080808080ff8080808080ffff018205ffffff01ff088080ff0180ffff04ffff01ffffff3301ff02ff02ffff03ff05ffff01ff0bff7affff02ff1effff04ff02ffff04ff09ffff04ffff02ff1cffff04ff02ffff04ff0dff80808080ff808080808080ffff016a80ff0180ffffff02ffff03ff05ffff01ff02ffff03ffff02ffff03ffff09ff11ff1080ffff01ff02ffff03ffff20ffff09ff29ff0b8080ffff01ff0101ff8080ff0180ff8080ff0180ffff01ff0880ffff01ff02ff12ffff04ff02ffff04ff0dffff04ff0bff808080808080ff0180ffff01ff010180ff0180ffffa04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459aa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ffa102a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222a102a8d5dd63fba471ebcb1f3e8f7c1e1879b7152a6e7298a91ce119a63400ade7c5ffff0bff5affff02ff1effff04ff02ffff04ff05ffff04ffff02ff1cffff04ff02ffff04ff07ff80808080ff808080808080ff0bff14ffff0bff14ff6aff0580ffff0bff14ff0bff4a8080ff018080");
5248pub const FORCE_1_OF_2_W_RESTRICTED_VARIABLE_HASH: [u8; 32] =
5249 hex!("4f7bc8f30deb6dad75a1e29ceacb67fd0fe0eda79173e45295ff2cfbb8de53c6");
5250
5251/// ```text
5252/// ; This is a restriction on delegated puzzles intended to force a coin announcement
5253/// ;
5254/// ; The idea behind enforcing this is that it makes the current coin spend non-replayable since it will be implictly
5255/// ; asserting that a specific coin ID is spent in tandem.
5256/// (mod
5257/// (
5258/// Conditions
5259/// )
5260///
5261/// (include condition_codes.clib)
5262///
5263/// (defun check_conditions (conditions)
5264/// ; If we run out of conditions without finding an assertion, this will raise with "path into atom"
5265/// (if (= (f (f conditions)) ASSERT_COIN_ANNOUNCEMENT)
5266/// conditions
5267/// (c (f conditions) (check_conditions (r conditions)))
5268/// )
5269/// )
5270///
5271/// (check_conditions Conditions)
5272/// )
5273/// ```
5274pub const FORCE_ASSERT_COIN_ANNOUNCEMENT: [u8; 85] = hex!("ff02ffff01ff02ff06ffff04ff02ffff04ff05ff80808080ffff04ffff01ff3dff02ffff03ffff09ff11ff0480ffff0105ffff01ff04ff09ffff02ff06ffff04ff02ffff04ff0dff808080808080ff0180ff018080");
5275pub const FORCE_ASSERT_COIN_ANNOUNCEMENT_HASH: [u8; 32] =
5276 hex!("ca0daca027e5ebd4a61fad7e32cfe1e984ad5b561c2fc08dea30accf3a191fab");
5277
5278/// ```text
5279/// ; This is a restriction on delegated puzzles intended to force a message that asserts the recipient's coin ID
5280/// ;
5281/// ; The idea behind enforcing this is that it makes the current coin spend non-replayable since it will be implictly
5282/// ; asserting that a specific coin ID is spent in tandem.
5283/// (mod
5284/// (
5285/// Conditions
5286/// )
5287///
5288/// (include condition_codes.clib)
5289/// (include utility_macros.clib)
5290///
5291/// (defun check_conditions (conditions)
5292/// ; If we run out of conditions without finding an assertion, this will raise with "path into atom"
5293/// (if (and
5294/// (= (f (f conditions)) SEND_MESSAGE)
5295/// ; This message filter will make sure that the last three bits of the bitmask are set.
5296/// ; The reason we do this is to make sure that there will be a RECIPIENT whose coin ID must be spent
5297/// ; in order for this spend to happen.
5298/// (logand (f (r (f conditions))) 0x07) ; 0x07 == 00 000 111
5299/// )
5300/// conditions
5301/// (c (f conditions) (check_conditions (r conditions)))
5302/// )
5303/// )
5304///
5305/// (check_conditions Conditions)
5306/// )
5307/// ```
5308pub const FORCE_COIN_MESSAGE: [u8; 127] = hex!("ff02ffff01ff02ff06ffff04ff02ffff04ff05ff80808080ffff04ffff01ff42ff02ffff03ffff02ffff03ffff09ff11ff0480ffff01ff02ffff03ffff18ff29ffff010780ffff01ff0101ff8080ff0180ff8080ff0180ffff0105ffff01ff04ff09ffff02ff06ffff04ff02ffff04ff0dff808080808080ff0180ff018080");
5309pub const FORCE_COIN_MESSAGE_HASH: [u8; 32] =
5310 hex!("9618c96b30b96362f6c01716a11f76c630a786697d5bac92345f5ff90b882268");
5311
5312/// ```text
5313/// (mod (CONDITION_OPCODE Conditions)
5314/// (include utility_macros.clib)
5315///
5316/// (defun check_coins (CONDITION_OPCODE conditions)
5317/// (if conditions
5318/// (if (= (f (f conditions)) CONDITION_OPCODE)
5319/// (x)
5320/// (check_coins CONDITION_OPCODE (r conditions))
5321/// )
5322/// 1
5323/// )
5324/// )
5325///
5326/// (assert (check_coins CONDITION_OPCODE Conditions) Conditions)
5327/// )
5328/// ```
5329pub const PREVENT_CONDITION_OPCODE: [u8; 131] = hex!("ff02ffff01ff02ffff03ffff02ff02ffff04ff02ffff04ff05ffff04ff0bff8080808080ffff010bffff01ff088080ff0180ffff04ffff01ff02ffff03ff0bffff01ff02ffff03ffff09ff23ff0580ffff01ff0880ffff01ff02ff02ffff04ff02ffff04ff05ffff04ff1bff808080808080ff0180ffff01ff010180ff0180ff018080");
5330pub const PREVENT_CONDITION_OPCODE_HASH: [u8; 32] =
5331 hex!("046dfa794bb1df14d5dc891b23764a0e31f119546d2c56cdc8df0d31daaa555f");
5332
5333/// ```text
5334/// (mod (Conditions)
5335/// (include utility_macros.clib)
5336/// (include condition_codes.clib)
5337///
5338/// (defun check_coins (conditions count)
5339/// (if conditions
5340/// (check_coins
5341/// (r conditions)
5342/// (if (= (f (f conditions)) CREATE_COIN)
5343/// (+ count 1)
5344/// count
5345/// )
5346/// )
5347/// count
5348/// )
5349/// )
5350///
5351/// (assert (= (check_coins Conditions 0) 1) Conditions)
5352/// )
5353/// ```
5354pub const PREVENT_MULTIPLE_CREATE_COINS: [u8; 143] = hex!("ff02ffff01ff02ffff03ffff09ffff02ff06ffff04ff02ffff04ff05ffff01ff8080808080ffff010180ffff0105ffff01ff088080ff0180ffff04ffff01ff33ff02ffff03ff05ffff01ff02ff06ffff04ff02ffff04ff0dffff04ffff02ffff03ffff09ff11ff0480ffff01ff10ff0bffff010180ffff010b80ff0180ff8080808080ffff010b80ff0180ff018080");
5355pub const PREVENT_MULTIPLE_CREATE_COINS_HASH: [u8; 32] =
5356 hex!("93b8c8abeab8f6bdba4acb49ed49362ecba94b703a48b15c8784f966547b7846");
5357
5358/// ```text
5359/// (mod
5360/// (
5361/// TIMELOCK
5362/// Conditions
5363/// )
5364///
5365/// (include condition_codes.clib)
5366/// (include utility_macros.clib)
5367///
5368/// (defun check_conditions (TIMELOCK conditions)
5369/// (if (and (= (f (f conditions)) ASSERT_SECONDS_RELATIVE) (= (f (r (f conditions))) TIMELOCK))
5370/// conditions
5371/// (c (f conditions) (check_conditions TIMELOCK (r conditions)))
5372/// )
5373/// )
5374///
5375/// (check_conditions TIMELOCK Conditions)
5376/// )
5377/// ```
5378pub const TIMELOCK: [u8; 137] = hex!("ff02ffff01ff02ff06ffff04ff02ffff04ff05ffff04ff0bff8080808080ffff04ffff01ff50ff02ffff03ffff02ffff03ffff09ff23ff0480ffff01ff02ffff03ffff09ff53ff0580ffff01ff0101ff8080ff0180ff8080ff0180ffff010bffff01ff04ff13ffff02ff06ffff04ff02ffff04ff05ffff04ff1bff80808080808080ff0180ff018080");
5379pub const TIMELOCK_HASH: [u8; 32] =
5380 hex!("a6f96d8ecf9bd29e8c41822d231408823707b587bc0d372e5db4ac9733cbea3c");
5381
5382/// ```text
5383/// (mod
5384/// (
5385/// WRAPPER
5386/// DELEGATED_PUZZLE
5387/// wrapper_solution
5388/// delegated_solution
5389/// )
5390///
5391/// (a WRAPPER (c (a DELEGATED_PUZZLE delegated_solution) wrapper_solution))
5392/// )
5393/// ```
5394pub const ADD_DPUZ_WRAPPER: [u8; 19] = hex!("ff02ff02ffff04ffff02ff05ff1780ff0b8080");
5395pub const ADD_DPUZ_WRAPPER_HASH: [u8; 32] =
5396 hex!("6427724905f2dcf8187300ef9a0436a3c96198e4fcd17101d1ded9bc61c3f3bf");
5397
5398/// ```text
5399/// ; This apparent monstrosity of a chiklisp file really does a very simple thing and gets it relative ugliness from
5400/// ; special attention paid to optimizing it.
5401/// ;
5402/// ; The goal of the function is to make sure that some delegated puzzle (inner_most_puzzle_hash) is wrapped by a number
5403/// ; of wrappers (WRAPPER_STACK) that use a specific base puzzle (ADD_WRAPPER_MOD). It uses the information in its solution
5404/// ; to calculate the hash of the following and assert it matches the delegated puzzle being validated:
5405/// ;
5406/// ; (a (q . WRAPPER_MOD) (c (q . WRAPPER) (c delegated_puzzle 1)))
5407/// (mod
5408/// (
5409/// QUOTED_ADD_WRAPPER_MOD_HASH ; The mod hash of the quoted wrapper add-er i.e. (q . ADD_WRAPPER_MOD)
5410/// WRAPPER_STACK ; The list of wrapper hashes (pre-quoted like above) to be run on the delegated puzzle
5411/// delegated_puzzle_hash ; The hash of the delegated puzzle to validate
5412/// inner_most_puzzle_hash ; hash of the thing being wrapped by all of these puzzles
5413/// )
5414///
5415/// (defconstant TWO 2)
5416/// (defconstant SHA_1_NIL 0x4bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a)
5417/// (defconstant SHA_1_1 0x9dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2)
5418/// (defconstant SHA_1_C 0xa8d5dd63fba471ebcb1f3e8f7c1e1879b7152a6e7298a91ce119a63400ade7c5)
5419/// (defconstant SHA_1_A 0xa12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222)
5420/// (defconstant SHA_1_&_NIL 0xba4484b961b7a2369d948d06c55b64bdbfaffb326bc13b490ab1215dd33d8d46)
5421///
5422/// (defun-inline branch_hash (left right)
5423/// (sha256 TWO left right)
5424/// )
5425///
5426/// (defun wrap_inner_most_puzzle_hash (QUOTED_ADD_WRAPPER_MOD_HASH WRAPPER_STACK inner_most_puzzle_hash)
5427/// (if WRAPPER_STACK
5428/// (branch_hash
5429/// SHA_1_A
5430/// (branch_hash
5431/// QUOTED_ADD_WRAPPER_MOD_HASH
5432/// (branch_hash
5433/// (branch_hash
5434/// SHA_1_C
5435/// (branch_hash
5436/// (f WRAPPER_STACK)
5437/// (branch_hash
5438/// (branch_hash
5439/// SHA_1_C
5440/// (branch_hash
5441/// (branch_hash
5442/// SHA_1_1
5443/// (wrap_inner_most_puzzle_hash QUOTED_ADD_WRAPPER_MOD_HASH (r WRAPPER_STACK) inner_most_puzzle_hash)
5444/// )
5445/// SHA_1_&_NIL
5446/// )
5447/// )
5448/// SHA_1_NIL
5449/// )
5450/// )
5451/// )
5452/// SHA_1_NIL
5453/// )
5454/// )
5455/// )
5456/// inner_most_puzzle_hash
5457/// )
5458/// )
5459///
5460/// (if (= delegated_puzzle_hash (wrap_inner_most_puzzle_hash QUOTED_ADD_WRAPPER_MOD_HASH WRAPPER_STACK inner_most_puzzle_hash))
5461/// ()
5462/// (x)
5463/// )
5464/// )
5465/// ```
5466pub const ENFORCE_DPUZ_WRAPPERS: [u8; 363] = hex!("ff02ffff01ff02ffff03ffff09ff17ffff02ff1effff04ff02ffff04ff05ffff04ff0bffff04ff2fff80808080808080ff80ffff01ff088080ff0180ffff04ffff01ffffa0ba4484b961b7a2369d948d06c55b64bdbfaffb326bc13b490ab1215dd33d8d46ffa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2a0a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222ffffa0a8d5dd63fba471ebcb1f3e8f7c1e1879b7152a6e7298a91ce119a63400ade7c5a04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459aff02ff02ffff03ff0bffff01ff0bff16ff1cffff0bff16ff05ffff0bff16ffff0bff16ff12ffff0bff16ff13ffff0bff16ffff0bff16ff12ffff0bff16ffff0bff16ff14ffff02ff1effff04ff02ffff04ff05ffff04ff1bffff04ff17ff80808080808080ff088080ff1a808080ff1a808080ffff011780ff0180ff018080");
5467pub const ENFORCE_DPUZ_WRAPPERS_HASH: [u8; 32] =
5468 hex!("1f94aa2381c1c02fec90687c0b045ef3cad4b458f8eac5bd90695b4d89624f09");
5469
5470/// ```text
5471/// (mod (POOL_PUZZLE_HASH
5472/// P2_SINGLETON_PUZZLE_HASH
5473/// OWNER_PUBKEY
5474/// POOL_REWARD_PREFIX
5475/// WAITINGROOM_PUZHASH
5476/// Truths
5477/// p1
5478/// pool_reward_height
5479/// )
5480///
5481///
5482/// ; POOL_PUZZLE_HASH is commitment to the pool's puzzle hash
5483/// ; P2_SINGLETON_PUZZLE_HASH is the puzzle hash for your pay to singleton puzzle
5484/// ; OWNER_PUBKEY is the farmer pubkey which authorises a travel
5485/// ; POOL_REWARD_PREFIX is network-specific data (mainnet vs testnet) that helps determine if a coin is a pool reward
5486/// ; WAITINGROOM_PUZHASH is the puzzle_hash you'll go to when you initiate the leaving process
5487///
5488/// ; Absorbing money if pool_reward_height is an atom
5489/// ; Escaping if pool_reward_height is ()
5490///
5491/// ; p1 is pool_reward_amount if absorbing money
5492/// ; p1 is extra_data key_value_list if escaping
5493///
5494/// ; pool_reward_amount is the value of the coin reward - this is passed in so that this puzzle will still work after halvenings
5495/// ; pool_reward_height is the block height that the reward was generated at. This is used to calculate the coin ID.
5496/// ; key_value_list is signed extra data that the wallet may want to publicly announce for syncing purposes
5497///
5498/// (include condition_codes.clib)
5499/// (include singleton_truths.clib)
5500///
5501/// ; takes a lisp tree and returns the hash of it
5502/// (defun sha256tree (TREE)
5503/// (if (l TREE)
5504/// (sha256 2 (sha256tree (f TREE)) (sha256tree (r TREE)))
5505/// (sha256 1 TREE)
5506/// )
5507/// )
5508///
5509/// (defun-inline calculate_pool_reward (pool_reward_height P2_SINGLETON_PUZZLE_HASH POOL_REWARD_PREFIX pool_reward_amount)
5510/// (sha256 (logior POOL_REWARD_PREFIX (logand (- (lsh (q . 1) (q . 128)) (q . 1)) pool_reward_height)) P2_SINGLETON_PUZZLE_HASH pool_reward_amount)
5511/// )
5512///
5513/// (defun absorb_pool_reward (POOL_PUZZLE_HASH my_inner_puzzle_hash my_amount pool_reward_amount pool_reward_id)
5514/// (list
5515/// (list CREATE_COIN my_inner_puzzle_hash my_amount)
5516/// (list CREATE_COIN POOL_PUZZLE_HASH pool_reward_amount)
5517/// (list CREATE_PUZZLE_ANNOUNCEMENT pool_reward_id)
5518/// (list ASSERT_COIN_ANNOUNCEMENT (sha256 pool_reward_id '$'))
5519/// )
5520/// )
5521///
5522/// (defun-inline travel_to_waitingroom (OWNER_PUBKEY WAITINGROOM_PUZHASH my_amount extra_data)
5523/// (list (list AGG_SIG_ME OWNER_PUBKEY (sha256tree extra_data))
5524/// (list CREATE_COIN WAITINGROOM_PUZHASH my_amount)
5525/// )
5526/// )
5527///
5528/// ; main
5529///
5530/// (if pool_reward_height
5531/// (absorb_pool_reward POOL_PUZZLE_HASH
5532/// (my_inner_puzzle_hash_truth Truths)
5533/// (my_amount_truth Truths)
5534/// p1
5535/// (calculate_pool_reward pool_reward_height P2_SINGLETON_PUZZLE_HASH POOL_REWARD_PREFIX p1)
5536/// )
5537/// (travel_to_waitingroom OWNER_PUBKEY WAITINGROOM_PUZHASH (my_amount_truth Truths) p1)
5538/// )
5539/// )
5540/// )
5541/// ```
5542pub const POOL_MEMBER_INNERPUZ: [u8; 376] = hex!("ff02ffff01ff02ffff03ff8202ffffff01ff02ff16ffff04ff02ffff04ff05ffff04ff8204bfffff04ff8206bfffff04ff82017fffff04ffff0bffff19ff2fffff18ffff019100ffffffffffffffffffffffffffffffffff8202ff8080ff0bff82017f80ff8080808080808080ffff01ff04ffff04ff08ffff04ff17ffff04ffff02ff1effff04ff02ffff04ff82017fff80808080ff80808080ffff04ffff04ff1cffff04ff5fffff04ff8206bfff80808080ff80808080ff0180ffff04ffff01ffff32ff3d33ff3effff04ffff04ff1cffff04ff0bffff04ff17ff80808080ffff04ffff04ff1cffff04ff05ffff04ff2fff80808080ffff04ffff04ff0affff04ff5fff808080ffff04ffff04ff14ffff04ffff0bff5fffff012480ff808080ff8080808080ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff1effff04ff02ffff04ff09ff80808080ffff02ff1effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080");
5543pub const POOL_MEMBER_INNERPUZ_HASH: [u8; 32] =
5544 hex!("a8490702e333ddd831a3ac9c22d0fa26d2bfeaf2d33608deb22f0e0123eb0494");
5545
5546/// ```text
5547/// (mod (POOL_PUZZLE_HASH
5548/// P2_SINGLETON_PUZZLE_HASH
5549/// OWNER_PUBKEY
5550/// POOL_REWARD_PREFIX
5551/// RELATIVE_LOCK_HEIGHT
5552/// Truths
5553/// spend_type
5554/// p1
5555/// p2
5556/// )
5557///
5558/// ; POOL_PUZZLE_HASH is commitment to the pool's puzzle hash
5559/// ; P2_SINGLETON_PUZZLE_HASH is the puzzlehash for your pay_to_singleton puzzle
5560/// ; OWNER_PUBKEY is the farmer pubkey which signs the exit puzzle_hash
5561/// ; POOL_REWARD_PREFIX is network-specific data (mainnet vs testnet) that helps determine if a coin is a pool reward
5562/// ; RELATIVE_LOCK_HEIGHT is how long it takes to leave
5563///
5564/// ; spend_type is: 0 for absorbing money, 1 to escape
5565/// ; if spend_type is 0
5566/// ; p1 is pool_reward_amount - the value of the coin reward - this is passed in so that this puzzle will still work after halvenings
5567/// ; p2 is pool_reward_height - the block height that the reward was generated at. This is used to calculate the coin ID.
5568/// ; if spend_type is 1
5569/// ; p1 is extra_data key_value_list - signed extra data that the wallet may want to publicly announce for syncing purposes
5570/// ; p2 is destination_puzhash - the location that the escape spend wants to create itself to
5571///
5572/// (include condition_codes.clib)
5573/// (include singleton_truths.clib)
5574///
5575/// ; takes a lisp tree and returns the hash of it
5576/// (defun sha256tree (TREE)
5577/// (if (l TREE)
5578/// (sha256 2 (sha256tree (f TREE)) (sha256tree (r TREE)))
5579/// (sha256 1 TREE)
5580/// )
5581/// )
5582///
5583/// (defun-inline calculate_pool_reward (pool_reward_height P2_SINGLETON_PUZZLE_HASH POOL_REWARD_PREFIX pool_reward_amount)
5584/// (sha256 (logior POOL_REWARD_PREFIX (logand (- (lsh (q . 1) (q . 128)) (q . 1)) pool_reward_height)) P2_SINGLETON_PUZZLE_HASH pool_reward_amount)
5585/// )
5586///
5587/// (defun absorb_pool_reward (POOL_PUZZLE_HASH my_inner_puzzle_hash my_amount pool_reward_amount pool_reward_id)
5588/// (list
5589/// (list CREATE_COIN my_inner_puzzle_hash my_amount)
5590/// (list CREATE_COIN POOL_PUZZLE_HASH pool_reward_amount)
5591/// (list CREATE_PUZZLE_ANNOUNCEMENT pool_reward_id)
5592/// (list ASSERT_COIN_ANNOUNCEMENT (sha256 pool_reward_id '$'))
5593/// )
5594/// )
5595///
5596/// (defun-inline travel_spend (RELATIVE_LOCK_HEIGHT new_puzzle_hash my_amount extra_data)
5597/// (list (list ASSERT_HEIGHT_RELATIVE RELATIVE_LOCK_HEIGHT)
5598/// (list CREATE_COIN new_puzzle_hash my_amount)
5599/// (list AGG_SIG_ME OWNER_PUBKEY (sha256tree (list new_puzzle_hash extra_data)))
5600/// )
5601/// )
5602///
5603/// ; main
5604///
5605/// (if spend_type
5606/// (travel_spend RELATIVE_LOCK_HEIGHT p2 (my_amount_truth Truths) p1)
5607/// (absorb_pool_reward POOL_PUZZLE_HASH
5608/// (my_inner_puzzle_hash_truth Truths)
5609/// (my_amount_truth Truths)
5610/// p1
5611/// (calculate_pool_reward p2 P2_SINGLETON_PUZZLE_HASH POOL_REWARD_PREFIX p1)
5612/// )
5613/// )
5614///
5615/// )
5616/// ```
5617pub const POOL_WAITINGROOM_INNERPUZ: [u8; 412] = hex!("ff02ffff01ff02ffff03ff82017fffff01ff04ffff04ff1cffff04ff5fff808080ffff04ffff04ff12ffff04ff8205ffffff04ff8206bfff80808080ffff04ffff04ff08ffff04ff17ffff04ffff02ff1effff04ff02ffff04ffff04ff8205ffffff04ff8202ffff808080ff80808080ff80808080ff80808080ffff01ff02ff16ffff04ff02ffff04ff05ffff04ff8204bfffff04ff8206bfffff04ff8202ffffff04ffff0bffff19ff2fffff18ffff019100ffffffffffffffffffffffffffffffffff8205ff8080ff0bff8202ff80ff808080808080808080ff0180ffff04ffff01ffff32ff3d52ffff333effff04ffff04ff12ffff04ff0bffff04ff17ff80808080ffff04ffff04ff12ffff04ff05ffff04ff2fff80808080ffff04ffff04ff1affff04ff5fff808080ffff04ffff04ff14ffff04ffff0bff5fffff012480ff808080ff8080808080ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff1effff04ff02ffff04ff09ff80808080ffff02ff1effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080");
5618pub const POOL_WAITINGROOM_INNERPUZ_HASH: [u8; 32] =
5619 hex!("a317541a765bf8375e1c6e7c13503d0d2cbf56cacad5182befe947e78e2c0307");
5620
5621/// ```text
5622/// ;; this code is included in the ROM. Unfortunately, it has a problem that limits
5623/// ;; its usefulness: it is incapable of deserializing atoms with length longer than
5624/// ;; 8191 = 0x1fff.
5625/// ;;
5626/// ;; Because this code is included in the ROM, fixing the bug would be a hard fork
5627/// ;; so we're rather stuck with this bug. We recommend simply using a local version
5628/// ;; of this code when necessary.
5629///
5630/// (mod (input)
5631///
5632/// (defconstant MAX_SINGLE_BYTE 0x7F)
5633/// (defconstant MAX_TWO_BYTE 0xbf)
5634/// (defconstant MAX_THREE_BYTE 0xdf)
5635/// (defconstant MAX_FOUR_BYTE 0xef)
5636/// (defconstant MAX_FIVE_BYTE 0xf7)
5637/// (defconstant MAX_SIX_BYTE 0xfb)
5638/// (defconstant CONS_BOX_MARKER 0xFF)
5639///
5640/// (defun sexp_from_stream (input_stream)
5641/// (if (= (substr input_stream 0 1) CONS_BOX_MARKER)
5642/// (cons_sexp_from_stream (sexp_from_stream (substr input_stream 1)))
5643/// (atom_from_stream (substr input_stream 1) (substr input_stream 0 1))
5644/// )
5645/// )
5646///
5647/// (defun cons_sexp_from_stream (left_sexp_with_input)
5648/// (cons_return (f left_sexp_with_input) (sexp_from_stream (f (r left_sexp_with_input))))
5649/// )
5650///
5651/// (defun cons_return (left_sexp right_sexp_with_input)
5652/// (list (c left_sexp (f right_sexp_with_input)) (f (r right_sexp_with_input)))
5653/// )
5654///
5655/// (defun atom_from_stream (input_file input_bits)
5656/// (if (= input_bits (quote 0x80))
5657/// (list () input_file)
5658/// (if (>s input_bits MAX_SINGLE_BYTE)
5659/// (atom_from_stream_part_two (get_bitcount input_bits input_file))
5660/// (list input_bits input_file)
5661/// )
5662/// )
5663/// )
5664///
5665/// ; Note that we reject any serialized atom here with more than 3 bytes of
5666/// ; encoded length prefix, even though the Rust and Python KLVM interpreters
5667/// ; and deserializers support more.
5668/// ; This allows 5 + 8 = 13 bits = 8191-byte atoms
5669/// ; Also note that this does not limit intermediate atom length. Those limits
5670/// ; are implemented in the klvm interpreters theselves
5671/// (defun-inline get_bitcount (input_bits input_file)
5672/// (if (>s input_bits MAX_TWO_BYTE)
5673/// (if (>s input_bits MAX_THREE_BYTE)
5674/// (x)
5675/// ;three byte length prefix
5676/// (list (concat (logand (quote 0x1f) input_bits) (substr input_file 0 1)) (substr input_file 1))
5677/// )
5678/// ;two byte length prefix
5679/// (list (logand (quote 0x3f) input_bits) input_file)
5680/// )
5681/// )
5682///
5683/// (defun atom_from_stream_part_two ((size_to_read input_file))
5684/// (list (substr input_file 0 size_to_read) (substr input_file size_to_read))
5685/// )
5686///
5687/// ; main
5688/// (f (sexp_from_stream input))
5689///
5690/// )
5691/// ```
5692pub const CHIKLISP_DESERIALISATION: [u8; 471] = hex!("ff02ffff01ff05ffff02ff3effff04ff02ffff04ff05ff8080808080ffff04ffff01ffffff81ff7fff81df81bfffffff02ffff03ffff09ff0bffff01818080ffff01ff04ff80ffff04ff05ff808080ffff01ff02ffff03ffff0aff0bff1880ffff01ff02ff1affff04ff02ffff04ffff02ffff03ffff0aff0bff1c80ffff01ff02ffff03ffff0aff0bff1480ffff01ff0880ffff01ff04ffff0effff18ffff011fff0b80ffff0cff05ff80ffff01018080ffff04ffff0cff05ffff010180ff80808080ff0180ffff01ff04ffff18ffff013fff0b80ffff04ff05ff80808080ff0180ff80808080ffff01ff04ff0bffff04ff05ff80808080ff018080ff0180ff04ffff0cff15ff80ff0980ffff04ffff0cff15ff0980ff808080ffff04ffff04ff05ff1380ffff04ff2bff808080ffff02ff16ffff04ff02ffff04ff09ffff04ffff02ff3effff04ff02ffff04ff15ff80808080ff8080808080ff02ffff03ffff09ffff0cff05ff80ffff010180ff1080ffff01ff02ff2effff04ff02ffff04ffff02ff3effff04ff02ffff04ffff0cff05ffff010180ff80808080ff80808080ffff01ff02ff12ffff04ff02ffff04ffff0cff05ffff010180ffff04ffff0cff05ff80ffff010180ff808080808080ff0180ff018080");
5693pub const CHIKLISP_DESERIALISATION_HASH: [u8; 32] =
5694 hex!("94ec19077f9a34e0b11ad2456af0170f4cc03f11230ca42e3f82e6e644ac4f5d");
5695
5696/// ```text
5697/// (mod (block_decompresser_program (historical_blocks_tree))
5698///
5699/// (defconstant local_deserialize_mod
5700/// ;; this monstrosity is the assembly output of `chiklisp_deserialisation.clsp`
5701/// ;; it's pasted in here because the compiler doesn't yet support nested `mod`
5702/// ;; my apologies -- RK
5703///
5704/// (a (q 5 (a 62 (c 2 (c 5 ()))))
5705/// (c (q ((-1 . 127) -33 . -65) ((a (i (= 11 (q . -128)) (q 4 () (c 5 ())) (q 2 (i (>s 11 24) (q 2 26 (c 2 (c (a (i (>s 11 28) (q 2 (i (>s 11 20) (q 8) (q 4 (concat (logand (q . 31) 11) (substr 5 () (q . 1))) (c (substr 5 (q . 1)) ()))) 1) (q 4 (logand (q . 63) 11) (c 5 ()))) 1) ()))) (q 4 11 (c 5 ()))) 1)) 1) 4 (substr 21 () 9) (c (substr 21 9) ())) (c (c 5 19) (c 43 ())) (a 22 (c 2 (c 9 (c (a 62 (c 2 (c 21 ()))) ())))) 2 (i (= (substr 5 () (q . 1)) 16) (q 2 46 (c 2 (c (a 62 (c 2 (c (substr 5 (q . 1)) ()))) ()))) (q 2 18 (c 2 (c (substr 5 (q . 1)) (c (substr 5 () (q . 1)) ()))))) 1)
5706/// 1))
5707/// )
5708///
5709/// (defun sha256tree
5710/// (TREE)
5711/// (if (l TREE)
5712/// (sha256 2 (sha256tree (f TREE)) (sha256tree (r TREE)))
5713/// (sha256 1 TREE)
5714/// )
5715/// )
5716///
5717/// (defun process_coin_spend ((parent puzzle amount solution . spend_level_extras))
5718/// (c parent (c (sha256tree puzzle) (c amount (c (a puzzle solution) spend_level_extras))))
5719/// )
5720///
5721/// (defun recurse (coin_spends)
5722/// (if coin_spends
5723/// (c (process_coin_spend (f coin_spends)) (recurse (r coin_spends)))
5724/// 0
5725/// )
5726/// )
5727///
5728/// (defun process-decompressor ((coin_spends . block-level-extras))
5729/// (c (recurse coin_spends) block-level-extras)
5730/// )
5731///
5732/// (process-decompressor (a block_decompresser_program (list local_deserialize_mod historical_blocks_tree))))
5733/// )
5734/// ```
5735pub const ROM_BOOTSTRAP_GENERATOR: [u8; 737] = hex!("ff02ffff01ff02ff0cffff04ff02ffff04ffff02ff05ffff04ff08ffff04ff13ff80808080ff80808080ffff04ffff01ffffff02ffff01ff05ffff02ff3effff04ff02ffff04ff05ff8080808080ffff04ffff01ffffff81ff7fff81df81bfffffff02ffff03ffff09ff0bffff01818080ffff01ff04ff80ffff04ff05ff808080ffff01ff02ffff03ffff0aff0bff1880ffff01ff02ff1affff04ff02ffff04ffff02ffff03ffff0aff0bff1c80ffff01ff02ffff03ffff0aff0bff1480ffff01ff0880ffff01ff04ffff0effff18ffff011fff0b80ffff0cff05ff80ffff01018080ffff04ffff0cff05ffff010180ff80808080ff0180ffff01ff04ffff18ffff013fff0b80ffff04ff05ff80808080ff0180ff80808080ffff01ff04ff0bffff04ff05ff80808080ff018080ff0180ff04ffff0cff15ff80ff0980ffff04ffff0cff15ff0980ff808080ffff04ffff04ff05ff1380ffff04ff2bff808080ffff02ff16ffff04ff02ffff04ff09ffff04ffff02ff3effff04ff02ffff04ff15ff80808080ff8080808080ff02ffff03ffff09ffff0cff05ff80ffff010180ff1080ffff01ff02ff2effff04ff02ffff04ffff02ff3effff04ff02ffff04ffff0cff05ffff010180ff80808080ff80808080ffff01ff02ff12ffff04ff02ffff04ffff0cff05ffff010180ffff04ffff0cff05ff80ffff010180ff808080808080ff0180ff018080ff04ffff02ff16ffff04ff02ffff04ff09ff80808080ff0d80ffff04ff09ffff04ffff02ff1effff04ff02ffff04ff15ff80808080ffff04ff2dffff04ffff02ff15ff5d80ff7d80808080ffff02ffff03ff05ffff01ff04ffff02ff0affff04ff02ffff04ff09ff80808080ffff02ff16ffff04ff02ffff04ff0dff8080808080ff8080ff0180ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff1effff04ff02ffff04ff09ff80808080ffff02ff1effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080");
5736pub const ROM_BOOTSTRAP_GENERATOR_HASH: [u8; 32] =
5737 hex!("161bade1f822dcd62ab712ebaf30f3922a301e48a639e4295c5685f8bece7bd9");
5738
5739/// ```text
5740/// ; TODO convert generators arg to list of generators
5741///
5742/// (mod (decompress_puzzle decompress_coin_spend_entry start end compressed_cses deserialize gen_list reserved_arg)
5743///
5744/// (defun decompress_cses (decompress_puzzle decompress_coin_spend_entry cses deserialize puzzle_prefix)
5745/// (if cses
5746/// (c (a decompress_coin_spend_entry (list deserialize decompress_puzzle puzzle_prefix (f cses)))
5747/// (decompress_cses decompress_puzzle decompress_coin_spend_entry (r cses) deserialize puzzle_prefix ))
5748/// ()) )
5749///
5750/// (list (decompress_cses decompress_puzzle decompress_coin_spend_entry compressed_cses deserialize (substr (f gen_list) start end)))
5751///
5752/// )
5753/// ```
5754pub const BLOCK_PROGRAM_ZERO: [u8; 170] = hex!("ff02ffff01ff04ffff02ff02ffff04ff02ffff04ff05ffff04ff0bffff04ff5fffff04ff81bfffff04ffff0cff82027fff17ff2f80ff8080808080808080ff8080ffff04ffff01ff02ffff03ff17ffff01ff04ffff02ff0bffff04ff2fffff04ff05ffff04ff5fffff04ff27ff808080808080ffff02ff02ffff04ff02ffff04ff05ffff04ff0bffff04ff37ffff04ff2fffff04ff5fff808080808080808080ff8080ff0180ff018080");
5755pub const BLOCK_PROGRAM_ZERO_HASH: [u8; 32] =
5756 hex!("f0a38c8efe58895ae527c65c37f700a4238504691b83990e5dd91bd8b3c30eae");
5757
5758/// ```text
5759/// (mod (deserialize decompress_puzzle puzzle_prefix cse)
5760///
5761/// ; decompress a single compressed standard transaction
5762///
5763/// (c (f (f cse)) (c (a decompress_puzzle (list deserialize puzzle_prefix (f (f (r cse))) (q . 0xff018080))) (c (f (r (f cse))) (r (f (r cse))))))
5764///
5765/// )
5766/// ```
5767pub const DECOMPRESS_COIN_SPEND_ENTRY_WITH_PREFIX: [u8; 54] = hex!("ff04ff47ffff04ffff02ff05ffff04ff02ffff04ff0bffff04ff8197ffff01ff84ff0180808080808080ffff04ff81a7ff81d7808080");
5768pub const DECOMPRESS_COIN_SPEND_ENTRY_WITH_PREFIX_HASH: [u8; 32] =
5769 hex!("92aa4bc8060a8836355a1884075141b4791ce1b67ae6092bb166b2845954bc89");
5770
5771/// ```text
5772/// (mod (deserialize decompress_puzzle puzzle_prefix suffix cse)
5773///
5774/// ; decompress a single compressed standard transaction
5775/// (c (f cse) (c (a decompress_puzzle (list deserialize puzzle_prefix (f (f (r cse))) suffix)) (c (f (r (f cse))) (r (f (r cse))))))
5776/// )
5777/// ```
5778pub const DECOMPRESS_COIN_SPEND_ENTRY: [u8; 55] = hex!("ff04ff4fffff04ffff02ff05ffff04ff02ffff04ff0bffff04ff82012fffff04ff17ff808080808080ffff04ff82014fff8201af808080");
5779pub const DECOMPRESS_COIN_SPEND_ENTRY_HASH: [u8; 32] =
5780 hex!("9d98ed08770d31be4bd1bde4705dab388db5e7e9c349f5a76fc3c347aa3a0b79");
5781
5782/// ```text
5783/// (mod (deserialize puzzle_prefix pubkey suffix)
5784///
5785/// (a deserialize (list (concat puzzle_prefix pubkey suffix)))
5786///
5787/// )
5788/// ```
5789pub const DECOMPRESS_PUZZLE: [u8; 21] = hex!("ff02ff02ffff04ffff0eff05ff0bff1780ff808080");
5790pub const DECOMPRESS_PUZZLE_HASH: [u8; 32] =
5791 hex!("fe94c58f1117afe315e0450daca1c62460ec1a1c439cd4018d79967a5d7d1370");