예제 #1
0
        public (bool ok, PublicKey keyChild, UInt256 ccChild) Derive(uint nChild, UInt256 cc)
        {
            (bool ok, PublicKey keyChild, UInt256 ccChild)invalid = (false, null, UInt256.Zero);
            if (!IsValid || !IsCompressed || nChild >= HardenedBit)
            {
                return(invalid);
            }

            var vout = new byte[64];

            Hashes.Bip32Hash(cc, nChild, Data[0], Data[1..], vout);
예제 #2
0
        internal (bool ok, PrivateKey keyChild, UInt256 ccChild) Derive(uint nChild, UInt256 chainCode)
        {
            (bool, PrivateKey, UInt256)invalid = (false, null, UInt256.Zero);
            if (!IsValid || !IsCompressed)
            {
                return(invalid);
            }

            var vout = new byte[64];

            if (nChild < HardenedBit)
            {
                // Not hardened.
                var pubkey = this.CreatePublicKey();
                Debug.Assert(pubkey.Data.Length == PublicKey.CompressedLength);
                Hashes.Bip32Hash(chainCode, nChild, pubkey.Data[0], pubkey.Data[1..], vout);