tx · 9a4Kh1koGivcFfGVgPQV7JySeSZVaMYY4LD7tAP54Rs1

3Mv11ueV92McwDfCDMXiwhEpiPyRNssXs3P:  -1.40000000 Waves

2019.08.20 11:49 [639232] smart account 3Mv11ueV92McwDfCDMXiwhEpiPyRNssXs3P > SELF 0.00000000 Waves

{ "type": 13, "id": "9a4Kh1koGivcFfGVgPQV7JySeSZVaMYY4LD7tAP54Rs1", "fee": 140000000, "feeAssetId": null, "timestamp": 1566291009421, "version": 1, "sender": "3Mv11ueV92McwDfCDMXiwhEpiPyRNssXs3P", "senderPublicKey": "B6QaSFkjGsEG6ong24CgrKaYkWPknjUM9vqRLoUGFLeC", "proofs": [ "5DDbzemFsNjtpBaBUN9cjAegkUwwp4D75iBAVcEyekB9fr8bqRLUrXVHW4yj295qi6PEBzdMuGuPmMdVLYpTBbby" ], "script": "base64:AwQAAAAHUHViS2V5MQEAAAAgaQxxSAhSITOlMYdvwKcfK7u/x0yzOg/68EH0ax0QlWUEAAAAB1B1YktleTIBAAAAILb58FcZXTIbjEshMW6ayDB2XcNop87YatlbtNE8j6N0BAAAAARzaWcxAwkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAAB1B1YktleTEAAAAAAAAAAAEAAAAAAAAAAAAEAAAABHNpZzIDCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAQUAAAAHUHViS2V5MgAAAAAAAAAAAQAAAAAAAAAAAAkAAGYAAAACCQAAZAAAAAIFAAAABHNpZzEFAAAABHNpZzIAAAAAAAAAAADO+UOI", "chainId": 84, "height": 639232, "spentComplexity": 0 } View: original | compacted Prev: AockQUMqYTdRdPSqTjwUp7iFZ1KQf6r3cSBrLxLsWMRN Next: 5EGfNYsmwCcWjf6mdyLMummETHc2eVXVZxyfxmxNNQa4 Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
2-{-# SCRIPT_TYPE ACCOUNT #-}
3-{-# CONTENT_TYPE DAPP #-}
4-let RSAPUBLIC = fromBase64String("base64:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqlAiANSmBpDHYKP9sKgeN/l1bAb28g/tGlgDkwT5FiMN4X3pwdvdxE7mvSR8/41dU9rx4jG+6tZpb1ULVDPs431tR2IRaTXw5Cj+Ac2vhL+5JamCerGD1UW+bh/EGQtxo8W3YLDrofXB5QHJx4Pkz2Kgf+oS/C8hHuB/U4krO76U0507GTjZPP9kRQ0uLSMeqQXt8wXS+nMp5wajqxPpDLMaSREgsKwv/AEkP4dzpTYbikLBYl4qtdJsD84HLFSkiwd3BhcOrPjoIYmLxQuBD5TIMKTKD3sdZgaY9rsyqx3A00innyxD6zp3b4gFpUOX8JxKZdEC2myEqleNgg7GzwIDAQAB")
5-
6-let SERVER = addressFromStringValue("3NCiG28LmWyTigWG13E5QnvdHBsZFYXSS2j")
7-
8-let SESSIONIDFIXSIZE = 50
9-
10-let EMPTYVECT = toBytes("")
11-
12-let STATEINIT = "INIT"
13-
14-let STATEREADY = "READY"
15-
16-let STATEFINISHED = "FINISHED"
17-
18-func abs (val) = if ((0 > val))
19- then -(val)
20- else val
21-
22-
23-func formatStateDataStr (drawState,organizerPubKey58,randOrEmpty) = {
24- let fullStateStr = ((drawState + "_") + organizerPubKey58)
25- if ((randOrEmpty == ""))
26- then fullStateStr
27- else ((fullStateStr + "_") + randOrEmpty)
28- }
29-
30-
31-func extractGameDataList (sessionId) = {
32- let rawDataStr = getStringValue(this, sessionId)
33- split(rawDataStr, "_")
34- }
35-
36-
37-func nextRand (currRandsVect,remainingHash) = {
38- let nextRandInt = abs(toInt(remainingHash))
39- let nextRandVect = toBytes(nextRandInt)
40- let s = (size(currRandsVect) / 8)
41- if ((0 == s))
42- then [nextRandVect, drop(remainingHash, 1)]
43- else {
44- let duplicate = if (if (if (if (if (if (if (if (if ((s >= 1))
45- then (take(currRandsVect, 8) == nextRandVect)
46- else false)
47- then true
48- else if ((s >= 2))
49- then (take(drop(currRandsVect, (1 * 8)), 8) == nextRandVect)
50- else false)
51- then true
52- else if ((s >= 3))
53- then (take(drop(currRandsVect, (2 * 8)), 8) == nextRandVect)
54- else false)
55- then true
56- else if ((s >= 4))
57- then (take(drop(currRandsVect, (3 * 8)), 8) == nextRandVect)
58- else false)
59- then true
60- else if ((s >= 5))
61- then (take(drop(currRandsVect, (4 * 8)), 8) == nextRandVect)
62- else false)
63- then true
64- else if ((s >= 6))
65- then (take(drop(currRandsVect, (5 * 8)), 8) == nextRandVect)
66- else false)
67- then true
68- else if ((s >= 7))
69- then (take(drop(currRandsVect, (6 * 8)), 8) == nextRandVect)
70- else false)
71- then true
72- else if ((s >= 8))
73- then (take(drop(currRandsVect, (7 * 8)), 8) == nextRandVect)
74- else false)
75- then true
76- else if ((s >= 9))
77- then (take(drop(currRandsVect, (8 * 8)), 8) == nextRandVect)
78- else false
79- if (duplicate)
80- then [currRandsVect, drop(remainingHash, 1)]
81- else [(currRandsVect + nextRandVect), drop(remainingHash, 1)]
82- }
83- }
84-
85-
86-func generateRandsVector (sessionId,from,to,rsaSign) = {
87- let emptyVec = toBytes("")
88- let randHash = sha256(rsaSign)
89- let de = DataEntry("r1", 10)
90- let dtx = DataTransaction(nil, emptyVec, 0, 0, 0, this, emptyVec, emptyVec, [emptyVec])
91- let nextInfo1 = nextRand(emptyVec, randHash)
92- let nextInfo2 = nextRand(nextInfo1[0], nextInfo1[1])
93- let nextInfo3 = nextRand(nextInfo2[0], nextInfo2[1])
94- let nextInfo4 = nextRand(nextInfo3[0], nextInfo3[1])
95- let nextInfo5 = nextRand(nextInfo4[0], nextInfo4[1])
96- let nextInfo6 = nextRand(nextInfo5[0], nextInfo5[1])
97- let nextInfo7 = nextRand(nextInfo6[0], nextInfo6[1])
98- let nextInfo8 = nextRand(nextInfo7[0], nextInfo7[1])
99- let nextInfo9 = nextRand(nextInfo8[0], nextInfo8[1])
100-nextInfo9[0]
101- }
102-
103-
104-func validateDtxKey (sessionId,data,dataEntriesCount,iteration) = {
105- let sessionIdFromKey = take(data.key, SESSIONIDFIXSIZE)
106- if ((iteration >= dataEntriesCount))
107- then true
108- else if (if (if ((sessionId == sessionIdFromKey))
109- then (size(data.key) > SESSIONIDFIXSIZE)
110- else false)
111- then !(isDefined(getString(this, data.key)))
112- else false)
113- then match data.value {
114- case str: String =>
115- true
116- case _ =>
117- throw((sessionId + " draw: only String type is accepted for data transactions"))
118- }
119- else false
120- }
121-
122-
123-func nextRand2 (randCtx) = {
124- let remainingHash = randCtx.bodyBytes
125- let currRandsEntries = randCtx.data
126- let nextRandInt = abs(toInt(remainingHash))
127- let nextHash = drop(remainingHash, 1)
128- let s = size(currRandsEntries)
129- if ((0 == s))
130- then {
131- let r1Entry = DataEntry(toString(nextRandInt), nextRandInt)
132- DataTransaction([r1Entry], EMPTYVECT, 0, 0, 0, this, EMPTYVECT, nextHash, [EMPTYVECT])
133- }
134- else {
135- let duplicate = if (if (if (if (if (if (if (if (if ((s >= 1))
136- then (currRandsEntries[0].value == nextRandInt)
137- else false)
138- then true
139- else if ((s >= 2))
140- then (currRandsEntries[1].value == nextRandInt)
141- else false)
142- then true
143- else if ((s >= 3))
144- then (currRandsEntries[2].value == nextRandInt)
145- else false)
146- then true
147- else if ((s >= 4))
148- then (currRandsEntries[3].value == nextRandInt)
149- else false)
150- then true
151- else if ((s >= 5))
152- then (currRandsEntries[4].value == nextRandInt)
153- else false)
154- then true
155- else if ((s >= 6))
156- then (currRandsEntries[5].value == nextRandInt)
157- else false)
158- then true
159- else if ((s >= 7))
160- then (currRandsEntries[6].value == nextRandInt)
161- else false)
162- then true
163- else if ((s >= 8))
164- then (currRandsEntries[7].value == nextRandInt)
165- else false)
166- then true
167- else if ((s >= 9))
168- then (currRandsEntries[8].value == nextRandInt)
169- else false
170- if (duplicate)
171- then DataTransaction(currRandsEntries, EMPTYVECT, 0, 0, 0, this, EMPTYVECT, nextHash, [EMPTYVECT])
172- else {
173- let newRandsEntries = DataEntry(toString(nextRandInt), nextRandInt) :: currRandsEntries
174- DataTransaction(newRandsEntries, EMPTYVECT, 0, 0, 0, this, EMPTYVECT, nextHash, [EMPTYVECT])
175- }
176- }
177- }
178-
179-
180-func generateRandsVector2 (sessionId,from,to,rsaSign) = {
181- let randHash = sha256(rsaSign)
182- let randCtx = DataTransaction(nil, EMPTYVECT, 0, 0, 0, this, EMPTYVECT, randHash, [EMPTYVECT])
183- nextRand2(nextRand2(nextRand2(nextRand2(nextRand2(nextRand2(nextRand2(nextRand2(nextRand2(randCtx)))))))))
184- }
185-
186-
187-@Callable(i)
188-func random2 (sessionId,rsaSign) = {
189- let from = 1
190- let to = 100
191- let drawParamsList = extractGameDataList(sessionId)
192- let drawState = drawParamsList[0]
193- let organizerPubKey58 = drawParamsList[1]
194- let organizerPubKey = fromBase58String(organizerPubKey58)
195- if ((drawState != STATEREADY))
196- then throw((sessionId + " draw: it must be in READY state to generate random numbers"))
197- else if (!(rsaVerify(SHA256, toBytes(sessionId), rsaSign, RSAPUBLIC)))
198- then throw("Invalid RSA signature")
199- else {
200- let randCtx = generateRandsVector2(sessionId, from, to, rsaSign)
201- let s = size(randCtx.data)
202- let rand0 = if ((s >= 1))
203- then randCtx.data[0].key
204- else ""
205- let rand1 = if ((s >= 2))
206- then ((rand0 + "_") + randCtx.data[0].key)
207- else rand0
208- let rand2 = if ((s >= 3))
209- then ((rand1 + "_") + randCtx.data[1].key)
210- else rand1
211- let rand3 = if ((s >= 4))
212- then ((rand2 + "_") + randCtx.data[2].key)
213- else rand2
214- let rand4 = if ((s >= 5))
215- then ((rand3 + "_") + randCtx.data[3].key)
216- else rand3
217- let rand5 = if ((s >= 6))
218- then ((rand4 + "_") + randCtx.data[4].key)
219- else rand4
220- let rand6 = if ((s >= 7))
221- then ((rand5 + "_") + randCtx.data[5].key)
222- else rand5
223- let rand7 = if ((s >= 8))
224- then ((rand6 + "_") + randCtx.data[6].key)
225- else rand6
226- let rand8 = if ((s >= 9))
227- then ((rand7 + "_") + randCtx.data[7].key)
228- else rand7
229- WriteSet([DataEntry(sessionId, formatStateDataStr(STATEFINISHED, organizerPubKey58, rand8))])
230- }
231- }
232-
233-
234-
235-@Callable(i)
236-func initDraw (sessionId) = {
237- let base58Valid = (size(fromBase58String(sessionId)) > 0)
238- if ((size(sessionId) != SESSIONIDFIXSIZE))
239- then throw("Draw Id must be exactly 50 simbols")
240- else if (!(base58Valid))
241- then throw("Draw id must be in Base58 format")
242- else {
243- let organizerPubKey58 = toBase58String(i.callerPublicKey)
244- let initState = formatStateDataStr(STATEINIT, organizerPubKey58, "")
245- WriteSet([DataEntry(sessionId, initState)])
246- }
247- }
248-
249-
250-
251-@Callable(i)
252-func ready (sessionId) = {
253- let drawParamsList = extractGameDataList(sessionId)
254- let drawState = drawParamsList[0]
255- let organizerPubKey58 = drawParamsList[1]
256- let organizerPubKey = fromBase58String(organizerPubKey58)
257- if ((drawState != STATEINIT))
258- then throw((sessionId + " draw: moving into READY state is allowed only from INIT state"))
259- else if ((organizerPubKey != i.callerPublicKey))
260- then throw((sessionId + "draw: moving into READY state is allowed for organizer only"))
261- else {
262- let readyState = formatStateDataStr(STATEREADY, organizerPubKey58, "")
263- WriteSet([DataEntry(sessionId, readyState)])
264- }
265- }
266-
267-
268-
269-@Callable(i)
270-func random (sessionId,rsaSign) = {
271- let from = 1
272- let to = 100
273- let drawParamsList = extractGameDataList(sessionId)
274- let drawState = drawParamsList[0]
275- let organizerPubKey58 = drawParamsList[1]
276- let organizerPubKey = fromBase58String(organizerPubKey58)
277- if ((drawState != STATEREADY))
278- then throw((sessionId + " draw: it must be in READY state to generate random numbers"))
279- else if (!(rsaVerify(SHA256, toBytes(sessionId), rsaSign, RSAPUBLIC)))
280- then throw("Invalid RSA signature")
281- else {
282- let currVect = generateRandsVector(sessionId, from, to, rsaSign)
283- let s = size(currVect)
284- let rand1 = if ((s >= 1))
285- then toString(toInt(take(drop(currVect, 0), 8)))
286- else ""
287- let rand2 = if ((s >= 2))
288- then ((rand1 + "_") + toString(toInt(take(drop(currVect, (1 * 8)), 8))))
289- else rand1
290- let rand3 = if ((s >= 3))
291- then ((rand2 + "_") + toString(toInt(take(drop(currVect, (2 * 8)), 8))))
292- else rand2
293- let rand4 = if ((s >= 4))
294- then ((rand3 + "_") + toString(toInt(take(drop(currVect, (3 * 8)), 8))))
295- else rand3
296- let rand5 = if ((s >= 5))
297- then ((rand4 + "_") + toString(toInt(take(drop(currVect, (4 * 8)), 8))))
298- else rand4
299- let rand6 = if ((s >= 6))
300- then ((rand5 + "_") + toString(toInt(take(drop(currVect, (5 * 8)), 8))))
301- else rand5
302- let rand7 = if ((s >= 7))
303- then ((rand6 + "_") + toString(toInt(take(drop(currVect, (6 * 8)), 8))))
304- else rand6
305- let rand8 = if ((s >= 8))
306- then ((rand7 + "_") + toString(toInt(take(drop(currVect, (7 * 8)), 8))))
307- else rand7
308- let rand9 = if ((s >= 9))
309- then ((rand8 + "_") + toString(toInt(take(drop(currVect, (8 * 8)), 8))))
310- else rand8
311- WriteSet([DataEntry(sessionId, formatStateDataStr(STATEFINISHED, organizerPubKey58, rand9))])
312- }
313- }
314-
315-
316-@Verifier(tx)
317-func verify () = match tx {
318- case dtx: DataTransaction =>
319- let data0 = dtx.data[0]
320- let sessionId = take(data0.key, SESSIONIDFIXSIZE)
321- let drawParamsList = extractGameDataList(sessionId)
322- let drawState = drawParamsList[0]
323- let organizerPubKey58 = drawParamsList[1]
324- let organizerPubKey = fromBase58String(organizerPubKey58)
325- let dataEntriesCount = size(dtx.data)
326- if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if ((drawState == STATEINIT))
327- then sigVerify(tx.bodyBytes, tx.proofs[0], organizerPubKey)
328- else false)
329- then (dataEntriesCount > 0)
330- else false)
331- then (15 >= dataEntriesCount)
332- else false)
333- then validateDtxKey(sessionId, data0, dataEntriesCount, 0)
334- else false)
335- then validateDtxKey(sessionId, dtx.data[1], dataEntriesCount, 1)
336- else false)
337- then validateDtxKey(sessionId, dtx.data[2], dataEntriesCount, 2)
338- else false)
339- then validateDtxKey(sessionId, dtx.data[3], dataEntriesCount, 3)
340- else false)
341- then validateDtxKey(sessionId, dtx.data[4], dataEntriesCount, 4)
342- else false)
343- then validateDtxKey(sessionId, dtx.data[5], dataEntriesCount, 5)
344- else false)
345- then validateDtxKey(sessionId, dtx.data[6], dataEntriesCount, 6)
346- else false)
347- then validateDtxKey(sessionId, dtx.data[7], dataEntriesCount, 7)
348- else false)
349- then validateDtxKey(sessionId, dtx.data[8], dataEntriesCount, 8)
350- else false)
351- then validateDtxKey(sessionId, dtx.data[9], dataEntriesCount, 9)
352- else false)
353- then validateDtxKey(sessionId, dtx.data[10], dataEntriesCount, 10)
354- else false)
355- then validateDtxKey(sessionId, dtx.data[11], dataEntriesCount, 11)
356- else false)
357- then validateDtxKey(sessionId, dtx.data[12], dataEntriesCount, 12)
358- else false)
359- then validateDtxKey(sessionId, dtx.data[13], dataEntriesCount, 13)
360- else false)
361- then validateDtxKey(sessionId, dtx.data[14], dataEntriesCount, 14)
362- else false
363- case sstx: SetScriptTransaction =>
364- true
365- case _ =>
366- false
367-}
368-
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)

github/deemru/w8io/873ac7e 
48.24 ms