forked from julia-social/julia_did_chialisp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaunch_issuer_key.clsp
More file actions
90 lines (82 loc) · 4.03 KB
/
Copy pathlaunch_issuer_key.clsp
File metadata and controls
90 lines (82 loc) · 4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
;; Copyright 2026 Julia.Social, Inc.
;;
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;; http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
(mod (curried-args solution)
(include *standard-cl-26*)
(defun print (l x) (i (all "$print$" l x) x x))
(defconstant ZERO_BIT_FIELD_HASH 0xce8f7180a0e5e32c4c806f0477778ffe4c5b125a892c4eb632177d125b183e32)
; Creates new issuer key singletons from the owning DID. Each key defines a signing key,
; validity period, maximum credential expiration, allowed claim properties, and optional
; payment requirement.
(include "condition_codes.clib")
(include "curry_and_treehash.clib")
(include "sha256tree.clib")
(include "did_puzzles.clib")
(embed-file launcher-puzzlehash bin "singleton_launcher.clsp.hash.bin")
(defun construct-conditions (my-launcher-id my-coin-id julia-did-puzzlehash issuer-key-puzzlehash solution amount)
(if (l solution)
(assign
public-key (f solution)
valid-from (f (r solution))
valid-to (f (r (r solution)))
max-expiration (f (r (r (r solution))))
keyhash-root (f (r (r (r (r solution)))))
mode-1-payment-puzzlehash (f (r (r (r (r (r solution))))))
mode-1-payment-mojos (f (r (r (r (r (r (r solution)))))))
solution-remainder (r (r (r (r (r (r (r solution)))))))
child-launcher-coin-id (coinid my-coin-id launcher-puzzlehash amount)
target-coin-curried-args-hash (sha256tree (list my-launcher-id issuer-key-puzzlehash julia-did-puzzlehash child-launcher-coin-id public-key ZERO_BIT_FIELD_HASH valid-from valid-to max-expiration keyhash-root mode-1-payment-puzzlehash mode-1-payment-mojos))
target-coin-puzzlehash (issuer-key-coin-puzzlehash
issuer-key-puzzlehash
child-launcher-coin-id
target-coin-curried-args-hash)
(if (> mode-1-payment-mojos 1)
(c (list CREATE_COIN launcher-puzzlehash amount)
(c (list RECEIVE_MESSAGE 0x3F "JDIDI" (coinid child-launcher-coin-id target-coin-puzzlehash 1))
(construct-conditions my-launcher-id my-coin-id julia-did-puzzlehash issuer-key-puzzlehash solution-remainder (+ amount 2))))
(x 41) ; free anyone-can-spend coins invite griefers
)
)
() ; end of recursion
)
)
; solution format:
; my-parent
; my-launcher-id
; issuer-key-puzzlehash
; sets of:
; public key
; valid-from datetime
; valid-to datetime
; max credential expiration
; root of sha256 tree of allowed credential claim key hashes
; mode-1-payment-puzzlehash (or 0 for no payment)
; mode-1-payment-mojos (or 0 for no payment)
;
; NOTE: when launching multiple issuer keys, the launcher coins will each get different amounts, starting at 2 and increasing by 2.
; However, the actual issuer key singletons will all get amount 1. So the extra mojos are a mini-"flash loan"
; and you only need to actually provide 1 mojo per singleton launched.
(assign
my-parent (f solution)
my-launcher-id (f (r solution))
issuer-key-puzzlehash (f (r (r solution)))
solution-remainder (r (r (r solution)))
julia-did-puzzlehash (f curried-args)
my-puzzlehash (julia-DID-coin-puzzlehash julia-did-puzzlehash my-launcher-id (sha256tree curried-args))
my-coin-id (coinid my-parent my-puzzlehash 1)
(list curried-args
(c (list ASSERT_MY_COIN_ID my-coin-id)
(construct-conditions my-launcher-id my-coin-id julia-did-puzzlehash issuer-key-puzzlehash solution-remainder 2))
)
)
)