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 [(s + v), drop(t, 1)] |
---|
44 | | - | } |
---|
45 | | - | |
---|
46 | | - | |
---|
47 | | - | func x (p,y,z,A) = { |
---|
48 | | - | let B = toBytes("") |
---|
49 | | - | let C = sha256(A) |
---|
50 | | - | let D = r(B, C) |
---|
51 | | - | let E = r(D[0], D[1]) |
---|
52 | | - | let F = r(E[0], E[1]) |
---|
53 | | - | let G = r(F[0], F[1]) |
---|
54 | | - | let H = r(G[0], G[1]) |
---|
55 | | - | let I = r(H[0], H[1]) |
---|
56 | | - | let J = r(I[0], I[1]) |
---|
57 | | - | let K = r(J[0], J[1]) |
---|
58 | | - | let L = r(K[0], K[1]) |
---|
59 | | - | let M = r(L[0], L[1]) |
---|
60 | | - | let N = r(M[0], M[1]) |
---|
61 | | - | let O = r(N[0], N[1]) |
---|
62 | | - | let P = r(O[0], O[1]) |
---|
63 | | - | let Q = r(P[0], P[1]) |
---|
64 | | - | let R = r(Q[0], Q[1]) |
---|
65 | | - | let S = r(R[0], R[1]) |
---|
66 | | - | let T = r(S[0], S[1]) |
---|
67 | | - | let U = r(T[0], T[1]) |
---|
68 | | - | let V = r(U[0], U[1]) |
---|
69 | | - | V[0] |
---|
70 | | - | } |
---|
71 | | - | |
---|
72 | | - | |
---|
73 | | - | func W (p,X,Y,Z) = { |
---|
74 | | - | let aa = take(X.key, c) |
---|
75 | | - | if ((Z >= Y)) |
---|
76 | | - | then true |
---|
77 | | - | else if (if (if ((p == aa)) |
---|
78 | | - | then (size(X.key) > c) |
---|
79 | | - | else false) |
---|
80 | | - | then !(isDefined(getString(this, X.key))) |
---|
81 | | - | else false) |
---|
82 | | - | then { |
---|
83 | | - | let ab = X.value |
---|
84 | | - | if ($isInstanceOf(ab, "String")) |
---|
85 | | - | then { |
---|
86 | | - | let ac = ab |
---|
87 | | - | true |
---|
88 | | - | } |
---|
89 | | - | else throw((p + " draw: only String type is accepted for data transactions")) |
---|
90 | | - | } |
---|
91 | | - | else false |
---|
92 | | - | } |
---|
93 | | - | |
---|
94 | | - | |
---|
95 | | - | @Callable(ad) |
---|
96 | | - | func initDraw (p) = { |
---|
97 | | - | let ae = (size(fromBase58String(p)) > 0) |
---|
98 | | - | if ((size(p) != c)) |
---|
99 | | - | then throw("Draw Id must be exactly 50 simbols") |
---|
100 | | - | else if (!(ae)) |
---|
101 | | - | then throw("Draw id must be in Base58 format") |
---|
102 | | - | else { |
---|
103 | | - | let l = toBase58String(ad.callerPublicKey) |
---|
104 | | - | let af = j(e, l, "") |
---|
105 | | - | WriteSet([DataEntry(p, af)]) |
---|
106 | | - | } |
---|
107 | | - | } |
---|
108 | | - | |
---|
109 | | - | |
---|
110 | | - | |
---|
111 | | - | @Callable(ad) |
---|
112 | | - | func ready (p) = { |
---|
113 | | - | let ag = o(p) |
---|
114 | | - | let k = ag[0] |
---|
115 | | - | let l = ag[1] |
---|
116 | | - | let ah = fromBase58String(l) |
---|
117 | | - | if ((k != e)) |
---|
118 | | - | then throw((p + " draw: moving into READY state is allowed only from INIT state")) |
---|
119 | | - | else if ((ah != ad.callerPublicKey)) |
---|
120 | | - | then throw((p + "draw: moving into READY state is allowed for organizer only")) |
---|
121 | | - | else { |
---|
122 | | - | let ai = j(f, l, "") |
---|
123 | | - | WriteSet([DataEntry(p, ai)]) |
---|
124 | | - | } |
---|
125 | | - | } |
---|
126 | | - | |
---|
127 | | - | |
---|
128 | | - | |
---|
129 | | - | @Callable(ad) |
---|
130 | | - | func random (p,A) = { |
---|
131 | | - | let y = 1 |
---|
132 | | - | let z = 100 |
---|
133 | | - | let ag = o(p) |
---|
134 | | - | let k = ag[0] |
---|
135 | | - | let l = ag[1] |
---|
136 | | - | let ah = fromBase58String(l) |
---|
137 | | - | if ((k != f)) |
---|
138 | | - | then throw((p + " draw: it must be in READY state to generate random numbers")) |
---|
139 | | - | else if (!(rsaVerify(SHA256, toBytes(p), A, a))) |
---|
140 | | - | then throw("Invalid RSA signature") |
---|
141 | | - | else { |
---|
142 | | - | let aj = x(p, y, z, A) |
---|
143 | | - | let w = size(aj) |
---|
144 | | - | let ak = if ((w >= 1)) |
---|
145 | | - | then toString(toInt(take(drop(aj, 0), 8))) |
---|
146 | | - | else "" |
---|
147 | | - | let al = if ((w >= 2)) |
---|
148 | | - | then ((ak + "_") + toString(toInt(take(drop(aj, (1 * 8)), 8)))) |
---|
149 | | - | else ak |
---|
150 | | - | let am = if ((w >= 3)) |
---|
151 | | - | then ((al + "_") + toString(toInt(take(drop(aj, (2 * 8)), 8)))) |
---|
152 | | - | else al |
---|
153 | | - | let an = if ((w >= 4)) |
---|
154 | | - | then ((am + "_") + toString(toInt(take(drop(aj, (3 * 8)), 8)))) |
---|
155 | | - | else am |
---|
156 | | - | let ao = if ((w >= 5)) |
---|
157 | | - | then ((an + "_") + toString(toInt(take(drop(aj, (4 * 8)), 8)))) |
---|
158 | | - | else an |
---|
159 | | - | let ap = if ((w >= 6)) |
---|
160 | | - | then ((ao + "_") + toString(toInt(take(drop(aj, (5 * 8)), 8)))) |
---|
161 | | - | else ao |
---|
162 | | - | let aq = if ((w >= 7)) |
---|
163 | | - | then ((ap + "_") + toString(toInt(take(drop(aj, (6 * 8)), 8)))) |
---|
164 | | - | else ap |
---|
165 | | - | let ar = if ((w >= 8)) |
---|
166 | | - | then ((aq + "_") + toString(toInt(take(drop(aj, (7 * 8)), 8)))) |
---|
167 | | - | else aq |
---|
168 | | - | let as = if ((w >= 9)) |
---|
169 | | - | then ((ar + "_") + toString(toInt(take(drop(aj, (8 * 8)), 8)))) |
---|
170 | | - | else ar |
---|
171 | | - | let at = if ((w >= 10)) |
---|
172 | | - | then ((as + "_") + toString(toInt(take(drop(aj, (9 * 8)), 8)))) |
---|
173 | | - | else as |
---|
174 | | - | let au = if ((w >= 10)) |
---|
175 | | - | then ((at + "_") + toString(toInt(take(drop(aj, (10 * 8)), 8)))) |
---|
176 | | - | else at |
---|
177 | | - | let av = if ((w >= 10)) |
---|
178 | | - | then ((au + "_") + toString(toInt(take(drop(aj, (11 * 8)), 8)))) |
---|
179 | | - | else au |
---|
180 | | - | let aw = if ((w >= 10)) |
---|
181 | | - | then ((av + "_") + toString(toInt(take(drop(aj, (12 * 8)), 8)))) |
---|
182 | | - | else av |
---|
183 | | - | let ax = if ((w >= 10)) |
---|
184 | | - | then ((aw + "_") + toString(toInt(take(drop(aj, (13 * 8)), 8)))) |
---|
185 | | - | else aw |
---|
186 | | - | let ay = if ((w >= 10)) |
---|
187 | | - | then ((ax + "_") + toString(toInt(take(drop(aj, (14 * 8)), 8)))) |
---|
188 | | - | else ax |
---|
189 | | - | let az = if ((w >= 10)) |
---|
190 | | - | then ((ay + "_") + toString(toInt(take(drop(aj, (15 * 8)), 8)))) |
---|
191 | | - | else ay |
---|
192 | | - | let aA = if ((w >= 10)) |
---|
193 | | - | then ((az + "_") + toString(toInt(take(drop(aj, (16 * 8)), 8)))) |
---|
194 | | - | else az |
---|
195 | | - | let aB = if ((w >= 10)) |
---|
196 | | - | then ((aA + "_") + toString(toInt(take(drop(aj, (17 * 8)), 8)))) |
---|
197 | | - | else aA |
---|
198 | | - | let aC = if ((w >= 10)) |
---|
199 | | - | then ((aB + "_") + toString(toInt(take(drop(aj, (18 * 8)), 8)))) |
---|
200 | | - | else aB |
---|
201 | | - | WriteSet([DataEntry(p, j(g, l, aC))]) |
---|
202 | | - | } |
---|
203 | | - | } |
---|
204 | | - | |
---|
205 | | - | |
---|
206 | | - | @Verifier(aD) |
---|
207 | | - | func aE () = { |
---|
208 | | - | let ab = aD |
---|
209 | | - | if ($isInstanceOf(ab, "DataTransaction")) |
---|
210 | | - | then { |
---|
211 | | - | let aF = ab |
---|
212 | | - | let aG = aF.data[0] |
---|
213 | | - | let p = take(aG.key, c) |
---|
214 | | - | let ag = o(p) |
---|
215 | | - | let k = ag[0] |
---|
216 | | - | let l = ag[1] |
---|
217 | | - | let ah = fromBase58String(l) |
---|
218 | | - | let Y = size(aF.data) |
---|
219 | | - | if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if ((k == e)) |
---|
220 | | - | then sigVerify(aD.bodyBytes, aD.proofs[0], ah) |
---|
221 | | - | else false) |
---|
222 | | - | then (Y > 0) |
---|
223 | | - | else false) |
---|
224 | | - | then (15 >= Y) |
---|
225 | | - | else false) |
---|
226 | | - | then W(p, aG, Y, 0) |
---|
227 | | - | else false) |
---|
228 | | - | then W(p, aF.data[1], Y, 1) |
---|
229 | | - | else false) |
---|
230 | | - | then W(p, aF.data[2], Y, 2) |
---|
231 | | - | else false) |
---|
232 | | - | then W(p, aF.data[3], Y, 3) |
---|
233 | | - | else false) |
---|
234 | | - | then W(p, aF.data[4], Y, 4) |
---|
235 | | - | else false) |
---|
236 | | - | then W(p, aF.data[5], Y, 5) |
---|
237 | | - | else false) |
---|
238 | | - | then W(p, aF.data[6], Y, 6) |
---|
239 | | - | else false) |
---|
240 | | - | then W(p, aF.data[7], Y, 7) |
---|
241 | | - | else false) |
---|
242 | | - | then W(p, aF.data[8], Y, 8) |
---|
243 | | - | else false) |
---|
244 | | - | then W(p, aF.data[9], Y, 9) |
---|
245 | | - | else false) |
---|
246 | | - | then W(p, aF.data[10], Y, 10) |
---|
247 | | - | else false) |
---|
248 | | - | then W(p, aF.data[11], Y, 11) |
---|
249 | | - | else false) |
---|
250 | | - | then W(p, aF.data[12], Y, 12) |
---|
251 | | - | else false) |
---|
252 | | - | then W(p, aF.data[13], Y, 13) |
---|
253 | | - | else false) |
---|
254 | | - | then W(p, aF.data[14], Y, 14) |
---|
255 | | - | else false |
---|
256 | | - | } |
---|
257 | | - | else if ($isInstanceOf(ab, "SetScriptTransaction")) |
---|
258 | | - | then { |
---|
259 | | - | let aH = ab |
---|
260 | | - | true |
---|
261 | | - | } |
---|
262 | | - | else if ($isInstanceOf(ab, "TransferTransaction")) |
---|
263 | | - | then { |
---|
264 | | - | let aI = ab |
---|
265 | | - | true |
---|
266 | | - | } |
---|
267 | | - | else false |
---|
268 | | - | } |
---|
269 | | - | |
---|
| 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) |
---|