public MnemonicKeyPair DerivedKey(bool hardened, string path = null) { DeterministicKeyPair master = DeterministicKeyPair; // check if we really have the masterKey at hand //mpiva limitation no go back in history if (master.Depth != 0) { throw new AException("Given mnemonicKeyPair object does not contain the master key"); } /** * following the BIP32 specification create the following tree purpose -> coin -> account -> * external chain -> child address */ /** * always set path for purpose {@link BaseConstants.HD_CHAIN_PURPOSE}, coin {@link * BaseConstants.HD_CHAIN_CODE_AETERNITY} */ string pathToDerivedKey = "m/" + Constants.BaseConstants.HD_CHAIN_PURPOSE + "'/" + Constants.BaseConstants.HD_CHAIN_CODE_AETERNITY + "'"; /** if no arguments are given, set default account and external chain (0h, 0h) */ if (string.IsNullOrEmpty(path)) { pathToDerivedKey += "/0'/0'"; /** in case arguments are given - add warning */ } else { pathToDerivedKey += "/" + path; pathToDerivedKey = pathToDerivedKey.Replace("//", "/"); } DeterministicKeyPair nextChildDeterministicKeyPair = master.DeriveNextChild(pathToDerivedKey, hardened); // derive a new child RawKeyPair childRawKeyPair = new RawKeyPair(Hex.ToHexString(nextChildDeterministicKeyPair.PrivateKey.ToBytes())); return(new MnemonicKeyPair(childRawKeyPair, MnemonicSeedWords, nextChildDeterministicKeyPair)); }