M
M
miki1312015-11-15 16:15:05
Mathematics
miki131, 2015-11-15 16:15:05

How to make an honest number choice?

The task is to honestly choose the winning number WIN_NUMBER from 1 to TOTAL prematurely without knowing TOTAL.
Now I first choose any small RAND number from 0 to 1 ( RAND = Math.random() ) and show people the hash of it md5(RAND) and at the end, when I know the total number of TOTAL, I calculate the winning number in this way

WIN_NUMBER = floor((TOTAL - 0.0000000001) * (RAND / 100)) + 1

What other honest choices are there?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2015-11-15
@OLS

You can also guess a large integer INTRND (which does not allow you to select it by exhaustive search by hash, for example, 128 bits), publish its hash in the same way, and then WIN_NUMBER = (INTRND mod TOTAL) +1. But modular arithmetic is less accepted by users, so multiplication by the number [0..1] is more intuitive for everyone.
And salt, as rightly noted, be sure to keep it secret until disclosed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question