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