Private keys are often represented in Base58Check called a Bitcoin Secret (also known as Wallet Import Format or simply WIF), like Bitcoin Addresses.
Key privateKey = new Key(); // generate a random private keyBitcoinSecret mainNetPrivateKey = privateKey.GetBitcoinSecret(Network.Main); // generate our Bitcoin secret(also known as Wallet Import Format or simply WIF) from our private key for the mainnetBitcoinSecret testNetPrivateKey = privateKey.GetBitcoinSecret(Network.TestNet); // generate our Bitcoin secret(also known as Wallet Import Format or simply WIF) from our private key for the testnetConsole.WriteLine(mainNetPrivateKey); // L5B67zvrndS5c71EjkrTJZ99UaoVbMUAK58GKdQUfYCpAa6jypvnConsole.WriteLine(testNetPrivateKey); // cVY5auviDh8LmYUW8AfafseD6p6uFoZrP7GjS3rzAerpRKE9Wmuzbool WifIsBitcoinSecret = mainNetPrivateKey == privateKey.GetWif(Network.Main);Console.WriteLine(WifIsBitcoinSecret); // True
Note that it is easy to go from BitcoinSecret to private Key. On the other hand, it is impossible to go from a Bitcoin Address to Public Key because the Bitcoin Address contains a hash of the Public Key, not the Public Key itself. Process this information by examining the similarities between these two codeblocks:
Key privateKey = new Key(); // generate a random private keyBitcoinSecret bitcoinSecret = privateKey.GetWif(Network.Main); // L5B67zvrndS5c71EjkrTJZ99UaoVbMUAK58GKdQUfYCpAa6jypvnKey samePrivateKey = bitcoinSecret.PrivateKey;Console.WriteLine(samePrivateKey == privateKey); // True
PubKey publicKey = privateKey.PubKey;BitcoinAddress bitcoinAddress = publicKey.GetAddress(ScriptPubKeyType.Legacy, Network.Main); // 1PUYsjwfNmX64wS368ZR5FMouTtUmvtmTY//PubKey samePublicKey = bitcoinAddress.ItIsNotPossible;
Generate a private key on the mainnet and note it.
Get the corresponding address.
Send bitcoins to it. More than what you can afford to lose, so it will keep you focused and motivated to get them back during the following lessons.