5

Would it be possible to design an algorithm for pseudo-randomly sorting accounts into groups, by using the maximum number of accounts on Ethereum, the max value of a 256-bit number, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF,  then treat the hash of an account as a large random number.

Something similar to the algorithm

userGroup[msg.sender] = uint(userHash[msg.sender]) / (uint(maxHash) / numGroups()) + 1;

g is group index, n is account hash, k is 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, p is number of groups.

g = n / (k / p) + 1

How large does the quantity of n have to be for a similar algorithm to work ? What is the lower-bound for quantity of n when it becomes unusable ?

What would be an example of a similar algorithm ?

eth
  • 85,679
  • 53
  • 285
  • 406
Euclid
  • 51
  • 1

1 Answers1

1

If the goal is just to pseudo-randomly assigning account to buckets, than you can simply use uint(address) % n to distribute among buckets numbered 0 to n-1 (see also: Non-cryptographic hash functions). If you have an additional requirement for this assignment to be unpredictable, this becomes much more complicated due to the lack of true randomness on the blockchain.

How large does the quantity of n have to be for a similar algorithm to work ? What is the lower-bound for quantity of n when it becomes unusable ?

It's not entirely clear, what do you mean by "work" / "usable". What requirements do you have?

Sergei Tikhomirov
  • 1,062
  • 8
  • 21