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 = toBytes("") |
---|
11 | | - | |
---|
12 | | - | let e = "INIT" |
---|
13 | | - | |
---|
14 | | - | let f = "READY" |
---|
15 | | - | |
---|
16 | | - | let g = "FINISHED" |
---|
17 | | - | |
---|
18 | | - | func h (i) = if ((0 > i)) |
---|
19 | | - | then -(i) |
---|
20 | | - | else i |
---|
21 | | - | |
---|
22 | | - | |
---|
23 | | - | func j (k,l,m) = { |
---|
24 | | - | let n = ((k + "_") + l) |
---|
25 | | - | if ((m == "")) |
---|
26 | | - | then n |
---|
27 | | - | else ((n + "_") + m) |
---|
28 | | - | } |
---|
29 | | - | |
---|
30 | | - | |
---|
31 | | - | func o (p) = { |
---|
32 | | - | let q = getStringValue(this, p) |
---|
33 | | - | split(q, "_") |
---|
34 | | - | } |
---|
35 | | - | |
---|
36 | | - | |
---|
37 | | - | func r (s,t) = { |
---|
38 | | - | let u = h(toInt(t)) |
---|
39 | | - | let v = toBytes(u) |
---|
40 | | - | let w = (size(s) / 8) |
---|
41 | | - | if ((0 == w)) |
---|
42 | | - | then [v, drop(t, 1)] |
---|
43 | | - | else { |
---|
44 | | - | let x = if (if (if (if (if (if (if (if (if ((w >= 1)) |
---|
45 | | - | then (take(s, 8) == v) |
---|
46 | | - | else false) |
---|
47 | | - | then true |
---|
48 | | - | else if ((w >= 2)) |
---|
49 | | - | then (take(drop(s, (1 * 8)), 8) == v) |
---|
50 | | - | else false) |
---|
51 | | - | then true |
---|
52 | | - | else if ((w >= 3)) |
---|
53 | | - | then (take(drop(s, (2 * 8)), 8) == v) |
---|
54 | | - | else false) |
---|
55 | | - | then true |
---|
56 | | - | else if ((w >= 4)) |
---|
57 | | - | then (take(drop(s, (3 * 8)), 8) == v) |
---|
58 | | - | else false) |
---|
59 | | - | then true |
---|
60 | | - | else if ((w >= 5)) |
---|
61 | | - | then (take(drop(s, (4 * 8)), 8) == v) |
---|
62 | | - | else false) |
---|
63 | | - | then true |
---|
64 | | - | else if ((w >= 6)) |
---|
65 | | - | then (take(drop(s, (5 * 8)), 8) == v) |
---|
66 | | - | else false) |
---|
67 | | - | then true |
---|
68 | | - | else if ((w >= 7)) |
---|
69 | | - | then (take(drop(s, (6 * 8)), 8) == v) |
---|
70 | | - | else false) |
---|
71 | | - | then true |
---|
72 | | - | else if ((w >= 8)) |
---|
73 | | - | then (take(drop(s, (7 * 8)), 8) == v) |
---|
74 | | - | else false) |
---|
75 | | - | then true |
---|
76 | | - | else if ((w >= 9)) |
---|
77 | | - | then (take(drop(s, (8 * 8)), 8) == v) |
---|
78 | | - | else false |
---|
79 | | - | if (x) |
---|
80 | | - | then [s, drop(t, 1)] |
---|
81 | | - | else [(s + v), drop(t, 1)] |
---|
82 | | - | } |
---|
83 | | - | } |
---|
84 | | - | |
---|
85 | | - | |
---|
86 | | - | func y (p,z,A,B) = { |
---|
87 | | - | let C = toBytes("") |
---|
88 | | - | let D = sha256(B) |
---|
89 | | - | let E = DataEntry("r1", 10) |
---|
90 | | - | let F = DataTransaction(nil, C, 0, 0, 0, this, C, C, [C]) |
---|
91 | | - | let G = r(C, D) |
---|
92 | | - | let H = r(G[0], G[1]) |
---|
93 | | - | let I = r(H[0], H[1]) |
---|
94 | | - | let J = r(I[0], I[1]) |
---|
95 | | - | let K = r(J[0], J[1]) |
---|
96 | | - | let L = r(K[0], K[1]) |
---|
97 | | - | let M = r(L[0], L[1]) |
---|
98 | | - | let N = r(M[0], M[1]) |
---|
99 | | - | let O = r(N[0], N[1]) |
---|
100 | | - | O[0] |
---|
101 | | - | } |
---|
102 | | - | |
---|
103 | | - | |
---|
104 | | - | func P (p,Q,R,S) = { |
---|
105 | | - | let T = take(Q.key, c) |
---|
106 | | - | if ((S >= R)) |
---|
107 | | - | then true |
---|
108 | | - | else if (if (if ((p == T)) |
---|
109 | | - | then (size(Q.key) > c) |
---|
110 | | - | else false) |
---|
111 | | - | then !(isDefined(getString(this, Q.key))) |
---|
112 | | - | else false) |
---|
113 | | - | then { |
---|
114 | | - | let U = Q.value |
---|
115 | | - | if ($isInstanceOf(U, "String")) |
---|
116 | | - | then { |
---|
117 | | - | let V = U |
---|
118 | | - | true |
---|
119 | | - | } |
---|
120 | | - | else throw((p + " draw: only String type is accepted for data transactions")) |
---|
121 | | - | } |
---|
122 | | - | else false |
---|
123 | | - | } |
---|
124 | | - | |
---|
125 | | - | |
---|
126 | | - | func W (X) = { |
---|
127 | | - | let t = X.bodyBytes |
---|
128 | | - | let Y = X.data |
---|
129 | | - | let u = h(toInt(t)) |
---|
130 | | - | let Z = drop(t, 1) |
---|
131 | | - | let w = size(Y) |
---|
132 | | - | if ((0 == w)) |
---|
133 | | - | then { |
---|
134 | | - | let aa = DataEntry(toString(u), u) |
---|
135 | | - | DataTransaction([aa], d, 0, 0, 0, this, d, Z, [d]) |
---|
136 | | - | } |
---|
137 | | - | else { |
---|
138 | | - | let x = if (if (if (if (if (if (if (if (if ((w >= 1)) |
---|
139 | | - | then (Y[0].value == u) |
---|
140 | | - | else false) |
---|
141 | | - | then true |
---|
142 | | - | else if ((w >= 2)) |
---|
143 | | - | then (Y[1].value == u) |
---|
144 | | - | else false) |
---|
145 | | - | then true |
---|
146 | | - | else if ((w >= 3)) |
---|
147 | | - | then (Y[2].value == u) |
---|
148 | | - | else false) |
---|
149 | | - | then true |
---|
150 | | - | else if ((w >= 4)) |
---|
151 | | - | then (Y[3].value == u) |
---|
152 | | - | else false) |
---|
153 | | - | then true |
---|
154 | | - | else if ((w >= 5)) |
---|
155 | | - | then (Y[4].value == u) |
---|
156 | | - | else false) |
---|
157 | | - | then true |
---|
158 | | - | else if ((w >= 6)) |
---|
159 | | - | then (Y[5].value == u) |
---|
160 | | - | else false) |
---|
161 | | - | then true |
---|
162 | | - | else if ((w >= 7)) |
---|
163 | | - | then (Y[6].value == u) |
---|
164 | | - | else false) |
---|
165 | | - | then true |
---|
166 | | - | else if ((w >= 8)) |
---|
167 | | - | then (Y[7].value == u) |
---|
168 | | - | else false) |
---|
169 | | - | then true |
---|
170 | | - | else if ((w >= 9)) |
---|
171 | | - | then (Y[8].value == u) |
---|
172 | | - | else false |
---|
173 | | - | if (x) |
---|
174 | | - | then DataTransaction(Y, d, 0, 0, 0, this, d, Z, [d]) |
---|
175 | | - | else { |
---|
176 | | - | let ab = DataEntry(toString(u), u) :: Y |
---|
177 | | - | DataTransaction(ab, d, 0, 0, 0, this, d, Z, [d]) |
---|
178 | | - | } |
---|
179 | | - | } |
---|
180 | | - | } |
---|
181 | | - | |
---|
182 | | - | |
---|
183 | | - | func ac (p,z,A,B) = { |
---|
184 | | - | let D = sha256(B) |
---|
185 | | - | let X = DataTransaction(nil, d, 0, 0, 0, this, d, D, [d]) |
---|
186 | | - | W(W(W(W(W(W(W(W(W(X))))))))) |
---|
187 | | - | } |
---|
188 | | - | |
---|
189 | | - | |
---|
190 | | - | @Callable(ad) |
---|
191 | | - | func random2 (p,B) = { |
---|
192 | | - | let z = 1 |
---|
193 | | - | let A = 100 |
---|
194 | | - | let ae = o(p) |
---|
195 | | - | let k = ae[0] |
---|
196 | | - | let l = ae[1] |
---|
197 | | - | let af = fromBase58String(l) |
---|
198 | | - | if ((k != f)) |
---|
199 | | - | then throw((p + " draw: it must be in READY state to generate random numbers")) |
---|
200 | | - | else if (!(rsaVerify(SHA256, toBytes(p), B, a))) |
---|
201 | | - | then throw("Invalid RSA signature") |
---|
202 | | - | else { |
---|
203 | | - | let X = ac(p, z, A, B) |
---|
204 | | - | let w = size(X.data) |
---|
205 | | - | let ag = if ((w >= 1)) |
---|
206 | | - | then X.data[0].key |
---|
207 | | - | else "" |
---|
208 | | - | let ah = if ((w >= 2)) |
---|
209 | | - | then ((ag + "_") + X.data[0].key) |
---|
210 | | - | else ag |
---|
211 | | - | let ai = if ((w >= 3)) |
---|
212 | | - | then ((ah + "_") + X.data[1].key) |
---|
213 | | - | else ah |
---|
214 | | - | let aj = if ((w >= 4)) |
---|
215 | | - | then ((ai + "_") + X.data[2].key) |
---|
216 | | - | else ai |
---|
217 | | - | let ak = if ((w >= 5)) |
---|
218 | | - | then ((aj + "_") + X.data[3].key) |
---|
219 | | - | else aj |
---|
220 | | - | let al = if ((w >= 6)) |
---|
221 | | - | then ((ak + "_") + X.data[4].key) |
---|
222 | | - | else ak |
---|
223 | | - | let am = if ((w >= 7)) |
---|
224 | | - | then ((al + "_") + X.data[5].key) |
---|
225 | | - | else al |
---|
226 | | - | let an = if ((w >= 8)) |
---|
227 | | - | then ((am + "_") + X.data[6].key) |
---|
228 | | - | else am |
---|
229 | | - | let ao = if ((w >= 9)) |
---|
230 | | - | then ((an + "_") + X.data[7].key) |
---|
231 | | - | else an |
---|
232 | | - | WriteSet([DataEntry(p, j(g, l, ao))]) |
---|
233 | | - | } |
---|
234 | | - | } |
---|
235 | | - | |
---|
236 | | - | |
---|
237 | | - | |
---|
238 | | - | @Callable(ad) |
---|
239 | | - | func initDraw (p) = { |
---|
240 | | - | let ap = (size(fromBase58String(p)) > 0) |
---|
241 | | - | if ((size(p) != c)) |
---|
242 | | - | then throw("Draw Id must be exactly 50 simbols") |
---|
243 | | - | else if (!(ap)) |
---|
244 | | - | then throw("Draw id must be in Base58 format") |
---|
245 | | - | else { |
---|
246 | | - | let l = toBase58String(ad.callerPublicKey) |
---|
247 | | - | let aq = j(e, l, "") |
---|
248 | | - | WriteSet([DataEntry(p, aq)]) |
---|
249 | | - | } |
---|
250 | | - | } |
---|
251 | | - | |
---|
252 | | - | |
---|
253 | | - | |
---|
254 | | - | @Callable(ad) |
---|
255 | | - | func ready (p) = { |
---|
256 | | - | let ae = o(p) |
---|
257 | | - | let k = ae[0] |
---|
258 | | - | let l = ae[1] |
---|
259 | | - | let af = fromBase58String(l) |
---|
260 | | - | if ((k != e)) |
---|
261 | | - | then throw((p + " draw: moving into READY state is allowed only from INIT state")) |
---|
262 | | - | else if ((af != ad.callerPublicKey)) |
---|
263 | | - | then throw((p + "draw: moving into READY state is allowed for organizer only")) |
---|
264 | | - | else { |
---|
265 | | - | let ar = j(f, l, "") |
---|
266 | | - | WriteSet([DataEntry(p, ar)]) |
---|
267 | | - | } |
---|
268 | | - | } |
---|
269 | | - | |
---|
270 | | - | |
---|
271 | | - | |
---|
272 | | - | @Callable(ad) |
---|
273 | | - | func random (p,B) = { |
---|
274 | | - | let z = 1 |
---|
275 | | - | let A = 100 |
---|
276 | | - | let ae = o(p) |
---|
277 | | - | let k = ae[0] |
---|
278 | | - | let l = ae[1] |
---|
279 | | - | let af = fromBase58String(l) |
---|
280 | | - | if ((k != f)) |
---|
281 | | - | then throw((p + " draw: it must be in READY state to generate random numbers")) |
---|
282 | | - | else if (!(rsaVerify(SHA256, toBytes(p), B, a))) |
---|
283 | | - | then throw("Invalid RSA signature") |
---|
284 | | - | else { |
---|
285 | | - | let as = y(p, z, A, B) |
---|
286 | | - | let w = size(as) |
---|
287 | | - | let ah = if ((w >= 1)) |
---|
288 | | - | then toString(toInt(take(drop(as, 0), 8))) |
---|
289 | | - | else "" |
---|
290 | | - | let ai = if ((w >= 2)) |
---|
291 | | - | then ((ah + "_") + toString(toInt(take(drop(as, (1 * 8)), 8)))) |
---|
292 | | - | else ah |
---|
293 | | - | let aj = if ((w >= 3)) |
---|
294 | | - | then ((ai + "_") + toString(toInt(take(drop(as, (2 * 8)), 8)))) |
---|
295 | | - | else ai |
---|
296 | | - | let ak = if ((w >= 4)) |
---|
297 | | - | then ((aj + "_") + toString(toInt(take(drop(as, (3 * 8)), 8)))) |
---|
298 | | - | else aj |
---|
299 | | - | let al = if ((w >= 5)) |
---|
300 | | - | then ((ak + "_") + toString(toInt(take(drop(as, (4 * 8)), 8)))) |
---|
301 | | - | else ak |
---|
302 | | - | let am = if ((w >= 6)) |
---|
303 | | - | then ((al + "_") + toString(toInt(take(drop(as, (5 * 8)), 8)))) |
---|
304 | | - | else al |
---|
305 | | - | let an = if ((w >= 7)) |
---|
306 | | - | then ((am + "_") + toString(toInt(take(drop(as, (6 * 8)), 8)))) |
---|
307 | | - | else am |
---|
308 | | - | let ao = if ((w >= 8)) |
---|
309 | | - | then ((an + "_") + toString(toInt(take(drop(as, (7 * 8)), 8)))) |
---|
310 | | - | else an |
---|
311 | | - | let at = if ((w >= 9)) |
---|
312 | | - | then ((ao + "_") + toString(toInt(take(drop(as, (8 * 8)), 8)))) |
---|
313 | | - | else ao |
---|
314 | | - | WriteSet([DataEntry(p, j(g, l, at))]) |
---|
315 | | - | } |
---|
316 | | - | } |
---|
317 | | - | |
---|
318 | | - | |
---|
319 | | - | @Verifier(au) |
---|
320 | | - | func av () = { |
---|
321 | | - | let U = au |
---|
322 | | - | if ($isInstanceOf(U, "DataTransaction")) |
---|
323 | | - | then { |
---|
324 | | - | let F = U |
---|
325 | | - | let aw = F.data[0] |
---|
326 | | - | let p = take(aw.key, c) |
---|
327 | | - | let ae = o(p) |
---|
328 | | - | let k = ae[0] |
---|
329 | | - | let l = ae[1] |
---|
330 | | - | let af = fromBase58String(l) |
---|
331 | | - | let R = size(F.data) |
---|
332 | | - | if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if ((k == e)) |
---|
333 | | - | then sigVerify(au.bodyBytes, au.proofs[0], af) |
---|
334 | | - | else false) |
---|
335 | | - | then (R > 0) |
---|
336 | | - | else false) |
---|
337 | | - | then (15 >= R) |
---|
338 | | - | else false) |
---|
339 | | - | then P(p, aw, R, 0) |
---|
340 | | - | else false) |
---|
341 | | - | then P(p, F.data[1], R, 1) |
---|
342 | | - | else false) |
---|
343 | | - | then P(p, F.data[2], R, 2) |
---|
344 | | - | else false) |
---|
345 | | - | then P(p, F.data[3], R, 3) |
---|
346 | | - | else false) |
---|
347 | | - | then P(p, F.data[4], R, 4) |
---|
348 | | - | else false) |
---|
349 | | - | then P(p, F.data[5], R, 5) |
---|
350 | | - | else false) |
---|
351 | | - | then P(p, F.data[6], R, 6) |
---|
352 | | - | else false) |
---|
353 | | - | then P(p, F.data[7], R, 7) |
---|
354 | | - | else false) |
---|
355 | | - | then P(p, F.data[8], R, 8) |
---|
356 | | - | else false) |
---|
357 | | - | then P(p, F.data[9], R, 9) |
---|
358 | | - | else false) |
---|
359 | | - | then P(p, F.data[10], R, 10) |
---|
360 | | - | else false) |
---|
361 | | - | then P(p, F.data[11], R, 11) |
---|
362 | | - | else false) |
---|
363 | | - | then P(p, F.data[12], R, 12) |
---|
364 | | - | else false) |
---|
365 | | - | then P(p, F.data[13], R, 13) |
---|
366 | | - | else false) |
---|
367 | | - | then P(p, F.data[14], R, 14) |
---|
368 | | - | else false |
---|
369 | | - | } |
---|
370 | | - | else if ($isInstanceOf(U, "SetScriptTransaction")) |
---|
371 | | - | then { |
---|
372 | | - | let ax = U |
---|
373 | | - | true |
---|
374 | | - | } |
---|
375 | | - | else false |
---|
376 | | - | } |
---|
377 | | - | |
---|
| 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) |
---|