コード例 #1
0
ファイル: KzExtPrivKey.cs プロジェクト: wy000000/KzBsv
        /// <summary>
        /// Sets hybrid Bip32 / Bip39 private key.
        /// Uses only a single Bip32 style use of HMACSHA512 starting with at least 32 bytes of Bip39 entropy from mnemonicWords.
        /// </summary>
        /// <param name="mnemonicWords">Must be at least 32 bytes of Bip39 mnemonic word entropy with valid checksum.</param>
        /// <param name="required">if not null, each key path will be verified as valid on the generated key or returns null.</param>
        /// <param name="hmacKey">Default is current global Kz.MasterBip32Key which may default to "Bitcoin seed".</param>
        /// <returns>Returns this key unless required key paths aren't valid for generated key.</returns>
        public KzExtPrivKey SetMasterBip32(string mnemonicWords, IEnumerable <KzKeyPath> required = null, string hmacKey = null)
        {
            var e = KzMnemonic.FromWords(mnemonicWords).Entropy;

            if (e == null || e.Length < 32)
            {
                throw new ArgumentException($"{nameof(mnemonicWords)} must provide at least 32 bytes of BIP39 mnemonic entropy.");
            }
            return(SetMasterBip32(e, required, hmacKey));
        }
コード例 #2
0
        public KzExtPrivKey SetMaster(string passPhrase, IEnumerable <KzKeyPath> required = null)
        {
            var e = KzMnemonic.FromWords(passPhrase).Entropy;

            if (e == null || e.Length < 32)
            {
                throw new ArgumentException($"{nameof(passPhrase)} must provide at least 32 bytes of BIP39 mnemonic entropy.");
            }
            return(SetMaster(e, required));
        }