Giter Club home page Giter Club logo

Comments (3)

fametrano avatar fametrano commented on June 4, 2024

good point. We should probably implement

pubkey_from_xpub(xpub: octets) -> Point:
prvkey_from_xpriv(xprv: octets) -> int:

and then rely on the wifaddress module for converting the public key point to address and the private key int to wif.
Does it make sense to you?

from btclib.

keviny avatar keviny commented on June 4, 2024

You mean use bip32 to manipulate the extended private key and extended public key, and use wifaddress to convert the Point (pubKey) and Int (prvKey) to other formats, that makes a lot of sense to me.

One other topic is using the generated private key to generate the second layer of the extended private/public key.

seed=bip39.seed_from_mnemonic('xyz')

// Generate the first layer address
mprv=bip32.mprv_from_seed(seed, xkey_version.hex())
dmprv=bip32.derive(mprv, layer1_path)
dprv=bip32.prvkey_from_xpriv(dmprv)

// Generate the second layer address
mprv2=bip32.mprv_from_pri(dprv)  # or could we use bip32.mprv_from_seed here?
dmprv2=bip32.derive(mprv, layer2_path)

from btclib.

fametrano avatar fametrano commented on June 4, 2024

with next release (later this month or early February, check the current master branch at fametrano/btclib) you will be able to use wif_from_xprv:

from btclib import bip32
from btclib.wif import p2pkh_address_from_wif
seed = b"00"*32  # better be random
rxprv = bip32.rootxprv_from_seed(seed)
path = "m/0h/0h/12"
xprv = bip32.derive(rxprv, path)
wif = bip32.wif_from_xprv(xprv)
address = p2pkh_address_from_wif(wif)
address2 = bip32.address_from_xpub(bip32.xpub_from_xprv(xprv))

with WIF being b'KyLk7s6Z1FtgYEVp3bPckPVnXvLUWNCcVL6wNt3gaT96EmzTKZwP' and both addresses being b'1Lbn3TbfPzM5AjQn84d4bugQN8W4bS1WAQ'

from btclib.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.