forked from IntersectMBO/cardano-ledger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathleader-value.tex
60 lines (47 loc) · 1.89 KB
/
leader-value.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
\section{Leader Value Calculation}
\label{sec:leader-value-calc}
This section details how we determine whether a node is entitled to lead (under
the Praos protocol) given the output of its verifiable random function
calculation.
\begin{figure}
\emph{Values associated with the leader value calculations}
\begin{equation*}
\begin{array}{r@{~\in~}lr}
\var{certNat} & \{n | n \in \N, n \in [0,2^{512})\} & \text{Certified natural value from VRF} \\
\var{f} & [0,1] & \text{Active slot coefficient} \\
\sigma & [0,1] & \text{Stake proportion}
\end{array}
\end{equation*}
\end{figure}
\subsection{Computing the leader value}
The verifiable random function gives us a 64-byte random output. We interpret
this as a natural number $\var{certNat}$ in the range $[0,2^{512})$.
\subsection{Node eligibility}
As per \cite{ouroboros_praos}, a node is eligible to lead when its leader value
$p < 1 - (1 - f)^\sigma$. We have
\begin{align*}
p & < 1 - (1 -f)^\sigma \\
\iff \left(\frac{1}{1-p}\right) & < \exp{(-\sigma \cdot \ln{(1-f)})}
\end{align*}
The latter inequality can be efficiently computed through use of its Taylor
expansion and error estimation to stop computing terms once we are certain that
the result will be either above or below the target value.
We carry out all computations using fixed precision arithmetic (specifically, we
use 34 decimal bits of precision, since this is enough to represent the fraction
of a single lovelace.)
As such, we define the following:
\begin{align*}
p & = \frac{\var{certNat}}{2^{512}} \\
q & = 1 - p \\
c & = \ln{(1 - f)}
\end{align*}
and define the function \textit{checkLeaderVal} as follows:
\begin{equation*}
\fun{checkLeaderVal}~\var{certNat}~\sigma~\var{f} =
\left\{
\begin{array}{l@{~}r}
\mathsf{True}, & f = 1 \\
\frac{1}{q} < \exp{(-\sigma \cdot c)}, & \text{ otherwise}
\end{array}
\right.
\end{equation*}