# Stella

Stella refers to the PoW type like we say that Bitcoin is Sha256, or Litecoin is Scrypt. In the case of Riecoin, it does not actually refer to the actual algorithm used by miners, but rather to what they are trying to find, prime constellations. Old implementations may also have referred Stella as "PrimesR".

## Riecoin PoW

As a reminder, a prime constellation of length $k$ is a sequence of $k$ prime numbers $(n_{1},n_{2},...,n_{k})$ , $n_{1} , such that the diameter $n_{k}-n_{1}$ , is in some sense the least possible.

The important parameters are:

• The constellation length $k$ : 7 (5 in Testnet);
• The Difficulty $D$ , which correspond to the size of the prime numbers, which is about $2^{D}$ .

While looking for them, miners first generate candidates at a rate of $c$ candidates/s. Then they check if the candidates are prime constellations. In practice, it can be stated that every of these candidates have a probability ${\frac {1}{r}}$ to be a prime number, ${\frac {1}{r^{2}}}$ to be a 2-tuples, etc. $r$ is the ratio of the rate of found $i$ to $(i+1)$ -tuples for $i\in \{0;1;...;k-1\}$ (a candidate whose $n_{1}$ is not prime is a 0-tuple). It does not depend on the $i$ but is proportional to the Difficulty, and may also change depending on the miner settings.

In other words, the occurrences of $i$ -tuples can be modeled as a Poisson Process of intensity ${\frac {1}{r^{i}}}$ .

## Solo mining

### Process

The mining process in solo mining is straightforward. A miner will generate the candidates, that check if $n_{1}$ is prime. If not, the miner discards the candidate and checks the next one, else it continues and check if $n_{2}$ , and so on. If the $n_{i}$ is prime for all the $i$ , a prime constellation was found and a block can be submitted to the Riecoin network.

### Earnings estimation

Computing the earnings only requires $c$ and $r$ , which can be obtained easily: count the number of candidates and prime numbers (in the sense how many times $n_{1}$ was prime) found during some time and do elementary arithmetics.

${\frac {c}{r^{k}}}$ gives a good estimation of the block rate (in blocks/second), so $86400{\frac {c}{r^{k}}}$ will give the average blocks found every day. Multiplying this by the block reward (currently 25 RIC) will yield the earnings in RIC/day.

${\frac {r^{k}}{c}}$ gives the average time to find a block in seconds, and a miner will have 50% chance to find a block within $\log(2){\frac {r^{k}}{c}}$ .

### Normalization

