2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let a = fromBase64String("base64:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqlAiANSmBpDHYKP9sKgeN/l1bAb28g/tGlgDkwT5FiMN4X3pwdvdxE7mvSR8/41dU9rx4jG+6tZpb1ULVDPs431tR2IRaTXw5Cj+Ac2vhL+5JamCerGD1UW+bh/EGQtxo8W3YLDrofXB5QHJx4Pkz2Kgf+oS/C8hHuB/U4krO76U0507GTjZPP9kRQ0uLSMeqQXt8wXS+nMp5wajqxPpDLMaSREgsKwv/AEkP4dzpTYbikLBYl4qtdJsD84HLFSkiwd3BhcOrPjoIYmLxQuBD5TIMKTKD3sdZgaY9rsyqx3A00innyxD6zp3b4gFpUOX8JxKZdEC2myEqleNgg7GzwIDAQAB") |
---|
5 | | - | |
---|
6 | | - | let b = addressFromStringValue("3NCiG28LmWyTigWG13E5QnvdHBsZFYXSS2j") |
---|
7 | | - | |
---|
8 | | - | let c = 50 |
---|
9 | | - | |
---|
10 | | - | let d = "INIT" |
---|
11 | | - | |
---|
12 | | - | let e = "READY" |
---|
13 | | - | |
---|
14 | | - | let f = "FINISHED" |
---|
15 | | - | |
---|
16 | | - | func g (h) = if ((0 > h)) |
---|
17 | | - | then -(h) |
---|
18 | | - | else h |
---|
19 | | - | |
---|
20 | | - | |
---|
21 | | - | func i (j) = { |
---|
22 | | - | let k = size(j) |
---|
23 | | - | if ((k == 0)) |
---|
24 | | - | then throw("Parameter size must be greater then 0") |
---|
25 | | - | else if ((k > 99)) |
---|
26 | | - | then throw("Parameter size must be less then 100") |
---|
27 | | - | else if ((10 > k)) |
---|
28 | | - | then (("0" + toString(k)) + j) |
---|
29 | | - | else (toString(k) + j) |
---|
30 | | - | } |
---|
31 | | - | |
---|
32 | | - | |
---|
33 | | - | func l (m,n,o) = { |
---|
34 | | - | let p = ((i(m) + "_") + i(n)) |
---|
35 | | - | if ((o == "")) |
---|
36 | | - | then p |
---|
37 | | - | else ((p + "_") + i(o)) |
---|
38 | | - | } |
---|
39 | | - | |
---|
40 | | - | |
---|
41 | | - | func q (r) = if ((size(r) > 0)) |
---|
42 | | - | then drop(r, 1) |
---|
43 | | - | else r |
---|
44 | | - | |
---|
45 | | - | |
---|
46 | | - | func s (r) = { |
---|
47 | | - | let k = size(r) |
---|
48 | | - | if ((k > 0)) |
---|
49 | | - | then { |
---|
50 | | - | let t = parseIntValue(take(r, 2)) |
---|
51 | | - | let u = take(drop(r, 2), t) |
---|
52 | | - | let v = drop(r, (t + 2)) |
---|
53 | | - | let w = q(v) |
---|
54 | | - | [u, w] |
---|
55 | | - | } |
---|
56 | | - | else throw("Empty string was passed into parseNextAttribute func") |
---|
57 | | - | } |
---|
58 | | - | |
---|
59 | | - | |
---|
60 | | - | func x (y) = { |
---|
61 | | - | let z = s(y) |
---|
62 | | - | let n = s(z[1]) |
---|
63 | | - | let A = s(n[1]) |
---|
64 | | - | [z[0], n[0], n[0], A[0]] |
---|
65 | | - | } |
---|
66 | | - | |
---|
67 | | - | |
---|
68 | | - | func B (C) = { |
---|
69 | | - | let D = { |
---|
70 | | - | let E = getString(this, C) |
---|
71 | | - | if ($isInstanceOf(E, "String")) |
---|
72 | | - | then { |
---|
73 | | - | let F = E |
---|
74 | | - | F |
---|
75 | | - | } |
---|
76 | | - | else throw(("Couldn't find game by " + C)) |
---|
77 | | - | } |
---|
78 | | - | x(D) |
---|
79 | | - | } |
---|
80 | | - | |
---|
81 | | - | |
---|
82 | | - | func G (H,I) = { |
---|
83 | | - | let J = g(toInt(I)) |
---|
84 | | - | let K = toBytes(J) |
---|
85 | | - | let k = (size(H) / 8) |
---|
86 | | - | if ((0 == k)) |
---|
87 | | - | then [K, drop(I, 1)] |
---|
88 | | - | else { |
---|
89 | | - | let L = if (if (if (if (if (if (if (if ((k >= 1)) |
---|
90 | | - | then (take(H, 8) == K) |
---|
91 | | - | else false) |
---|
92 | | - | then true |
---|
93 | | - | else if ((k >= 2)) |
---|
94 | | - | then (take(drop(H, (1 * 8)), 8) == K) |
---|
95 | | - | else false) |
---|
96 | | - | then true |
---|
97 | | - | else if ((k >= 3)) |
---|
98 | | - | then (take(drop(H, (2 * 8)), 8) == K) |
---|
99 | | - | else false) |
---|
100 | | - | then true |
---|
101 | | - | else if ((k >= 4)) |
---|
102 | | - | then (take(drop(H, (3 * 8)), 8) == K) |
---|
103 | | - | else false) |
---|
104 | | - | then true |
---|
105 | | - | else if ((k >= 5)) |
---|
106 | | - | then (take(drop(H, (4 * 8)), 8) == K) |
---|
107 | | - | else false) |
---|
108 | | - | then true |
---|
109 | | - | else if ((k >= 6)) |
---|
110 | | - | then (take(drop(H, (5 * 8)), 8) == K) |
---|
111 | | - | else false) |
---|
112 | | - | then true |
---|
113 | | - | else if ((k >= 7)) |
---|
114 | | - | then (take(drop(H, (6 * 8)), 8) == K) |
---|
115 | | - | else false) |
---|
116 | | - | then true |
---|
117 | | - | else if ((k >= 8)) |
---|
118 | | - | then (take(drop(H, (7 * 8)), 8) == K) |
---|
119 | | - | else false |
---|
120 | | - | if (L) |
---|
121 | | - | then [H, drop(I, 1)] |
---|
122 | | - | else [(H + K), drop(I, 1)] |
---|
123 | | - | } |
---|
124 | | - | } |
---|
125 | | - | |
---|
126 | | - | |
---|
127 | | - | func M (C,N,O,P) = { |
---|
128 | | - | let Q = toBytes("") |
---|
129 | | - | let R = sha256(P) |
---|
130 | | - | let S = G(Q, R) |
---|
131 | | - | let T = G(S[0], S[1]) |
---|
132 | | - | let U = G(T[0], T[1]) |
---|
133 | | - | let V = G(U[0], U[1]) |
---|
134 | | - | let W = G(V[0], V[1]) |
---|
135 | | - | let X = G(W[0], W[1]) |
---|
136 | | - | let Y = G(X[0], X[1]) |
---|
137 | | - | let Z = G(Y[0], Y[1]) |
---|
138 | | - | Z[0] |
---|
139 | | - | } |
---|
140 | | - | |
---|
141 | | - | |
---|
142 | | - | func aa (C,ab,ac,ad) = { |
---|
143 | | - | let ae = take(ab.key, c) |
---|
144 | | - | if ((ad >= ac)) |
---|
145 | | - | then true |
---|
146 | | - | else if (if (if ((C == ae)) |
---|
147 | | - | then (size(ab.key) > c) |
---|
148 | | - | else false) |
---|
149 | | - | then !(isDefined(getString(this, ab.key))) |
---|
150 | | - | else false) |
---|
151 | | - | then { |
---|
152 | | - | let E = ab.value |
---|
153 | | - | if ($isInstanceOf(E, "String")) |
---|
154 | | - | then { |
---|
155 | | - | let F = E |
---|
156 | | - | true |
---|
157 | | - | } |
---|
158 | | - | else throw((C + " draw: only String type is accepted for data transactions")) |
---|
159 | | - | } |
---|
160 | | - | else false |
---|
161 | | - | } |
---|
162 | | - | |
---|
163 | | - | |
---|
164 | | - | @Callable(af) |
---|
165 | | - | func initDraw (C) = { |
---|
166 | | - | let ag = (size(fromBase58String(C)) > 0) |
---|
167 | | - | if ((size(C) != c)) |
---|
168 | | - | then throw("Draw Id must be exactly 50 simbols") |
---|
169 | | - | else if (!(ag)) |
---|
170 | | - | then throw("Draw id must be in Base58 format") |
---|
171 | | - | else { |
---|
172 | | - | let n = toBase58String(af.callerPublicKey) |
---|
173 | | - | let ah = l(d, n, "") |
---|
174 | | - | WriteSet([DataEntry(C, ah)]) |
---|
175 | | - | } |
---|
176 | | - | } |
---|
177 | | - | |
---|
178 | | - | |
---|
179 | | - | |
---|
180 | | - | @Callable(af) |
---|
181 | | - | func ready (C) = { |
---|
182 | | - | let ai = B(C) |
---|
183 | | - | let m = ai[0] |
---|
184 | | - | let n = ai[1] |
---|
185 | | - | let aj = fromBase58String(n) |
---|
186 | | - | if ((m != d)) |
---|
187 | | - | then throw((C + " draw: moving into READY state is allowed only from INIT state")) |
---|
188 | | - | else if ((aj != af.callerPublicKey)) |
---|
189 | | - | then throw((C + "draw: moving into READY state is allowed for organizer only")) |
---|
190 | | - | else { |
---|
191 | | - | let ak = l(d, n, "") |
---|
192 | | - | WriteSet([DataEntry(C, ak)]) |
---|
193 | | - | } |
---|
194 | | - | } |
---|
195 | | - | |
---|
196 | | - | |
---|
197 | | - | |
---|
198 | | - | @Callable(af) |
---|
199 | | - | func random (C,P) = { |
---|
200 | | - | let N = 1 |
---|
201 | | - | let O = 100 |
---|
202 | | - | let ai = B(C) |
---|
203 | | - | let m = ai[0] |
---|
204 | | - | let n = ai[1] |
---|
205 | | - | let aj = fromBase58String(n) |
---|
206 | | - | if ((m != e)) |
---|
207 | | - | then throw((C + " draw: it must be in READY state to generate random numbers")) |
---|
208 | | - | else if (!(rsaVerify(SHA256, toBytes(C), P, a))) |
---|
209 | | - | then throw("Invalid RSA signature") |
---|
210 | | - | else { |
---|
211 | | - | let al = M(C, N, O, P) |
---|
212 | | - | let k = size(al) |
---|
213 | | - | let am = if ((k >= 1)) |
---|
214 | | - | then toString(toInt(take(drop(al, 0), 8))) |
---|
215 | | - | else "" |
---|
216 | | - | let an = if ((k >= 2)) |
---|
217 | | - | then ((am + "_") + toString(toInt(take(drop(al, (1 * 8)), 8)))) |
---|
218 | | - | else am |
---|
219 | | - | let ao = if ((k >= 3)) |
---|
220 | | - | then ((an + "_") + toString(toInt(take(drop(al, (2 * 8)), 8)))) |
---|
221 | | - | else an |
---|
222 | | - | let ap = if ((k >= 4)) |
---|
223 | | - | then ((ao + "_") + toString(toInt(take(drop(al, (3 * 8)), 8)))) |
---|
224 | | - | else ao |
---|
225 | | - | let aq = if ((k >= 5)) |
---|
226 | | - | then ((ap + "_") + toString(toInt(take(drop(al, (4 * 8)), 8)))) |
---|
227 | | - | else ap |
---|
228 | | - | let ar = if ((k >= 6)) |
---|
229 | | - | then ((aq + "_") + toString(toInt(take(drop(al, (5 * 8)), 8)))) |
---|
230 | | - | else aq |
---|
231 | | - | let as = if ((k >= 7)) |
---|
232 | | - | then ((ar + "_") + toString(toInt(take(drop(al, (6 * 8)), 8)))) |
---|
233 | | - | else ar |
---|
234 | | - | let at = if ((k >= 8)) |
---|
235 | | - | then ((as + "_") + toString(toInt(take(drop(al, (7 * 8)), 8)))) |
---|
236 | | - | else as |
---|
237 | | - | WriteSet([DataEntry(C, l(f, n, at))]) |
---|
238 | | - | } |
---|
239 | | - | } |
---|
240 | | - | |
---|
241 | | - | |
---|
242 | | - | @Verifier(au) |
---|
243 | | - | func av () = { |
---|
244 | | - | let E = au |
---|
245 | | - | if ($isInstanceOf(E, "DataTransaction")) |
---|
246 | | - | then { |
---|
247 | | - | let aw = E |
---|
248 | | - | let ax = aw.data[0] |
---|
249 | | - | let C = take(ax.key, c) |
---|
250 | | - | let ai = B(C) |
---|
251 | | - | let m = ai[0] |
---|
252 | | - | let n = ai[1] |
---|
253 | | - | let aj = fromBase58String(n) |
---|
254 | | - | let ac = size(aw.data) |
---|
255 | | - | if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if ((m == d)) |
---|
256 | | - | then sigVerify(au.bodyBytes, au.proofs[0], aj) |
---|
257 | | - | else false) |
---|
258 | | - | then (ac > 0) |
---|
259 | | - | else false) |
---|
260 | | - | then (15 >= ac) |
---|
261 | | - | else false) |
---|
262 | | - | then aa(C, ax, ac, 0) |
---|
263 | | - | else false) |
---|
264 | | - | then aa(C, aw.data[1], ac, 1) |
---|
265 | | - | else false) |
---|
266 | | - | then aa(C, aw.data[2], ac, 2) |
---|
267 | | - | else false) |
---|
268 | | - | then aa(C, aw.data[3], ac, 3) |
---|
269 | | - | else false) |
---|
270 | | - | then aa(C, aw.data[4], ac, 4) |
---|
271 | | - | else false) |
---|
272 | | - | then aa(C, aw.data[5], ac, 5) |
---|
273 | | - | else false) |
---|
274 | | - | then aa(C, aw.data[6], ac, 6) |
---|
275 | | - | else false) |
---|
276 | | - | then aa(C, aw.data[7], ac, 7) |
---|
277 | | - | else false) |
---|
278 | | - | then aa(C, aw.data[8], ac, 8) |
---|
279 | | - | else false) |
---|
280 | | - | then aa(C, aw.data[9], ac, 9) |
---|
281 | | - | else false) |
---|
282 | | - | then aa(C, aw.data[10], ac, 10) |
---|
283 | | - | else false) |
---|
284 | | - | then aa(C, aw.data[11], ac, 11) |
---|
285 | | - | else false) |
---|
286 | | - | then aa(C, aw.data[12], ac, 12) |
---|
287 | | - | else false) |
---|
288 | | - | then aa(C, aw.data[13], ac, 13) |
---|
289 | | - | else false) |
---|
290 | | - | then aa(C, aw.data[14], ac, 14) |
---|
291 | | - | else false |
---|
292 | | - | } |
---|
293 | | - | else if ($isInstanceOf(E, "SetScriptTransaction")) |
---|
294 | | - | then { |
---|
295 | | - | let ay = E |
---|
296 | | - | true |
---|
297 | | - | } |
---|
298 | | - | else false |
---|
299 | | - | } |
---|
300 | | - | |
---|
| 2 | + | {-# CONTENT_TYPE EXPRESSION #-} |
---|
| 3 | + | let PubKey1 = base58'854p8BYzrj6yBPRPmfQur3oF1Rjc1AJ548qRp5FT5kDa' |
---|
| 4 | + | let PubKey2 = base58'DKGFPozLrsiR8NM4NJzqQaBYC8NyGYjuw2hDYicQVjco' |
---|
| 5 | + | let sig1 = if (sigVerify(tx.bodyBytes, tx.proofs[0], PubKey1)) |
---|
| 6 | + | then 1 |
---|
| 7 | + | else 0 |
---|
| 8 | + | let sig2 = if (sigVerify(tx.bodyBytes, tx.proofs[1], PubKey2)) |
---|
| 9 | + | then 1 |
---|
| 10 | + | else 0 |
---|
| 11 | + | ((sig1 + sig2) > 0) |
---|