Creating random data and Storing in the blockchain ?

bloodshinxbloodshinx Member Posts: 5
edited May 2016 in Solidity
Hello !

I have some plans for a future Dapp. However, even if i master quite enough Solidity, there is some questions i have, not answered by my researchs.

Let's say that i want to create an array of n elements.
In the constructor of the contract, i initialize this array with random values ( hashes, timestamps .. ).

Then i would use this array into a game.

Where are stored these values?
Can someone see what's inside? Could the execution steps of the contract shows the final outputs ?
Is a "secret zone discovering" dapp impossible to exist on the blockchain?

In other terms : is it possible to have secret initialized data in a contract ?:smile:smile:
Thank you a lot for your help :blush:

Comments

  • HippoClipHippoClip Member Posts: 16
    If I understand correctly keeping such information secret is not possible. The contract including its entire state is in the blockchain which is public. If you think about, since all full nodes need to be able to process the contract code there is really no easy way to keep such information secret.
  • bloodshinxbloodshinx Member Posts: 5
    thank you, i understood that too.
  • o0ragman0oo0ragman0o Member, Moderator Posts: 1,291 mod
    @bloodshix, I'm trying to understand your request in pratical terms....

    Say you have a game world with hidden treasure (minecraft perhaps). The treasure is randomly distributed in to the world upon initialization of the game and doesn't move afterward. You want that treasure to award actual ether when a player 'finds it'. The Game has a smart contract which takes a coordinate and returns eth or not based upon looking up that coordinate in the treasures table.

    So naturally you want to keep those locations secret from prying eyes who could simply steal the ether strait from games smart contract.

    What you could do is have a table of SHA3 hashes of the treasure coords. A player then provides a SHA3 hash of their current coordinate.

    This would push back the attack vector from a mere lookup to one of iterative spamming the contract with game coords. But that's a different problem, perhaps answered by an algo that maps (hides) the finite game space into a far greater uint256 space to make brute force searching impractical.
Sign In or Register to comment.