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