Exemplo n.º 1
0
        public static KzExtPubKey FromPriv(KzExtPrivKey priv)
        {
            var key = new KzExtPubKey {
                _depth       = priv.Depth,
                _fingerprint = priv.Fingerprint,
                _child       = priv.IndexWithHardened,
                _chaincode   = priv.Chaincode,
                pubkey       = priv.PrivKey.GetPubKey()
            };

            return(key);
        }
Exemplo n.º 2
0
        public override KzExtKey DeriveBase(int index, bool hardened)
        {
            Trace.Assert(index >= 0);
            var cek = new KzExtPrivKey {
                _depth = (byte)(_depth + 1),
                _child = (uint)index | (hardened ? HardenedBit : 0)
            };

            _privkey.GetPubKey().GetID().Span.Slice(0, 4).CopyTo(cek._fingerprint.AsSpan());
            bool ok;

            (ok, cek._privkey, cek._chaincode) = _privkey.Derive(cek._child, _chaincode);
            return(ok ? cek : null);
        }
Exemplo n.º 3
0
 public bool Equals(KzExtPrivKey o) => (object)o != null && base.Equals(o) && _privkey == o._privkey;
Exemplo n.º 4
0
 public static KzExtPrivKey GetMasterPrivKey(string seed, string seedExtension = null) =>
 KzExtPrivKey.Master(KzHashes.pbkdf2_hmac_sha512(seed.UTF8ToBytes(), $"electrum{seedExtension}".UTF8ToBytes(), 2048).Span);
Exemplo n.º 5
0
 public static KzExtPrivKey GetMasterPrivKey(string passphrase, string password = null) =>
 KzExtPrivKey.MasterBip39(passphrase, password, passwordPrefix: "electrum");