Riecoin Protocol
This page provides general information and explanations about the Riecoin protocol.
Bitcoin base
Riecoin is based on Bitcoin, in particular Riecoin Core is a fork of Bitcoin Core. For now, most of the Bitcoin protocol is left unchanged, so you can in general use existing Bitcoin documentations or tutorials to learn about the Riecoin protocol, there are plenty of them. Of course, you need to take care of things like the modified chain parameters or the different PoW.
Riecoin general parameters
Here are general chain parameters, notably values defined in the Riecoin Core's chainparams.cpp source file, as well as some other constants.
- Blocks every 2.5 minutes (150 seconds)
- Base block reward of 50 RIC, halving every 840000 blocks (~4 years)
- Maximum supply: less than 84 million RIC
- Smallest amount: 0.00000001 RIC, or 1 riemann
- Addresses prefixes:
- Mainnet: ric (Bech32), R (3C16 = 6010, P2PKH), T[1] (4116 = 6510, P2SH)
- Testnet: tric (Bech32), r (7A16 = 12210, P2PKH), t (7F16 = 12710, P2SH)
- Regtest: rric (Bech32), r (7A16 = 12210, P2PKH), t (7F16 = 12710, P2SH)
- RPC port 28332 (38332 for Testnet, 38443 for Regtest)
- P2P port 28333 (38333 for Testnet, 38444 for Regtest)
- Block limits:
- 500 KB (weight 2M)
- Block rewards can be spent only after 100 confirmations
- A block's timestamp must be at most 15 s earlier than the previous one, and 15 s later than the current time
- Protocol version 70001, magic number (Little Endian) 0xFCBCB2DB (0x0E091105 for Testnet, 0xFABFB5DA for Regtest)
- Signed messages prefix:
Riecoin Signed Message:\n
Block header
A Riecoin block header has the following structure (in total, 896 bits, or 112 bytes):
- 32 bits – stores the block version (this includes bits for softfork support signaling);
- 256 bits – stores the hash of the previous block;
- 256 bits – stores the Merkle Root of the block’s transactions;
- 64 bits – stores the block's timestamp;
- 32 bits – stores the difficulty;
- 256 bits – stores the PoW solution (this field is often called nOffset or Nonce).
Proof of Work
The Riecoin Proof of Work (PoW) features the central change from Bitcoin. Instead of looking for hashes, Riecoin miners are looking for prime constellations.
To be a good proof of work, solutions should be much harder to find than verify. If the proof of work were just to find a prime number of length , checking whether a number is actually prime is not much easier, so this would not be a good PoW. Validating blocks and their transactions would be almost as hard as finding them.
A way to make finding much harder than verifying is to not just look for prime numbers, but prime constellations. A prime constellation of length is a sequence of prime numbers , , such that the diameter , is in some sense the least possible[2]. Like we say that Bitcoin has a Sha256 PoW, the Riecoin PoW is called Stella.
Increasing the length makes finding constellations much harder, while verifying that the numbers are indeed prime will not be much more difficult, so we would ideally want to use the largest we can. However, a too large would make mining too hard and force to find much smaller prime numbers, which is something that would also make GPU mining easy. was initially chosen, because the known algorithms at this time were too slow for . Starting from the second hard fork, became 7.
Read this page to learn about the PoW implementation in detail. You might also take a look at the explanation of the mining algorithm, and the Stella page.
Difficulty adjustment algorithm
This is another important change from Bitcoin. The Bitcoin's difficulty adjustment algorithm (DAA) is often considered as one that is particularly vulnerable to attacks from malicious miners. While we believe that the true problem is to gather enough miners such that nobody could access to a significant part of the mining power (making the choice of the DAA irrelevant; after all, Bitcoin never had any problem despite its DAA), an improved DAA may help to lower the risk of attacks while still few people are mining Riecoins and grant other advantages like a better reactivity to mining power changes.
The Riecoin DAA was initially the same as Bitcoin's except a faster adjustment every 288 blocks (about 12 h in Riecoin) instead of 2016 (14 days in Bitcoin). Starting from the second fork, a DAA based on ASERT[3] is used instead. You can learn about the Riecoin DAA implementation here.
Notes and References
- The T prefix is an analogy with the Bitcoin prefixes, as it has 1 for P2PKH and 3 for P2SH, and T is the second letter after R.
- A more precise definition can be found here: Wolfram MathWorld: Prime Constellation
- Actually, an approximated ASERT, sometimes called EMA. This document explains and analyzes ASERT. ASERT/EMA is recommended by a reference person in the domain.