Winner selection

In this document, we outline the comprehensive process used to select winners in our raffle system. Our goal is to ensure fairness, transparency, and incentivization of early participation through a well-defined mechanism. By detailing the methodology behind the winner selection, we aim to provide participants with a clear understanding of how their actions influence their chances of winning and uphold the integrity of the raffle.

Winner Selection Mechanism

The winner selection process in our raffle system is designed to be both equitable and strategic, at its core, encouraging early and meaningful participation. It unfolds in three key steps:

  • firstly, by assigning weights to deposits, emphasizing the value of early contributions.

  • Next, each participant is allocated a range or "slot" based on their weighted contribution, setting the stage for the selection phase.

  • Finally, a random number determines the winning slot, seamlessly blending engagement levels with chance.

This concise approach ensures an equitable competition, where the timing and amount of participation directly influence the odds of winning

Below, we break down the key components of this process:

Weight Calculation Based on Deposit Day

The fundamental principle guiding the weight calculation is that the value of a deposit is not only a function of the amount but also of its timing. To achieve this, we employ a multiplier that decreases over time, applied to the amount deposited. This multiplier is highest at the beginning of the raffle period and gradually reduces as the end of the period approaches.

  • Early Participation Incentive: Deposits made earlier in the raffle period receive a higher weight due to the higher multiplier. This serves as an incentive for participants to deposit sooner rather than later, adding an element of strategy to their participation.

  • Multiplier Decrease: The rate at which the multiplier decreases is predetermined and transparently communicated to all participants. This ensures that every participant has the same information and can make informed decisions about when to make their deposits.

  • Impact on Winner Selection: The weights calculated through this method are then aggregated for each participant, forming the basis of the winner selection process. The higher the total weight a participant accumulates, the higher their chances of being selected as a winner.

By employing a weight-based system modulated by deposit timing, we not only incentivize early and active participation but also ensure a fair and transparent method for selecting winners. This approach balances the randomness inherent in a raffle with strategic elements that participants can influence through their actions.

Weight Calculation Based on Deposit Day

The weight of a deposit is directly proportional to the amount deposited and is modulated by a multiplier that decreases over time. This multiplier is designed to give more weight to early deposits during the raffle period, incentivizing early participation.

The formula for calculating the weight of a deposit is:

Where:

  • The amount is the value of the deposit

  • Multiplier(t) is a function of time (t) (the day of the deposit relative to the start of the raffle period), which assigns a higher multiplier to earlier deposits and a lower multiplier to later deposits. This function is predefined and consists of a descending array of multipliers corresponding to the raffle duration.

Adjustment of Weight Based on Withdrawals

When a withdrawal occurs, the weight calculated from the most recent deposit of the withdrawing participant is adjusted. If a participant withdraws an amount, the weight corresponding to their first deposit is reduced by an amount proportional to the withdrawal, modulated by the multiplier applicable at the time of that first deposit.

The formula to adjust the weight after a withdrawal is:

where:

  • Weight_current is the current weight of the participant before the withdrawal.

  • Amount_withdraw is the amount being withdrawn.

  • Multiplier(t firstdeposit) is the multiplier applied to the first deposit made by the participant, determined by the day of that deposit relative to the start of the raffle period.

This approach ensures that the withdrawal affects the participant's weight in a manner that reflects both the amount withdrawn and the temporal value of their last deposit. It effectively penalizes withdrawals by reducing the participant's accumulated weight, thus diminishing their chances in the lottery proportional to the timing and amount of their withdrawal.

The Process of Generating the Multiplier Array

The creation of the multiplier array is a calculated process, designed to incentivize early participation while maintaining equitable chances for all entrants. Here’s a step-by-step breakdown of how this array comes to be:

The core of this process is the systematic generation of the multiplier for each day of the raffle. Starting with the base_multiplier, the value for each day is calculated by decrementing the multiplier by the daily decrease step, applied iteratively for the duration of the raffle.

How the multiplayer array is generated:

Bountive generates an array of multipliers that decrease linearly over the total duration of a raffle.

  1. Calculation of the Daily Decrease Step:

The base_multiplier is initialized at 1.0 and represents the starting multiplier. The is the amount by which the multiplier decreases each day.

  1. Generation of the Multiplier Array:

For each day i of the raffle period, a corresponding multiplier is calculated. The multiplier for the day i is the base multiplier decreased by i times the step.

