elective-stereophonic
elective-stereophonic
Lottery
Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest Nxt Client: Nxt 1.11.15

Pages: 1 [2] 3 4  All

Author Topic: Lottery  (Read 16301 times)

Brangdon

  • Hero Member
  • *****
  • Karma: +229/-25
  • Offline Offline
  • Posts: 1389
  • Quality is addictive.
    • View Profile
Re: Lottery
« Reply #20 on: August 13, 2016, 08:47:36 am »

Can anyone shed some light on how nxt can implement this better than on ethereum?
To be trust-free I think it would need to be in the core. Once accepted into the core, it would need to be part of Nxt and Nxt 2.0 forever. I don't know how the devs would feel about it; I'm guessing if someone else did the work and it was reasonably general they'd be OK with it, but you'd have to check with them first. Frankly, this area is where Ethereum is strong and Nxt weak.
Logged

Brangdon

  • Hero Member
  • *****
  • Karma: +229/-25
  • Offline Offline
  • Posts: 1389
  • Quality is addictive.
    • View Profile
Re: Lottery
« Reply #21 on: August 13, 2016, 09:22:14 am »

I believe there is an issue with what you propose. The numbers from an external source will not always match one of the sequences in submitted tickets. In fact, they will almost never match because of very few participants in Nxt. The funds will have to be collected and wait for a long time until someone can guess the numbers. It's very unlikely it will ever happen in the Nxt lottery with few players. The lottery needs hundreds of thousands players to guess the numbers and that's what the script does - it simulates hundreds of thousands of players by generating thousands of combinations. I can show the source code but since I run it there is no point because I can show you one source but run a modified one.
Presumably your script uses a pseudo-random number generator to produce all those combinations. If you used the publicly known external source as the initial seed, other people could verify that the winners were the first winners if you start iterating from that seed. You'd publish your script, and other people could run the same script on the same input and see that they got the same result. If you ran a modified script, people could detect it. The lottery would be provably fair.

This still isn't trust free, because nothing would stop you simply absconding with the funds. You could use account control, but mostly that just increases the number of people who would need to collude to steal. It also increases transaction fee overheads. Still, being able to verify that no-one was stealing from the lottery secretly is huge, and if you did abscond with the funds, at least everyone would know that was what had happened. So if the amounts of money are small I doubt that trust would be an issue, and you could add account control as the amounts grew. I think this approach might be better than putting it in the core.

I'd consider getting the seed from the block-chain, rather than an external source like the NY numbers. That's if you can find some way to make it resistant to being manipulated by forgers, which now that I think about it may be a hard problem.
Logged

lurker10

  • Hero Member
  • *****
  • Karma: +168/-33
  • Offline Offline
  • Posts: 1334
    • View Profile
Re: Lottery
« Reply #22 on: August 13, 2016, 09:51:59 am »

I believe there is an issue with what you propose. The numbers from an external source will not always match one of the sequences in submitted tickets. In fact, they will almost never match because of very few participants in Nxt. The funds will have to be collected and wait for a long time until someone can guess the numbers. It's very unlikely it will ever happen in the Nxt lottery with few players. The lottery needs hundreds of thousands players to guess the numbers and that's what the script does - it simulates hundreds of thousands of players by generating thousands of combinations. I can show the source code but since I run it there is no point because I can show you one source but run a modified one.
Presumably your script uses a pseudo-random number generator to produce all those combinations. If you used the publicly known external source as the initial seed, other people could verify that the winners were the first winners if you start iterating from that seed. You'd publish your script, and other people could run the same script on the same input and see that they got the same result. If you ran a modified script, people could detect it. The lottery would be provably fair.

This still isn't trust free, because nothing would stop you simply absconding with the funds. You could use account control, but mostly that just increases the number of people who would need to collude to steal. It also increases transaction fee overheads. Still, being able to verify that no-one was stealing from the lottery secretly is huge, and if you did abscond with the funds, at least everyone would know that was what had happened. So if the amounts of money are small I doubt that trust would be an issue, and you could add account control as the amounts grew. I think this approach might be better than putting it in the core.

I'd consider getting the seed from the block-chain, rather than an external source like the NY numbers. That's if you can find some way to make it resistant to being manipulated by forgers, which now that I think about it may be a hard problem.

Thank you for this suggestion. I'll look into modifying this to use a seed from the blockchain if it's possible. If NXT block ids are random I could use one of those as a seed, take the id of the block 10 blocks in the past before the script runs to avoid forks. Are block ids safe from gaming them?
At this time I just use www.php.net/random_int

