Пример #1
0
        /// <summary>
        /// Sets Bip32 private key.
        /// Uses a single invocation of HMACSHA512 to generate 512 bits of entropy with which to set master private key and chaincode.
        /// </summary>
        /// <param name="hmacData">Sequence of bytes passed as hmacData to HMACSHA512 along with byte encoding of hmacKey.</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(ReadOnlySpan <byte> hmacData, IEnumerable <KzKeyPath> required = null, string hmacKey = null)
        {
            hmacKey = hmacKey ?? Kz.MasterBip32Key;
            var vout = KzHashes.HMACSHA512(hmacKey.UTF8NFKDToBytes(), hmacData);

            return(SetMaster(vout, required));
        }
Пример #2
0
        public KzExtPrivKey SetMaster(ReadOnlySpan <byte> seed, IEnumerable <KzKeyPath> required = null)
        {
            var vout = KzHashes.HMACSHA512(Encoding.ASCII.GetBytes(Kz.SetMasterSeed), seed).ReadOnlySpan;

            return(SetMaster(vout.Slice(0, 32).ToKzUInt256(), vout.Slice(32, 32).ToKzUInt256(), required));
        }