Anish-Agnihotri / MultiRaffle

NFT distribution with (1) randomized, multi-winner raffles and (2) bulk on-chain metadata generation.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Biased shuffling

ARR4N opened this issue · comments

This is a great initiative, thanks for starting it.

Your Fisher–Yates implementation biases selection of early entrants by use of modulus (Wiki explanation).

uint256 randomIndex = i + entropy % (raffleEntries.length - i);

I suspect that reuse of the same entropy will introduce other biases, but how the affect the implementation is less immediately obvious. My initial thoughts are that you need to use the entropy from VRF in a construction like keccak256(abi.encode(vrf_entropy, counter)) so that each selection is independent. However this becomes expensive.

FWIW I'm @divergence_art in the NFT world should you want to chat on Twitter.