Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds page pseudorandom number generation algorithm #963

Merged
merged 4 commits into from
Jul 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/research/ticket-selection-algorithm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# <img class="dcr-icon" src="/img/dcr-icons/QuestionTicket.svg" /> Ticket Selection Algorithm

Every block, 5 tickets are pseudorandomly selected from the ticket pool to [vote](../proof-of-stake/overview.md). Below is a high-level description of the ticket selection algorithm. A more detailed, low-level walkthrough of the ticket selection code can be found in this [video](https://www.youtube.com/watch?v=eysGWVhDFWY).

## Pseudorandom number generation

Tickets are selected from the ticket pool using a deterministic [Pseudorandom Number Generator (PRNG)](https://en.wikipedia.org/wiki/Pseudorandom_number_generator). It is deterministic because the seed input to the PRNG is derived from the hash of the previous block (the block being voted on). Specifically, the seed is a serialization of the [header](../advanced/block-header-specifications.md) of the previous block suffixed with a constant derived from the hex representation of the mathematical constant Pi (𝜋), which acts as a publicly verifiable Nothing-Up-My-Sleeve ([NUMS](https://en.wikipedia.org/wiki/Nothing-up-my-sleeve_number)) constant. All eligible tickets in the ticket pool (also referred to as live tickets) are hashed using the [BLAKE-256](blake-256-hash-function.md) hash function and sorted [lexicographically](https://en.wikipedia.org/wiki/Lexicographical_order) by their hash to generate a [total order](https://en.wikipedia.org/wiki/Total_order). Finally, uniformly random values constrained by the number of total eligible tickets as an upper bound are produced and used as indices into the total order.

1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ nav:
- 'Script Extensions': 'research/script-extensions.md'
- 'Signature Script Isolation and Fraud Proofs': 'research/signature-script-isolation-and-fraud-proofs.md'
- 'Transaction Extensions': 'research/transaction-extensions.md'
- 'Ticket Selection Algorithm': 'research/ticket-selection-algorithm.md'
- 'Schnorr Signatures': 'research/schnorr-signatures.md'
- 'Miscellaneous Improvements': 'research/miscellaneous-improvements.md'
- Contributing:
Expand Down