Riecoin needs support! We are offering a 1,000,000 RIC bounty, which was worth more than $500,000 during the Riecoin ATH, to whoever makes a fruitful partnership with us, and significantly contributes to the Riecoin adoption. Note that the supply is capped to about 84,000,000 RIC!
Riecoin makes use of PoW to do scientific number crunching in addition to securing the network, which provides a concrete solution to the PoW power consumption issue and makes the existence of any hash PoW altcoin an aberration and hundreds of mining algorithms useless. Yet it remains overlooked by major medias and actors. So if you have the resources to give Riecoin the attention it deserves, don't miss this interesting opportunity!
For educational or development purposes, this page will explain how to generate a Riecoin Bech32 (P2WPKH) address from scratch.
Firstly, generate 256 random bits (32 bytes), which will be your private key. This number can be represented in hexadecimal with 64 hex digits. For example, consider the private key
The hexadecimal string may directly be imported in a Riecoin wallet: since Riecoin Core 22.02, it is no longer needed to make an additional step to calculate a "WIF" private key, which did not really provide a lot of advantages in practice. Of course, never share a private key that you use, in any form.
With this private key, generate the compressed public key of 33 bytes using the ECDSA algorithm with the Secp256k1 elliptic curve, which should be done using an existing library. The public key associated to the private key is in hexadecimal
PubC = 02dc7438cb82428573712e4f1703bccb621f3b1d4b8ba88892f365253940cfb9f7
Now, compute the Witness Program, which takes 20 bytes, by hashing the public key with two algorithms,
RIPEMD160(SHA256(PubC)) = 0e8db9fd38a1ee20c196f625922dace944d833da
The Witness Program will now be converted to the Bech32 format. We will not show all the technical details, only general steps. To learn more, the Bitcoin's Bech32 specification and a reference code may be studied.
The first step of the conversion to Bech32 is to convert the witness program to Base 32. By hand, this can be done by using its binary representation and grouping the bits by 5
00001:11010:00110:11011:10011:11111:01001:11000: 10100:00111:10111:00010:00001:10000:01100:10110: 11110:11000:10010:11001:00100:01011:01101:01100: 11101:00101:00010:01101:10000:01100:11110:11010
The base 32 digits written in decimal are:
Use this table to change these digits to letters from the Bech32 alphabet. 1 becomes p, 26 becomes 6, 6 becomes x,...
Such addresses are using the Witness Version 0, which is included in the Bech32 address by prepending the version (0 is represented by q according to the table):
Finally, use the human readable part (HRP) ric to generate the checksum, prepend with the HRP and delimiter 1, and append the checksum.
The generated Bech32 address is
Broken down: ric . 1 . q . p6xmnlfc58hzpsvk7cjeytdva9zdsv76 . uq03wu HRP . Delimiter . Witness Version . Witness Program . Checksum
For Testnet and Regtest, the respective tric and rric HRP must be used instead, and the addresses would have been
Notes and references
- It must be between 1 and fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140.
- The advantages are that they are a bit shorter, and the type of address and a checksum could be included. However, Private Keys should be copy pasted anyway, Bech32 adoption is basically 100% in Riecoin, and one can double check by reimporting the key and look at the address. Also Private Keys are normally not handled by most users. Not using WIF also save developers from the trouble of having to write or find a Base58 implementation.
- What is a compressed Bitcoin key?