There is no objection about setting up Account Control for this and sending phased transactions. Somebody will need to approve them. It should be easy to implement and find the right co-manager from the community if this project grows to anything significant :)

PS:
I'll modify the script by tomorrow to use the last 5 digits of the block id (current block height at the time of script run - 10 blocks) as a seed. This will generate provably random sequences for anyone to verify. If the block id can be gamed by forgers, this risk is smaller than the possibility of me modifying the source code.

PS2:
Done and uploaded to Nxt Data Cloud. Instructions in the script will let anyone verify that results are not rigged by me.
« Last Edit: August 13, 2016, 11:47:54 am by lurker10 »
Logged
Run a node - win a prize! "Lucky node" project jar: NXT-8F28-EDVE-LPPX-HY4E7

jnsptrsn

  • Jr. Member
  • **
  • Karma: +6/-9
  • Offline Offline
  • Posts: 70
    • View Profile
Re: Lottery
« Reply #23 on: August 13, 2016, 11:43:30 am »

I think you should use the same method as NXTBubble/ToTheMoon and other projects like that: a hash-chain that is used in reverse to get a pseudo-random seed for each game. The seed for the first hash in the chain could be a NXT or Bitcoin block hash at some height in the future from now.

Much of the NxtBubble info is removed from this forum, but here is a start: https://nxtforum.org/nxtbubble-com/nxtbubble-verifier/

Logged

lurker10

  • Hero Member
  • *****
  • Karma: +168/-33
  • Offline Offline
  • Posts: 1334
    • View Profile
Re: Lottery
« Reply #24 on: August 13, 2016, 11:49:27 am »

I think you should use the same method as NXTBubble/ToTheMoon and other projects like that: a hash-chain that is used in reverse to get a pseudo-random seed for each game. The seed for the first hash in the chain could be a NXT or Bitcoin block hash at some height in the future from now.

Much of the NxtBubble info is removed from this forum, but here is a start: https://nxtforum.org/nxtbubble-com/nxtbubble-verifier/

Sorry, I misunderstood you first. Using a block from the future could possibly be the next project. For this lottery the logic is simple - get a winner and instantly send away rewards.
« Last Edit: August 13, 2016, 12:02:40 pm by lurker10 »
Logged
Run a node - win a prize! "Lucky node" project jar: NXT-8F28-EDVE-LPPX-HY4E7

Brangdon

  • Hero Member
  • *****
  • Karma: +229/-25
  • Offline Offline
  • Posts: 1389
  • Quality is addictive.
    • View Profile
Re: Lottery
« Reply #25 on: August 13, 2016, 12:42:38 pm »

I think you should use the same method as NXTBubble/ToTheMoon and other projects like that: a hash-chain that is used in reverse to get a pseudo-random seed for each game.
That sounds like the person who runs the lottery could know the result of each lottery in advance. They could play under a pseudonym and always win, and nobody would know they were doing it.
Logged

Brangdon

  • Hero Member
  • *****
  • Karma: +229/-25
  • Offline Offline
  • Posts: 1389
  • Quality is addictive.
    • View Profile
Re: Lottery
« Reply #26 on: August 13, 2016, 12:56:53 pm »

Thank you for this suggestion. I'll look into modifying this to use a seed from the blockchain if it's possible. If NXT block ids are random I could use one of those as a seed, take the id of the block 10 blocks in the past before the script runs to avoid forks. Are block ids safe from gaming them?
The block id includes a hash of the transactions in a block. That can be gamed by the person who forges the block, by picking which transactions the block should include. I had been thinking instead of the hash used in the forging algorithm, which doesn't depend on the block contents but does depend on which accounts forge which blocks. However, that might be too easy to predict, and can still be gamed to some extent by forgers deciding not to forge when it is their turn.

Using something like state lottery numbers would probably be safer. Some source where it's possible to get historical values so checks can be made long after the fact. It doesn't have to be in lottery format - any string can be hashed to get a seed for a PRNG.
Logged

lurker10

  • Hero Member
  • *****
  • Karma: +168/-33
  • Offline Offline
  • Posts: 1334
    • View Profile
Re: Lottery
« Reply #27 on: August 13, 2016, 01:26:03 pm »

Thank you for this suggestion. I'll look into modifying this to use a seed from the blockchain if it's possible. If NXT block ids are random I could use one of those as a seed, take the id of the block 10 blocks in the past before the script runs to avoid forks. Are block ids safe from gaming them?
The block id includes a hash of the transactions in a block. That can be gamed by the person who forges the block, by picking which transactions the block should include. I had been thinking instead of the hash used in the forging algorithm, which doesn't depend on the block contents but does depend on which accounts forge which blocks. However, that might be too easy to predict, and can still be gamed to some extent by forgers deciding not to forge when it is their turn.

