/// <summary> /// Computes the key specified by a key path. /// At each derivation, there's a small chance the index specified will fail. /// If any generation fails, null is returned. /// </summary> /// <param name="kp"></param> /// <returns>null on derivation failure. Otherwise the derived private key.</returns> public KzExtKey DeriveBase(KzKeyPath kp) { var k = this; foreach (var i in kp.Indices) { k = k.DeriveBase((int)(i & ~HardenedBit), (i & HardenedBit) != 0); if (k == null) { break; } } return(k); }
/// <summary> /// Computes the public key specified by a key path. /// At each derivation, there's a small chance the index specified will fail. /// If any generation fails, null is returned. /// </summary> /// <param name="kp"></param> /// <returns>null on derivation failure. Otherwise the derived private key.</returns> public KzExtPubKey Derive(KzKeyPath kp) => DeriveBase(kp) as KzExtPubKey;