During the Selection Process, we dynamically allocate a "range" or "slot" to each participant in a raffle based on their weighted contribution. This method facilitates the selection of a winner by generating a random number within a predefined range. Here's a breakdown of how it works and the rationale behind its design:

  1. Total Weight Calculation: the function computes the total weight of all participants combined. This total weight represents the sum of individual weights, where each weight reflects the participant's engagement and contribution to the raffle as previously defined.

  2. Range Assignment: Each participant is then allocated a specific range based on their proportional contribution to the total weight. The range is determined by calculating a segment within a fixed scale that corresponds to their share of the total weight.

Formula

For each participant i, the range (Ri) is calculated using the formula:

where:

Here, weight is the weight of the participant i,total_weight is the sum of weights for all participants.

Selection of a Winner

Once ranges are assigned, selecting a winner becomes a matter of generating a random number within the total fixed scale and determining which participant's range includes this number. This method is used for several reasons:

  • Fairness: Every participant is guaranteed a chance to win proportional to their contribution, ensuring fairness.

  • Scalability: It can easily accommodate any number of participants without significant changes to the logic or the performance of the selection process.

  • Precision: By using a large multiplier, the method allows for precise differentiation between participants, especially important in close contests where small differences in contribution need to be accurately reflected.

How the Random Number is selected

Bountive random Implementation

On-Chain Random Number Generation Process

  1. Poseidon Hash Calculation: The Poseidon Hash function, denoted as H, is used to hash an integer A, resulting in H(A), the hash of A. The Poseidon Hash function is known for its efficiency and security, making it an excellent choice for blockchain applications.

  2. Normalization: The number is normalized to a range of 0 to B-1using the formula. N(x, B) = x % B, ensuring that the result fits within the specified range.

  3. Final Calculation: The final random number is calculated using the formula:

This ensures that the random number is derived from the future block hash and normalized to the desired range.

Why Poseidon Hash

The Poseidon Hash function is considered one of the best solutions for Zero-Knowledge proofs due to its:

  • Efficiency: Poseidon Hash is designed to be highly efficient in circuits, which is a crucial aspect of ZK proof systems.

  • Security: It provides a high level of security, making it suitable for applications that require secure and verifiable computations.

Fairness of Using Future Block Hash

Using the hash of a future block as a source of randomness is considered fair because:

  • Unpredictability: No participant can know or influence the hash of a future block, ensuring that the outcome cannot be manipulated.

  • Verifiability: Once the block is mined, its hash becomes publicly available, allowing anyone to verify the calculation of the random number.

  • Equality: Every participant has an equal chance of winning, as the random number is derived from a source that is external to the participants' influence.

On-Chain Verification

Allowing users to input the block hash of the drawing and the maximum range on-chain for verification ensures:

  • Transparency: The process is transparent, as all participants can see and verify how the winner is determined.

  • Trust: This method builds trust in the system, as it relies on blockchain's inherent properties of immutability and transparency.

  • Accessibility: Users can independently verify the fairness of the draw, reinforcing the integrity of the selection process.

In summary, the use of the Poseidon Hash function for calculating random numbers from future block hashes provides an optimal balance of efficiency, security, and fairness for on-chain applications. This approach ensures that all participants have an equitable chance in the selection process, with the added benefit of enabling transparent and verifiable outcomes.

It's essential to highlight that, in parallel to our developed method for generating random numbers using the future block hash, we have also integrated the Pragma VRF (Verifiable Random Function) solution for randomness. The Pragma VRF represents a cutting-edge approach to achieving verifiable randomness, which is crucial for applications requiring a high degree of security and fairness, such as lottery or raffle systems.

However, since the Pragma VRF was not yet available on-chain at the time of our implementation, we incorporated our custom function to generate a random number that fits our specific lottery raffle scenario. This bespoke function, outlined previously, leverages the Poseidon Hash and the properties of future block hashes to ensure fairness, unpredictability, and transparency.

Integration of Pragma VRF

The decision to integrate Pragma VRF into our system was motivated by its robustness and the additional layer of security and verifiability it offers. VRFs are cryptographic methods that produce a random output along with proof of the randomness' correctness. This feature is particularly valuable in decentralized applications, where trust is distributed, and verifiability of actions is paramount.

Custom Random Number Generation

Our custom solution for random number generation was designed to meet the immediate needs of our lottery raffle application, ensuring that the process remains fair and transparent until Pragma VRF becomes fully operational on-chain. This approach allowed us to maintain the integrity and trustworthiness of our application.

Last updated