1

When writing the following code:

            ////////////////1st offline SERVER//////////////////
            //Create Master Private Key with a seed
            ExtKey privateKey = new ExtKey("16236c2028fd2018eb7049825e6b4f0191de4dbff003579918de7b7348ff06ac");
            //create master public key from this privateKey
            ExtPubKey pubKey = privateKey.Neuter();

            //save it's wifStr as key to the next server to use and generate all child keys 
            string wifStr = pubKey.ToString(Network.Main);
            ////////////////END//////////////////



            ////////////////2nd online SERVER//////////////////
            ExtPubKey key = ExtPubKey.Parse(wifStr);
            //The payment server receive an order, note the server does not need the private key to generate the address
            uint orderID = 1001;
            //address created with only extendet publik key 
            BitcoinAddress address = key.Derive(orderID).PubKey.GetAddress(Network.Main);

            Console.WriteLine(address);
            ////////////////END//////////////////

Am I using hardened private derivation function ? please explain why . I know that in order to use hardened private derivation function I should derive it from a hardened parent, but how do I know that the parent is hardened parent ?

2

Am I using hardened private derivation function?

No. You're using nonhardened derivation. That's the only kind of derivation that you can use when you only have the public key.

Hardened derivation looks like this:

BitcoinAddress address = privateKey.Derive(orderID, true).Key.PubKey.GetAddress(Network.Main);

It requires the private key. It also doesn't matter if the parent is hardened or not.

I would recommend using nonhardened keys for most applications.

  • Why so ? in the book "Mastering bitcoin" the recommendation to use hardened keys, for using nonhardened keys and leak of a private Key can expose the all brunch from the extended Publik Key. I don't understand the issue in using hardened keys where you have to give the top private key so how can it create a "firewall" ? – Haddar Macdasi Apr 23 '15 at 18:35
  • @HaddarMacdasi If you're using hardened keys, then the private key needs to be present whenever you want to generate addresses. That is, in practice, less secure. – Nick ODell Apr 23 '15 at 18:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.