Bip32-Hd-Wallets

NBitcoin 是否使用強化私有派生?

  • April 22, 2015

編寫以下程式碼時:

           ////////////////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//////////////////

我在使用強化的私有派生函式嗎?請解釋原因。我知道為了使用強化的私有派生函式,我應該從強化的父級派生它,但是我怎麼知道父級是強化的父級?

我在使用強化的私有派生函式嗎?

不,您使用的是非硬化派生。當您只有公鑰時,這是您可以使用的唯一一種派生方式。

硬化派生如下所示:

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

它需要私鑰。父母是否變硬也無關緊要。

我建議對大多數應用程序使用非硬化密鑰。

引用自:https://bitcoin.stackexchange.com/questions/37038