Example #1
0
        public void SetKey(ExtPublicKey pubKey)
        {
            var prefix = RootService.Network.ExtPublicKey;
            var data   = new byte[prefix.Length + ExtKey.Bip32KeySize];

            prefix.CopyTo(data.Slice(0, prefix.Length));
            pubKey.Encode(data.Slice(prefix.Length));
            SetData(data, prefix.Length);
        }
Example #2
0
        public ExtPublicKey GetKey()
        {
            var pubKey = new ExtPublicKey();

            if (KeyData.Length == ExtKey.Bip32KeySize)
            {
                pubKey.Decode(KeyData);
            }
            return(pubKey);
        }
Example #3
0
        /// <summary>
        /// Derives a child hierarchical deterministic public key specified by a key path.
        /// </summary>
        /// <param name="index"></param>
        /// <param name="hardened"></param>
        /// <returns></returns>
        protected override ExtKey DeriveBase(int index, bool hardened)
        {
            var cek = new ExtPublicKey
            {
                Depth       = (byte)(Depth + 1),
                Child       = (uint)index | (hardened ? HardenedBit : 0),
                Fingerprint = BitConverter.ToInt32(PublicKey.GetId().Span.Slice(0, 4))
            };

            bool ok;

            (ok, cek.PublicKey, cek.ChainCode) = PublicKey.Derive(cek.Child, ChainCode);
            return(ok ? cek : null);
        }
Example #4
0
 public bool Equals(ExtPublicKey o) => !(o is null) && base.Equals(o) && PublicKey == o.PublicKey;
Example #5
0
 /// <summary>
 /// BIP32 uses "Neuter" to describe adding the extended key information to the public key
 /// associated with an extended private key.
 /// </summary>
 /// <returns></returns>
 public ExtPublicKey GetExtPublicKey() => ExtPublicKey.FromPrivateKey(this);
Example #6
0
 public Base58ExtPublicKey(ExtPublicKey pubKey)
 {
     SetKey(pubKey);
 }