2

I'm writing a smart contract where participants are asked to submit a value (1 to 1000000) in the submission period, and then reveal what that value is in the revealing period.

In order to hide it from other participants, I'm thinking of using the built-in SHA3 hash function.

Originally I thought of simply asking the player to provide a SHA3 hash of the value, but then realized anyone could figure out the original value, since it's easy to compute SHA3 hashes of all numbers from 1 to 1000000 and just find the matches.

The alternative is to concatenate the number with an arbitrary local value, send the hash of that, and in the reveal phase ask the participant to provide both values.

Is this method workable? Is this a standard way of hiding moves in Ethereum? Are there better alternatives?

Thanks!

0

What you suggest would work: Hash the number, combined with a large random number.

Alternatively if the goal is make a random number from 1 to 1000000, you could just have them provide the hash of their large random number, then the actual large random number, then take the result of their_number % 1000000

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.