Using something like state lottery numbers would probably be safer. Some source where it's possible to get historical values so checks can be made long after the fact. It doesn't have to be in lottery format - any string can be hashed to get a seed for a PRNG.

Anything historical as a source of seed, if it is known by players in advance, can in theory be gamed, no?
For now the lottery should be ok with small prizes, it's not trivial to game the blockid 10 minutes before the lottery, so v0.1 is safe and should be safe for quite a while to allow time for more safety measures.
Logged
Run a node - win a prize! "Lucky node" project jar: NXT-8F28-EDVE-LPPX-HY4E7

martismartis

  • Hero Member
  • *****
  • Karma: +73/-10
  • Offline Offline
  • Posts: 1237
    • View Profile
Re: Lottery
« Reply #28 on: August 13, 2016, 01:34:21 pm »

What about of hashing the block ID with some seed from future and get last digits from this hash?
Logged

lurker10

  • Hero Member
  • *****
  • Karma: +168/-33
  • Offline Offline
  • Posts: 1334
    • View Profile
Re: Lottery
« Reply #29 on: August 13, 2016, 02:51:49 pm »

What about of hashing the block ID with some seed from future and get last digits from this hash?

How do you get the seed from future? The lottery needs to have a seed and pay out prizes instantly. Only some seed from the past is available. Using the blockid from 10 blocks ago as a seed is reasonably secure unless we talk millions in prizes as an incentive to game it. The blockid can be lumped together with something else from the past blockchain that is relatively unpredictable for double protection.

The v0.1 script results verification is half-baked, will only work for the current lottery before payouts, going to make and upload v0.2 to verify past lotteries by date. This doesn't affect the lottery itself, just the verification routine, so wait for v0.2 and use it to verify results.
Logged
Run a node - win a prize! "Lucky node" project jar: NXT-8F28-EDVE-LPPX-HY4E7

box1413

  • Hero Member
  • *****
  • Karma: +101/-4
  • Offline Offline
  • Posts: 687
    • View Profile
Re: Lottery
« Reply #30 on: August 13, 2016, 04:18:06 pm »

why not just time it according to the official NY state lottery and just have a drawing once a week in order to build up the pot. initial investors can start the pot of funds and in return they would just get a % of each ticket purchased. I think using some form of data to generate random numbers just makes things more complex.

I think a more important issue is how do you manage funds and distribute funds to winners without the risk of someone running away with the pot.
« Last Edit: August 13, 2016, 04:21:29 pm by box1413 »
Logged

lurker10

  • Hero Member
  • *****
  • Karma: +168/-33
  • Offline Offline
  • Posts: 1334
    • View Profile
Re: Lottery
« Reply #31 on: August 13, 2016, 04:55:18 pm »

why not just time it according to the official NY state lottery and just have a drawing once a week in order to build up the pot. initial investors can start the pot of funds and in return they would just get a % of each ticket purchased. I think using some form of data to generate random numbers just makes things more complex.

I think a more important issue is how do you manage funds and distribute funds to winners without the risk of someone running away with the pot.

The NY state lottery numbers can be used as a seed to generate random numbers.
But the NY state lottery numbers cannot be practically used as the actual winning numbers because of low participation rates in the Nxt lottery which would force us to wait for our winner for years.
Which of the two options did you mean?

The script now is provably not rigged by me, and extremely hard if not impossible to game by forgers. v0.2 with results verification is almost complete and will be uploaded to Data Cloud.
I'll consider using NY state lottery numbers or some such external data source as a seed to random numbers generation, but in my view using a blockId from 10 blocks in the past is the N(e)xt way of doing the job :)

Not especially keen on collecting a big jackpot spanning weeks for this project either. I'll implement Account control in the future if we have a lot of players.
Logged
Run a node - win a prize! "Lucky node" project jar: NXT-8F28-EDVE-LPPX-HY4E7

box1413

  • Hero Member
  • *****
  • Karma: +101/-4
  • Offline Offline
  • Posts: 687
    • View Profile
Re: Lottery
« Reply #32 on: August 13, 2016, 05:38:51 pm »

nxt has a small audience, which is fine if your just testing out the platform. But it would have to be denominated in BTC in order to attract a wider audience. In effect SuperBTC would have to come into play.
Logged

