tx · 2pYNtLQBJ1Q4418JC2Kiv9qJDbfWNv5ax2XYQUVVt9Kt

3Mr3UetMa47fYAzYciA4arYqVcfwsq5UA8W:  -1.40000000 Waves

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

{ "type": 13, "id": "2pYNtLQBJ1Q4418JC2Kiv9qJDbfWNv5ax2XYQUVVt9Kt", "fee": 140000000, "feeAssetId": null, "timestamp": 1566291001302, "version": 1, "sender": "3Mr3UetMa47fYAzYciA4arYqVcfwsq5UA8W", "senderPublicKey": "2ejpsso8umRMGaakJnSTHxYkTL25EA29BXNs4W9PphBR", "proofs": [ "3paPquWAZizibXZrZsZ4FAuK7Gb6E7ctCby4NpbLfuMzaH5ksqvnRxaDgZnd1V823Tp6wNJRXoCkCA8ZeSQeWGVZ" ], "script": "base64:AwQAAAAHUHViS2V5MQEAAAAgaQxxSAhSITOlMYdvwKcfK7u/x0yzOg/68EH0ax0QlWUEAAAAB1B1YktleTIBAAAAILb58FcZXTIbjEshMW6ayDB2XcNop87YatlbtNE8j6N0BAAAAARzaWcxAwkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAAB1B1YktleTEAAAAAAAAAAAEAAAAAAAAAAAAEAAAABHNpZzIDCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAQUAAAAHUHViS2V5MgAAAAAAAAAAAQAAAAAAAAAAAAkAAGYAAAACCQAAZAAAAAIFAAAABHNpZzEFAAAABHNpZzIAAAAAAAAAAADO+UOI", "chainId": 84, "height": 639232, "spentComplexity": 0 } View: original | compacted Prev: 2RrH9BadRpSn6sx3kCdFh92NLdmZWTfFgWqFdtXBdh3b Next: 7LCgfprY1Qv3xy8WcpLEBnQkvCooiuFcQAMj9dZRHoHo 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 WAVELET = ((100 * 1000) * 1000)
9-
10-let SESSIONIDFIXSIZE = 50
11-
12-let RANDCYCLEPRICE = ((5 * WAVELET) / 1000)
13-
14-let MAXRANDSPERCYCLE = 14
15-
16-let STATEINIT = "INIT"
17-
18-let DATADONE = "READY"
19-
20-let STATEFINISHED = "FINISHED"
21-
22-let IdxState = 0
23-
24-let IdxOrganizerPub = 1
25-
26-let IdxRandFrom = 2
27-
28-let IdxRandTo = 3
29-
30-let IdxRandsCount = 4
31-
32-let IdxRemainRandsCount = 5
33-
34-let IdxDataDoneTxId = 6
35-
36-let IdxLastOffset = 7
37-
38-let IdxCurrRands = 8
39-
40-func abs (val) = if ((0 > val))
41- then -(val)
42- else val
43-
44-
45-func formatStateDataStr (drawState,organizerPubKey58,randFrom,randTo,randsCount,remainingRands,dataDoneTxId,lastOffset,randOrEmpty) = {
46- let fullStateStr = ((((((((((((((drawState + "_") + organizerPubKey58) + "_") + randFrom) + "_") + randTo) + "_") + randsCount) + "_") + remainingRands) + "_") + dataDoneTxId) + "_") + lastOffset)
47- if ((randOrEmpty == ""))
48- then ((fullStateStr + "_") + "-")
49- else ((fullStateStr + "_") + randOrEmpty)
50- }
51-
52-
53-func extractGameDataList (sessionId) = {
54- let rawDataStr = getStringValue(this, sessionId)
55- split(rawDataStr, "_")
56- }
57-
58-
59-func nextRand (div,min,currRandsStr,remainingRands,remainingHash) = {
60- let nextRandInt = ((abs(toInt(remainingHash)) % div) + min)
61- let nextRandStr = toString(nextRandInt)
62- let duplicate = isDefined(indexOf(currRandsStr, nextRandStr))
63- if (if (!(duplicate))
64- then (remainingRands > 0)
65- else false)
66- then [((currRandsStr + "-") + nextRandStr), "yes"]
67- else [currRandsStr, ""]
68- }
69-
70-
71-func generateRand (sessionId,from,to,rsaSign,currRandsStr,remainingRands,lastOffsetBytes) = {
72- let randHash = rsaSign
73- let div = ((to - from) + 1)
74- let rand1 = nextRand(div, from, currRandsStr, remainingRands, drop(randHash, (lastOffsetBytes + 1)))
75- let rem1 = if ((rand1[1] != ""))
76- then (remainingRands - 1)
77- else remainingRands
78- let rand2 = nextRand(div, from, rand1[0], rem1, drop(randHash, (lastOffsetBytes + 2)))
79- let rem2 = if ((rand2[1] != ""))
80- then (rem1 - 1)
81- else rem1
82- let rand3 = nextRand(div, from, rand2[0], rem2, drop(randHash, (lastOffsetBytes + 3)))
83- let rem3 = if ((rand3[1] != ""))
84- then (rem2 - 1)
85- else rem2
86- let rand4 = nextRand(div, from, rand3[0], rem3, drop(randHash, (lastOffsetBytes + 4)))
87- let rem4 = if ((rand4[1] != ""))
88- then (rem3 - 1)
89- else rem3
90- let rand5 = nextRand(div, from, rand4[0], rem4, drop(randHash, (lastOffsetBytes + 5)))
91- let rem5 = if ((rand5[1] != ""))
92- then (rem4 - 1)
93- else rem4
94- let rand6 = nextRand(div, from, rand5[0], rem5, drop(randHash, (lastOffsetBytes + 6)))
95- let rem6 = if ((rand6[1] != ""))
96- then (rem5 - 1)
97- else rem5
98- let rand7 = nextRand(div, from, rand6[0], rem6, drop(randHash, (lastOffsetBytes + 7)))
99- let rem7 = if ((rand7[1] != ""))
100- then (rem6 - 1)
101- else rem6
102- let rand8 = nextRand(div, from, rand7[0], rem7, drop(randHash, (lastOffsetBytes + 8)))
103- let rem8 = if ((rand8[1] != ""))
104- then (rem7 - 1)
105- else rem7
106- let rand9 = nextRand(div, from, rand8[0], rem8, drop(randHash, (lastOffsetBytes + 9)))
107- let rem9 = if ((rand9[1] != ""))
108- then (rem8 - 1)
109- else rem8
110- let rand10 = nextRand(div, from, rand9[0], rem9, drop(randHash, (lastOffsetBytes + 10)))
111- let rem10 = if ((rand10[1] != ""))
112- then (rem9 - 1)
113- else rem9
114- let rand11 = nextRand(div, from, rand10[0], rem10, drop(randHash, (lastOffsetBytes + 11)))
115- let rem11 = if ((rand11[1] != ""))
116- then (rem10 - 1)
117- else rem10
118- let rand12 = nextRand(div, from, rand11[0], rem11, drop(randHash, (lastOffsetBytes + 12)))
119- let rem12 = if ((rand12[1] != ""))
120- then (rem11 - 1)
121- else rem11
122- let rand13 = nextRand(div, from, rand12[0], rem12, drop(randHash, (lastOffsetBytes + 13)))
123- let rem13 = if ((rand13[1] != ""))
124- then (rem12 - 1)
125- else rem12
126- let rand14 = nextRand(div, from, rand13[0], rem13, drop(randHash, (lastOffsetBytes + 14)))
127- let rem14 = if ((rand14[1] != ""))
128- then (rem13 - 1)
129- else rem13
130-[rand14[0], if ((rem14 == 0))
131- then "0"
132- else toString(rem14), toString((lastOffsetBytes + 14))]
133- }
134-
135-
136-func validateDtxKey (sessionId,data,dataEntriesCount,iteration) = {
137- let sessionIdFromKey = take(data.key, SESSIONIDFIXSIZE)
138- if ((iteration >= dataEntriesCount))
139- then true
140- else if (if (if ((sessionId == sessionIdFromKey))
141- then (size(data.key) > SESSIONIDFIXSIZE)
142- else false)
143- then !(isDefined(getString(this, data.key)))
144- else false)
145- then match data.value {
146- case str: String =>
147- true
148- case _ =>
149- throw((sessionId + " draw: only String type is accepted for data transactions"))
150- }
151- else false
152- }
153-
154-
155-@Callable(i)
156-func initDraw (randFrom,randTo,randsCount) = {
157- let sessionId = toBase58String(i.transactionId)
158- if (if ((0 >= randFrom))
159- then true
160- else (0 >= randTo))
161- then throw("randFrom and randTo must be greater than 0")
162- else if ((randFrom >= randTo))
163- then throw("randFrom must be strict less then randTo")
164- else if ((randsCount > ((randTo - randFrom) + 1)))
165- then throw(((((("Impossible to generate " + toString(randsCount)) + " for provided random range - from ") + toString(randFrom)) + " to ") + toString(randTo)))
166- else {
167- let organizerPubKey58 = toBase58String(i.callerPublicKey)
168- let randsCountStr = toString(randsCount)
169- let initState = formatStateDataStr(STATEINIT, organizerPubKey58, toString(randFrom), toString(randTo), randsCountStr, randsCountStr, "null", "0", "")
170- ScriptResult(WriteSet([DataEntry(sessionId, initState)]), TransferSet([ScriptTransfer(SERVER, 1000, unit)]))
171- }
172- }
173-
174-
175-
176-@Callable(i)
177-func ready (sessionId) = {
178- let drawParamsList = extractGameDataList(sessionId)
179- let drawState = drawParamsList[IdxState]
180- let organizerPubKey58 = drawParamsList[IdxOrganizerPub]
181- let randsCountStr = drawParamsList[IdxRandsCount]
182- let remainRandsCountStr = drawParamsList[IdxRemainRandsCount]
183- let fromStr = drawParamsList[IdxRandFrom]
184- let toStr = drawParamsList[IdxRandTo]
185- let organizerPubKey = fromBase58String(organizerPubKey58)
186- if ((drawState != STATEINIT))
187- then throw((sessionId + " draw: moving into READY state is allowed only from INIT state"))
188- else if ((organizerPubKey != i.callerPublicKey))
189- then throw((sessionId + "draw: moving into READY state is allowed for organizer only"))
190- else {
191- let readyState = formatStateDataStr(DATADONE, organizerPubKey58, fromStr, toStr, randsCountStr, remainRandsCountStr, toBase58String(i.transactionId), "0", "")
192- WriteSet([DataEntry(sessionId, readyState)])
193- }
194- }
195-
196-
197-
198-@Callable(i)
199-func random (sessionId,rsaSign) = {
200- let drawParamsList = extractGameDataList(sessionId)
201- let drawState = drawParamsList[IdxState]
202- let organizerPubKey58 = drawParamsList[IdxOrganizerPub]
203- let randsCountStr = drawParamsList[IdxRandsCount]
204- let remainRandsCount = parseIntValue(drawParamsList[IdxRemainRandsCount])
205- let lastOffsetBytes = parseIntValue(drawParamsList[IdxLastOffset])
206- let currRandsStr = drawParamsList[IdxCurrRands]
207- let fromStr = drawParamsList[IdxRandFrom]
208- let toStr = drawParamsList[IdxRandTo]
209- let dataDoneTxId = drawParamsList[IdxDataDoneTxId]
210- let from = parseIntValue(fromStr)
211- let to = parseIntValue(toStr)
212- let organizerPubKey = fromBase58String(organizerPubKey58)
213- if ((drawState != DATADONE))
214- then throw((sessionId + " draw: it must be in READY state to generate random numbers"))
215- else if (!(rsaVerify(SHA256, (toBytes(sessionId) + toBytes(dataDoneTxId)), rsaSign, RSAPUBLIC)))
216- then throw("Invalid RSA signature")
217- else {
218- let randGenInfo = generateRand(sessionId, from, to, rsaSign, currRandsStr, remainRandsCount, lastOffsetBytes)
219- let newRandsStr = randGenInfo[0]
220- let newRemainRandsCountStr = randGenInfo[1]
221- let newOffsetBytes = randGenInfo[2]
222- let newState = if ((newRemainRandsCountStr == "0"))
223- then STATEFINISHED
224- else DATADONE
225- WriteSet([DataEntry(sessionId, formatStateDataStr(newState, organizerPubKey58, fromStr, toStr, randsCountStr, newRemainRandsCountStr, dataDoneTxId, newOffsetBytes, newRandsStr))])
226- }
227- }
228-
229-
230-@Verifier(tx)
231-func verify () = match tx {
232- case dtx: DataTransaction =>
233- let data0 = dtx.data[0]
234- let sessionId = take(data0.key, SESSIONIDFIXSIZE)
235- let drawParamsList = extractGameDataList(sessionId)
236- let drawState = drawParamsList[0]
237- let organizerPubKey58 = drawParamsList[1]
238- let organizerPubKey = fromBase58String(organizerPubKey58)
239- let dataEntriesCount = size(dtx.data)
240- if (if (if (if (if (if (if (if (if ((drawState == STATEINIT))
241- then sigVerify(tx.bodyBytes, tx.proofs[0], organizerPubKey)
242- else false)
243- then (dataEntriesCount > 0)
244- else false)
245- then (5 >= dataEntriesCount)
246- else false)
247- then validateDtxKey(sessionId, data0, dataEntriesCount, 0)
248- else false)
249- then validateDtxKey(sessionId, dtx.data[1], dataEntriesCount, 1)
250- else false)
251- then validateDtxKey(sessionId, dtx.data[2], dataEntriesCount, 2)
252- else false)
253- then validateDtxKey(sessionId, dtx.data[3], dataEntriesCount, 3)
254- else false)
255- then validateDtxKey(sessionId, dtx.data[4], dataEntriesCount, 4)
256- else false)
257- then validateDtxKey(sessionId, dtx.data[5], dataEntriesCount, 5)
258- else false
259- case sstx: SetScriptTransaction =>
260- true
261- case ttx: TransferTransaction =>
262- true
263- case _ =>
264- false
265-}
266-
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/169f3d6 
44.05 ms