One issue with just having a block rate is that it cannot be used if the difficulty varies. For the same mining power, if $D$ increases, $c$ will be lower and $r$ higher, and there will be less blocks found (but because there is more mining power in the network, the network's average time between blocks will remain the same).

To handle this, these two assumptions can be used:

• $r$ is proportional to $D$ , which is close to the reality;
• $c$ is proportional to $D^{2.3}$ . In reality, the power is something around 2.2-2.6, increasing when $D$ is higher, but it is not easy to derive a precise formula for this so we are just taking 2.3, which also corresponds to current difficulties.

Using them allows to normalize various metrics. For example, $({\frac {D}{D'}})^{k+2.3}{\frac {c}{r^{k}}}$ gives a good estimation of the block rate for a reference difficulty $D'$ using the candidates/s and ratio metrics at difficulty $D$ . Or, $({\frac {D}{D'}})^{2.3}c$ estimates the candidates/s as if we were mining at difficulty $D'$ from metrics for $D$ .

The Riecoin Core's getnetworkminingpower command uses $D'=600$ to provide a normalized number that corresponds to how many times the current network's mining power is larger than the power needed to find a block of difficulty 600 every 150 s.

## Pooled mining

### Shares

In pooled mining, the point is to avoid very long periods between blocks for a miner by making them find and submit shares instead. The conditions to meet for a share are much weaker versions of the ones for a block, so finding shares is much easier, but one of them will eventually also be a block. Pools then reward miners based on the submitted shares.

Usually, the conditions for a share are the same as the ones for a block, but with a lower difficulty. This clearly cannot be done for Stella. Instead of lowering the difficulty and submitting shares with smaller prime numbers, an idea would be reduce the tuple length. However, looking for shorter tuples is easier than looking for full $k$ -tuples and submit shorter tuples (the sieving process is shorter and there are less numbers to test), making mining more profitable for those who just want to find shares, which is not an acceptable solution.

The current condition for a share is as follow:

• Among the $k$ numbers $n_{i}$ , $k-2$ must be prime;
• The first two numbers must be prime.

The first condition forces miners to look for actual $k$ -tuples. With this system, a miner will test the different numbers until either enough are prime or the current candidate cannot longer be a share. There is one issue, it can happen to check numbers in hopes that it is a share, despite knowing that the candidate will never be a part of a block, reducing pooled mining's general performance. The second condition renders the impact of this issue negligible.

The share prime count is the number of prime numbers, but is equal to 0 if the second condition is not true.

### Earnings estimation

At the miner's side, the process is such that $c$ and $r$ can be obtained in the same way as in solo mining, so calculating the earnings can be done as explained above.

At a pool's side, only the share rate metric can be known (let $s$ be the rate in shares/s), and some combinatorics is required if the operator wishes to show the earning estimations to miners. To do so, the first step is to derive the probability $P$ of a candidate to be a share.

A candidate must first have $n_{1}$ and $n_{2}$ prime numbers. This has ${\frac {1}{r^{2}}}$ probability of occurring (see below for the ratio estimation). Then, we still need at least $k-4$ numbers to be prime among the remaining $k-2$ numbers $n_{3}$ to $n_{k}$ . The probability of having exactly $m$ additional prime numbers can be calculated by using the Binomial Distribution, $P_{k-2,m}={\binom {k-2}{m}}({\frac {1}{r}})^{m}(1-{\frac {1}{r}})^{k-2-m}$ . ${\binom {n}{k}}={\frac {n!}{k!(n-k)!}}$ is the Binomial Coefficient.

With this and basic probability rules, we can now calculate

$P={\frac {1}{r^{2}}}(P_{k-2,k-4}+P_{k-2,k-3}+P_{k-2,k-2})$ • For 7-tuples (Mainnet): $P={\frac {1}{r^{2}}}(P_{5,3}+P_{5,4}+P_{5,5})={\frac {1}{r^{2}}}(10({\frac {1}{r}})^{3}(1-{\frac {1}{r}})^{2}+5({\frac {1}{r}})^{4}(1-{\frac {1}{r}})+({\frac {1}{r}})^{5})$ ;
• For 5-tuples (Testnet): $P={\frac {1}{r^{2}}}(P_{3,1}+P_{3,2}+P_{3,3})={\frac {1}{r^{2}}}(3({\frac {1}{r}})(1-{\frac {1}{r}})^{2}+3({\frac {1}{r}})^{2}(1-{\frac {1}{r}})+({\frac {1}{r}})^{3})$ .

There is no way to get the ratio $r$ , but you can estimate it with $r\approx 0.0181116D$ .

Finally, we have $c={\frac {s}{P}}$ and the earnings can be calculated like above.

Note that the share rate is probably relatively low, so the accuracy of the earnings estimation will also be low.

### Normalization

Again, it is the same as solo mining at the miner's side. For the pool's side, you can calculate $c$ and $r$ like explained and apply the tricks exposed in the solo mining section.

Pools should use a normalized metric in order to compare their mining power in an other way than just looking at the distribution of the latest 1000 Riecoin blocks or so. A suggested option is to compute the mining power as a factor of the power needed to find a block at difficulty 600 every 150 s, which can be approximated with

${\frac {150s}{Pr^{k}}}({\frac {D}{600}})^{k+2.3}$ Dividing this value by the Riecoin Core's getnetworkminingpower result will approximate the pool's contribution to the entire Riecoin network mining power.