Brangdon

  • Hero Member
  • *****
  • Karma: +229/-25
  • Offline Offline
  • Posts: 1389
  • Quality is addictive.
    • View Profile
Re: Lottery
« Reply #33 on: August 14, 2016, 01:20:06 pm »

Using something like state lottery numbers would probably be safer. Some source where it's possible to get historical values so checks can be made long after the fact.

Anything historical as a source of seed, if it is known by players in advance, can in theory be gamed, no?
I don't mean use old values for new payouts. I mean that in order to check whether the payout of 6 months ago was fair, I need to know the seed from 6 months ago. The source of the seeds needs to be archived somewhere.

It looks like the NY lottery numbers are archived, and of course the Nxt blockchain is, so not much of a problem.


For now the lottery should be ok with small prizes, it's not trivial to game the blockid 10 minutes before the lottery, so v0.1 is safe and should be safe for quite a while to allow time for more safety measures.
[/quote]
Logged

lurker10

  • Hero Member
  • *****
  • Karma: +168/-33
  • Offline Offline
  • Posts: 1334
    • View Profile
Re: Lottery
« Reply #34 on: August 14, 2016, 03:46:43 pm »

Two hours before the first lottery, be a part of history :)
Logged
Run a node - win a prize! "Lucky node" project jar: NXT-8F28-EDVE-LPPX-HY4E7

yassin54

  • Hero Member
  • *****
  • Karma: +240/-14
  • Offline Offline
  • Posts: 2498
  • I am Homer, Sorry my english is Bad!!
    • View Profile
Re: Lottery
« Reply #35 on: August 14, 2016, 06:08:54 pm »

Thanks!!  8)

Code: [Select]
Public Message
Seed 46850 from block 914773; Winning combination: 15,13,9,4,7; your ticket: 7,15,20,13,27 - 3 matches; 14.25000 NXT:1 winner(s).

The first lottery is complete, 10 tickets were bought. Congratulations to 3 winners, I will soon post instructions to verify lottery results. The next lottery will take place next Sunday as usual :)

lurker10

  • Hero Member
  • *****
  • Karma: +168/-33
  • Offline Offline
  • Posts: 1334
    • View Profile
Re: Lottery
« Reply #36 on: August 14, 2016, 06:09:25 pm »

The first lottery is complete, 10 tickets were bought. Congratulations to 3 winners, I will soon post instructions to verify lottery results. The next lottery will take place next Sunday as usual :)

Updated the first post with verification instructions.
« Last Edit: August 14, 2016, 07:51:38 pm by lurker10 »
Logged
Run a node - win a prize! "Lucky node" project jar: NXT-8F28-EDVE-LPPX-HY4E7

lurker10

  • Hero Member
  • *****
  • Karma: +168/-33
  • Offline Offline
  • Posts: 1334
    • View Profile
Re: Lottery
« Reply #37 on: August 15, 2016, 06:59:57 am »

Working on v0.3. It will process multiple tickets from one nxt account as somebody just bought 3 tickets from one account. The first lottery didn't have that happen, the script will be changed to take care of this by next Sunday lottery. Attached messages should still be public. The lottery will not process encrypted messages, they will go to the donations jar.

Question: should one ticket be allowed to participate in all 3 rounds?

Example:
a ticket comes with numbers 1,2,3,4,5

5-number round winning combination: 1,2,3,4,5
4-number round winning combination: 1,2,3,4,10
3-number round winning combination: 1,2,3,10,20

Should the ticket take prizes in all rounds or just the first one it matches?
Logically the ticket should be canceled after the first round but I never play lotteries, have no idea what is right or wrong, lol.
Logged
Run a node - win a prize! "Lucky node" project jar: NXT-8F28-EDVE-LPPX-HY4E7

TheWireMaster

  • Sr. Member
  • ****
  • Karma: +27/-0
  • Offline Offline
  • Posts: 356
    • View Profile
    • NXT Folks
Re: Lottery
« Reply #38 on: August 15, 2016, 07:43:42 am »

I won!!!! yeah!!!! First time a win something! ;)
Logged
NXT-5WW2-XQ63-CFGM-G7YAJ

Butthead

  • Jr. Member
  • **
  • Karma: +1/-0
  • Offline Offline
  • Posts: 16
    • View Profile
Re: Lottery
« Reply #39 on: August 15, 2016, 01:46:39 pm »

I'll play again. Can I pay now or do I need to wait until it's reset?
Logged
Pages: 1 [2] 3 4  All
 

elective-stereophonic
elective-stereophonic
assembly
assembly