ebellocchia / bip_utils Goto Github PK
View Code? Open in Web Editor NEWGeneration of mnemonics, seeds, private/public keys and addresses for different types of cryptocurrencies
License: MIT License
Generation of mnemonics, seeds, private/public keys and addresses for different types of cryptocurrencies
License: MIT License
how to get a hardened address? v 1.11.1
Hi . Thanks for the great package.
I derive BTC,LTC .... address like below from my seed and it works like a charm . But while I'm change it to produce XRP address it doesn't work.
import binascii
from bip_utils import Bip44, Bip44Coins, Bip44Changes
from bip_utils import (P2PKH, P2SH, P2WPKH, BchP2PKH, BchP2SH, AtomAddr, AvaxPChainAddr, AvaxXChainAddr, EthAddr, TrxAddr, XrpAddr)
# Seed bytes
seed_bytes = binascii.unhexlify(b"MY SEED")
# Create from seed
bip44_mst = Bip44.FromSeed(seed_bytes, Bip44Coins.TRON)
# Derive account 0 for Bitcoin: m/44'/0'/0'
bip44_acc = bip44_mst.Purpose().Coin().Account(0)
# Derive the external chain: m/44'/0'/0'/0
bip44_change = bip44_acc.Change(Bip44Changes.CHAIN_EXT)
bip44_addr = bip44_change.AddressIndex(20)
# Print extended keys and address
print(bip44_addr.PrivateKey().ToExtended())
print(bip44_addr.PublicKey().ToExtended())
print(bip44_addr.PublicKey().ToAddress())
print(TrxAddr.ToAddress(bip44_addr.PublicKey().RawUncompressed().ToBytes()))
I get this exception belongs to last line of above code :
ValueError: Public uncompressed key is required for Ethereum address
By the way , the address generated in this line successfully :
bip44_addr.PublicKey().ToAddress()
But is not a valid XRP address. !
Please help
to increase speed, maybe it is worth looking at other libraries?
ofek / match
Richardkiss / Pycoin
famous electrum wallet uses sec256k1 dll
but they all have a big drawback! They can't do everything you do
I ask you to add the use of swift libraries.
this code work fine on ubuntu but when i try to run it on window i get the error shown below
Code Snippet:
from bip_utils import Bip44Coins, Bip44, Bip39SeedGenerator, Bip39MnemonicGenerator, Bip39WordsNum
mnemonic = Bip39MnemonicGenerator().FromWordsNumber(Bip39WordsNum.WORDS_NUM_24)
seed_bytes = Bip39SeedGenerator(mnemonic).Generate()
bip44_def_ctx = Bip44.FromSeed(seed_bytes, Bip44Coins.SOLANA)
print(bip44_def_ctx.PublicKey().ToAddress())
The Error:
Traceback (most recent call last):
File "C:\generate.py", line 5, in <module>
bip44_def_ctx = Bip44.FromSeed(seed_bytes, Bip44Coins.SOLANA)
File "C:\Python310\lib\enum.py", line 429, in __getattr__
raise AttributeError(name) from None
AttributeError: SOLANA
Have you tested with:
PYPY
NIMBA
ERROR: Failed building wheel for coincurve
(while installing the package from pip)
Update the dependencies of the project to coincurve v16 please
Hi,
I'm getting this traceback when creating a wallet in python:
bip44_def_ctx = bip_utils.Bip44.FromSeed(
File ".tox/devel/lib/python3.9/site-packages/bip_utils/bip/bip44/bip44.py", line 144, in DeriveDefaultPath
return self._DeriveDefaultPathGeneric(self, Bip44Const.PURPOSE)
File ".tox/devel/lib/python3.9/site-packages/bip_utils/bip/bip44_base/bip44_base.py", line 275, in _DeriveDefaultPathGeneric
bip_obj = cls._PurposeGeneric(bip_obj, purpose)
File ".tox/devel/lib/python3.9/site-packages/bip_utils/bip/bip44_base/bip44_base.py", line 306, in _PurposeGeneric
return cls(bip_obj.m_bip32.ChildKey(purpose),
File ".tox/devel/lib/python3.9/site-packages/bip_utils/bip/bip32/bip32_base.py", line 336, in ChildKey
return self._ValidateAndCkdPriv(index) if not self.IsPublicOnly() else self._ValidateAndCkdPub(index)
File ".tox/devel/lib/python3.9/site-packages/bip_utils/bip/bip32/bip32_base.py", line 477, in _ValidateAndCkdPriv
return self._CkdPriv(index)
File ".tox/devel/lib/python3.9/site-packages/bip_utils/bip/bip32/bip32_secp256k1.py", line 87, in _CkdPriv
return self._CkdPrivEcdsa(self, index)
File ".tox/devel/lib/python3.9/site-packages/bip_utils/bip/bip32/bip32_ecdsa_base.py", line 114, in _CkdPrivEcdsa
fprint=bip32_obj.m_pub_key.FingerPrint(),
File ".tox/devel/lib/python3.9/site-packages/bip_utils/bip/bip32/bip32_keys.py", line 162, in FingerPrint
return Bip32FingerPrint(self.KeyIdentifier())
File ".tox/devel/lib/python3.9/site-packages/bip_utils/bip/bip32/bip32_keys.py", line 172, in KeyIdentifier
return CryptoUtils.Hash160(self.m_pub_key.RawCompressed().ToBytes())
File ".tox/devel/lib/python3.9/site-packages/bip_utils/utils/misc/crypto.py", line 222, in Hash160
return CryptoUtils.Ripemd160(CryptoUtils.Sha256(data))
File ".tox/devel/lib/python3.9/site-packages/bip_utils/utils/misc/crypto.py", line 199, in Ripemd160
return hashlib.new("ripemd160", AlgoUtils.Encode(data)).digest()
File "/usr/lib64/python3.9/hashlib.py", line 166, in __hash_new
return __get_builtin_constructor(name)(data)
File "/usr/lib64/python3.9/hashlib.py", line 123, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type ripemd160
The code I'm using is
mnemonic = bip_utils.Bip39MnemonicGenerator().FromWordsNumber(
bip_utils.Bip39WordsNum.WORDS_NUM_24
)
is_valid = bip_utils.Bip39MnemonicValidator().IsValid(mnemonic)
# Validate a mnemonic, raise exceptions
try:
bip_utils.Bip39MnemonicValidator().Validate(mnemonic)
# Valid...
except bip_utils.Bip39ChecksumError:
# Invalid checksum...
pass
except ValueError:
# Invalid length or language...
pass
if is_valid:
seed_bytes = bip_utils.Bip39SeedGenerator(mnemonic).Generate()
bip44_def_ctx = bip_utils.Bip44.FromSeed(
seed_bytes, bip_utils.Bip44Coins.CHIHUAHUA
).DeriveDefaultPath()
wallet = bip44_def_ctx.PublicKey().ToAddress()
This worked fine with python 3.9 on F35 (and still does), so I assume it's something in the python side on F36, so any hint will be appreciated. (both are on Python 3.9.10)
Thanks
is it possible to create a complete package from your library with all dependencies?
This would greatly simplify the installation process.
because your library has big dependencies that need to be compiled. e.g. ed25519-blake2b
installing this library requires MSBUILD.
Hi, chihuahua uses cosmos sdk... would it be possible to add support for it?
Thanks
Hey, I want to know how to derive addresses and keys from non standart BIP44 path. For example I want to derive seed for solana addresses in 4 paths: 1) m/44'/501'/0', 2) m/44'/501'/0'/0', 3) m/44'/501'/0/0, 4) m/0/0
For first path I'm using code from readme and it works fine:
import binascii
from bip_utils import Bip44Coins, Bip44
seed_bytes = binascii.unhexlify(b"5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4")
bip44_mst_ctx = Bip44.FromSeed(seed_bytes, Bip44Coins.SOLANA)
bip44_acc_ctx = bip44_mst_ctx.Purpose().Coin().Account(0)
print(bip44_acc_ctx.PublicKey().ToAddress())
But how can I derive for second, third and fourth pathes?
Thanks
Hello dev team.
Thank you for making a library so simple and easy to use.
I'm trying to create a dogecoin wallet with bip32 but it still looks like the address of bitcoin. I have compared with website https://iancoleman.io/bip39/ the private key and public key are same . But when creating a wallet address, it is not the same
Here is my code.
#------------------------
mnemonic='balcony bulk patch salmon illness live hen black try riot author wreck'
seed_bytes = Bip39SeedGenerator(mnemonic).Generate()
#bip32_ctx = Bip32.FromSeedAndPath(seed_bytes, "m/44'/0'/0'",DogecoinConf.BIP44_KEY_NET_VER.Main())
print(bip32_ctx.PrivateKey().ToExtended())
print(bip32_ctx.PublicKey().ToExtended())
print(bip32_ctx.PublicKey().ToAddress())
#-------------
Moreover, how can I get the private key of each wallet address.
Please see where I went wrong and help me to solve the problem.
Thank you
Im testing a bruteforce script im makeing and i keep getting the following error.
Traceback (most recent call last): File "/home/pi/betterbrute.py", line 30, in <module> if generate_address(words_prefix + list(perm)): File "/home/pi/betterbrute.py", line 13, in generate_address if not Bip39MnemonicValidator(mnemonic).Validate(): File "/home/pi/.local/lib/python3.9/site-packages/bip_utils/bip/bip39/bip39_mnemonic_validator.py", line 50, in __init__ self.m_mnemonic_decoder = Bip39MnemonicDecoder(lang) File "/home/pi/.local/lib/python3.9/site-packages/bip_utils/bip/bip39/bip39_mnemonic.py", line 303, in __init__ self.m_words_list = (_Bip39WordsListGetter.Instance().GetByLanguage(lang) File "/home/pi/.local/lib/python3.9/site-packages/bip_utils/bip/bip39/bip39_mnemonic.py", line 164, in GetByLanguage raise TypeError("Language is not an enumerative of Bip39Languages") TypeError: Language is not an enumerative of Bip39Languages
Im using the latest version and my code is the following. I am pretty sure that my code is correct. And the following btc private keys and addresses were generated by iancolman.io/bip39
`from bip_utils import Bip39SeedGenerator, Bip39MnemonicValidator
from bip_utils import Bip44, Bip44Coins, Bip44Changes
import itertools
address = "1EHiMwCPzcvMdeGowsowVF2X2PgLo67Qj7"
words_prefix = ['since', 'desk']
words = ['zone', 'leaf', 'luggage', 'hobby', 'depart', 'thrive', 'practice', 'carbon', 'prison', 'ivory']
def generate_address(words):
mnemonic = " ".join(words)
# Early exit if the checksum word is wrong.
if not Bip39MnemonicValidator(mnemonic).Validate():
return False
# Derive the seed bytes from the mnemonic.
seed_bytes = Bip39SeedGenerator(mnemonic).Generate()
# Derive the master BIP44 key from the seed bytes.
bip44_mst = Bip44.FromSeed(seed_bytes, Bip44Coins.BITCOIN)
# Derive account 0 for Bitcoin: m/44'/0'/0'.
bip44_acc = bip44_mst.Purpose().Coin().Account(0)
# Derive the external chain: m/44'/0'/0'/0
bip44_change = bip44_acc.Change(Bip44Changes.CHAIN_EXT)
# Derive the first address of the external chain: m/44'/0'/0'/0/0
bip44_addr = bip44_change.AddressIndex(0)
return bip44_addr.PublicKey().ToAddress() == address
for perm in itertools.permutations(words):
if generate_address(words_prefix + list(perm)):
print(words_prefix + list(perm))
exit()
`
Hello,
Does BipPublicKey support generating a Bech32 address?
How can I get bip84 and bip141 adresses from seed phrase, can you give the code
my code not work. whu?
`
from bip_utils import Bip39SeedGenerator, Bip39EntropyGenerator,Bip39Languages, Bip39MnemonicGenerator, Bip39WordsNum, Bip39Languages, Bip44, Bip44Coins, Bip44Changes, Bip32, Bip32Utils
mnemonic = Bip39MnemonicGenerator().FromWordsNumber(Bip39WordsNum(12))
seed_bytes = Bip39SeedGenerator(mnemonic).Generate()
bip32_ctx = Bip32.FromSeed(seed_bytes)
bip32_ctx_ex = bip32_ctx.DerivePath("0'/0'/0")
bip32_addr:str = bip32_ctx_ex.PublicKey().ToAddress()
`
Hi,
First of all thank you, I find your repo very useful, great job !
I see in the doc Solana is supported, but Bip44Coins.SOLANA is missing. Bip32Secp256k1 also.
I guess the doc is outdated ?
Hi,
Would you mind adding support for generating Axelar (https://axelar.network/) addresses?
Prefix is: axelar
https://docs.axelar.dev/resources
Thank you in advance
Hi.
Is it possible to validate addresses of various assets with this module ?
I'm installing bip_utils using pipenv, which pulls the package prom pypi, I think the package is not well deployed, since I'm getting the latest version (1.11.1) but with an outdated package
pipenv install bip_utils==1.11.1
####Current coins supported if installed through pypi
Coin | Main net enum | Test net enum |
---|---|---|
Bitcoin | Bip44Coins.BITCOIN | Bip44Coins.BITCOIN_TESTNET |
Bitcoin Cash | Bip44Coins.BITCOIN_CASH | Bip44Coins.BITCOIN_CASH_TESTNET |
BitcoinSV | Bip44Coins.BITCOIN_SV | Bip44Coins.BITCOIN_SV_TESTNET |
Litecoin | Bip44Coins.LITECOIN | Bip44Coins.LITECOIN_TESTNET |
Dogecoin | Bip44Coins.DOGECOIN | Bip44Coins.DOGECOIN_TESTNET |
Dash | Bip44Coins.DASH | Bip44Coins.DASH_TESTNET |
Zcash | Bip44Coins.ZCASH | Bip44Coins.ZCASH_TESTNET |
Ethereum | Bip44Coins.ETHEREUM | - |
Ethereum Classic | Bip44Coins.ETHEREUM_CLASSIC | - |
Ripple | Bip44Coins.RIPPLE | - |
Tron | Bip44Coins.TRON | - |
VeChain | Bip44Coins.VECHAIN | - |
Cosmos | Bip44Coins.COSMOS | - |
Band Protocol | Bip44Coins.BAND_PROTOCOL | - |
Kava | Bip44Coins.KAVA | - |
IRIS Network | Bip44Coins.IRIS_NET | - |
Terra | Bip44Coins.TERRA | - |
Binance Chain | Bip44Coins.BINANCE_CHAIN | - |
Binance Smart Chain | Bip44Coins.BINANCE_SMART_CHAIN | - |
Avalanche C-Chain | Bip44Coins.AVAX_C_CHAIN | - |
Avalanche X-Chain | Bip44Coins.AVAX_X_CHAIN | - |
Avalanche P-Chain | Bip44Coins.AVAX_P_CHAIN | - |
Polygon | Bip44Coins.POLYGON | - |
Fantom Opera | Bip44Coins.FANTOM_OPERA | - |
Harmony One (Metamask address) | Bip44Coins.HARMONY_ONE_METAMASK | - |
Harmony One (Ethereum address) | Bip44Coins.HARMONY_ONE_ETH | - |
Harmony One (Cosmos address) | Bip44Coins.HARMONY_ONE_ATOM | - |
Huobi Chain | Bip44Coins.HUOBI_CHAIN | - |
OKEx Chain (Ethereum address) | Bip44Coins.OKEX_CHAIN_ETH | - |
OKEx Chain (Cosmos address) | Bip44Coins.OKEX_CHAIN_ATOM | - |
OKEx Chain (Old Cosmos address before mainnet upgrade) | Bip44Coins.OKEX_CHAIN_ATOM_OLD | - |
Hey there, I realize that the master branch is not ready for release so you may already know this but as currently configured, running
python setup.py install
will not install a working package because setuptools won't read a folder without
__init__.py
as an importable package and so bip_utils/ecc/lib/ed25519_monero_lib.py won't be included when running the installation script. The simplest fix is to change find_packages to find_namespace_packages in setup.py which will enable proper packaging. Alternatively, an empty
__init__.py
in the ecc/lib folder will also suffice. I have forked the repo and made the fix in a new branch and can submit a pull request if you'd like.
Also, it appears that the latest version of scalecodec changed its namespacing a bit as well, so in bip_utils/substrate/substrate_path.py the ScaleDecoder import needs to be changed to
from scalecodec.base import ScaleDecoder
Likewise, I've forked and made the fix in the aforementioned new branch and can submit a pull request if you'd like. Cheers.
PLS ADD support generate mnemonic and create address electrum v1 (old 100000*sha256) , v2 standart
Please give an example of how to get addresses BIP 49 BIP 84
From the example folder. I use python 3.6.2
Please I will really appreciate
Good day,
would you mind providing me a small example how to derive the first 20 BTC and ETH addresses(used to receive actual funds) from a "normal" private key? I see, you provided many examples how to do it using mnemonic, seed or private extended key. But I can't wrap my head around, how to do it using private key, generated by various software wallets(Electrum, Exodus, etc.) For example, I have a private key:
KzBfG4pV3xjD4aNsxggFmtY6dLqae55CKEFiU2dDztpxtyotdjib
How do I derive the first BTC address from it, which should be:
129hrvLEK84djejoW4hMEC48gEuYSHMLiD
(Ideally, it should support all BTC address formats, P2PKH, P2SH, Bech32) :)
I'm not lazy, just all the crypto and math stuff is beyond my limits of comprehension. Willing to make a donation :)
Hello,
A BITCOIN_CASH_ABC entry could be added to the following (and where else necessary):
bip_utils/bip_utils/bip/bip44_base.py
Line 106 in 3366233
1899 is consistent with the official web wallet (cashtab) and ElectrumABC
See: Bitcoin-ABC/ElectrumABC#62
Ciao.
Thanks for making available this awesome project.
Unfortunately, my python skills are basic and poor.
I was wondering if we are aware of a similar project to this one (particularly BIP 44/49/84) but implemented in C/C++ language?
Any pointers would be greatly appreciated.
Cheers.
hello i am trying to get derived seed and private key of solana however when i call the private key from the library it gives me back an invalid private key which i cant use on any of solana wallets
from bip_utils import Bip44Coins, Bip44, Bip39SeedGenerator,Bip44Changes
seed_bytes = Bip39SeedGenerator('business visit gather camera cargo ketchup episode keep erosion pact large olympic amount trash bring heavy auto what merry surge motor quality corn okay').Generate()
bip44_def_ctx = Bip44.FromSeed(seed_bytes, Bip44Coins.SOLANA)
bip44_acc_ctx = bip44_def_ctx.Purpose().Coin().Account(0)
bip44_chg_ctx = bip44_acc_ctx.Change(Bip44Changes.CHAIN_EXT)
print("derived address : "+bip44_chg_ctx.PublicKey().ToAddress())
print("derived private key : "+bip44_chg_ctx.PrivateKey().ToExtended())
which output
derived address : 93GqFeUXbtGGAP5GfTu6nBbZSvYTr1MiaCGsVpb8Dhk2
derived private key : xprvA1aUNWiGt1MiJQ17kARGhubHR8zEu49td9jMPEj7UigkbYXwxctNFEZrSE4htNrwR1tm7es8LCN9ubft8ah4VXmkcdT3mUBK9ynHsyL3yVB
the public key is correct but the private key isnt
also i cant see any way of getting a derived seed too
the valid private key is : 2SFFSyM8TqXBpsUNk6BbJkTZzkA2NJdHGLCNnYymWNAcgacJvc8PT9ZE4NsnUkgorbmhEk8tRdPcvvkAUTg6u3tA
bip_utils doesn't connect to network however scalecodec
which is related to Palkdot is installing requests
library. It's included in requirements.txt
Hopefully there would be a way to make scalecodec
as an optional dependency. Seems like bip_utils
comes with about 20 dependencies. Would you consider documenting which libraries is needed for which functionality.
thank you.
$ poetry show --tree py-crypto-hd-wallet
py-crypto-hd-wallet 1.1.0 HD (Hierarchical Deterministic) wallet for cryptocurrencies based on bip_utils library
└── bip-utils >=2.3,<3.0
├── coincurve >=15.0.1,<18.0.0
│ ├── asn1crypto *
│ └── cffi >=1.3.0
│ └── pycparser *
├── crcmod >=1.7,<2.0
├── ecdsa >=0.15,<1.0
│ └── six >=1.9.0
├── ed25519-blake2b >=1.4,<2.0
├── py-sr25519-bindings >=0.1.3,<2.0.0
├── pycryptodome >=3.6,<4.0
├── pynacl >=1.1,<2.0
│ └── cffi >=1.4.1 (circular dependency aborted here)
├── scalecodec >=1.0,<2.0
│ ├── base58 >=2.0.1
│ ├── more-itertools *
│ └── requests >=2.24.0
│ ├── certifi >=2017.4.17
│ ├── charset-normalizer >=2.0.0,<2.1.0
│ ├── idna >=2.5,<4
│ └── urllib3 >=1.21.1,<1.27
└── six >=1.12.0 (circular dependency aborted here)
Hi there. I appreciate the work, would you be able to add in Vergecoin and Signum? Thank-you
Using solana CLI to verify seed
and pub_key
raises an error.
### Code Used in Python
# Generate mnemonic
entropy_bytes = Bip39EntropyGenerator(Bip39EntropyBitLen.BIT_LEN_256).Generate()
mnemonic = Bip39MnemonicGenerator(Bip39Languages.ENGLISH).FromEntropy(entropy_bytes)
print("mnemonic")
print(mnemonic)
>>> "mnemonic"
>>> "sting limb crash ribbon delay close until easily attract dog recipe cake smooth release august found disagree treat want argue salute entire urge describe"
# Generate seed
seed_bytes = Bip39SeedGenerator(mnemonic, Bip39Languages.ENGLISH).Generate()
print("seed without passphrase")
print([x for x in seed_bytes])
>>> "seed without passphrase"
>>> [228, 156, 216, 41, 147, 240, 115, 137, 23, 81, 246, 115, 182, 158, 55, 95, 186, 10, 179, 168, 187, 50, 144, 101, 131, 29, 114, 243, 23, 4, 14, 30, 9, 137, 206, 174, 178, 52, 51, 34, 184, 43, 206, 219, 68, 121, 176, 174, 2, 164, 103, 112, 153, 37, 28, 19, 7, 213, 122, 94, 149, 219, 73, 158]
# Derive a Valid Solana PubKey from seed
bip44_ctx = Bip44.FromSeed(seed_bytes, Bip44Coins.SOLANA).DeriveDefaultPath()
print("bip44_ctx_pubkey")
print(bip44_ctx.PublicKey().ToAddress())
>>> "bip44_ctx_pubkey"
>>> "5cHj95qPtR4Xwo8wBkX3b129D8PApqn64LUh5XMVYFo6"
sh -c "$(curl -sSfL https://release.solana.com/v1.7.3/install)"
seed_array file
is located and run the following command solana-keygen verify <public_key> <file_name_where_seed_array_is_stored>
Using the same output in this example i got the following:
$ solana-keygen verify 5cHj95qPtR4Xwo8wBkX3b129D8PApqn64LUh5XMVYFo6 pytohn_test.json
"Verification for public key: 5cHj95qPtR4Xwo8wBkX3b129D8PApqn64LUh5XMVYFo6: Failed"
If I recover the account using the same mnemonic from the example using the following command:
solana-keygen recover --force ASK
The recovered public_key is the following one
XhYnQXtkTdbycmGvaJ7xBaSzKMpYzLPm7mn36PkRhQ3
If I validate this pub_key
with the seed_array running the command above:
$ solana-keygen verify XhYnQXtkTdbycmGvaJ7xBaSzKMpYzLPm7mn36PkRhQ3 pytohn_test.json
"Verification for public key: XhYnQXtkTdbycmGvaJ7xBaSzKMpYzLPm7mn36PkRhQ3: Success"
Any thoughts on why is it failing?
To my suprise I run into trouble installing bip_utils using pip install bip_utils,
I got it to work in the past, so not sure what the issue is at the moment. Could it be that my Python to new or is this some sort compilatiopn error?
bip_utils) (4.0.0) Building wheels for collected packages: ed25519-blake2b Building wheel for ed25519-blake2b (setup.py): started Building wheel for ed25519-blake2b (setup.py): finished with status 'error' Running setup.py clean for ed25519-blake2b Failed to build ed25519-blake2b Installing collected packages: ed25519-blake2b, crcmod, bip-utils Running setup.py install for ed25519-blake2b: started Running setup.py install for ed25519-blake2b: finished with status 'error'
Hi!
I noticed that in some of the examples you are using binascii.unhexlify()
, but import binascii
is missing. Otherwise you could use bytes.fromhex()
, that requires no import.
Really good job! Kind regards
Hello! First I want to say thank you for great job you've done. Please add support for these tokens (or some of them):
Hello! How to get seed with derived path "m/44'/501'/0'/0'" for using in KeyPair.from_seed() from solana-py library?
I see my phantom wallet address only after:
bip44_mst_ctx = Bip44.FromSeed(seed_bytes, Bip44Coins.SOLANA)
bip44_acc_ctx = bip44_mst_ctx.Purpose().Coin().Account(0)
bip44_chg_ctx = bip44_acc_ctx.Change(Bip44Changes.CHAIN_EXT)
print(f"Address: {bip44_chg_ctx.PublicKey().ToAddress()}")
But how to get deriveSeed (derive_seed_bytes) for KeyPair? I need this to make transactions.
mnemonic = Bip39MnemonicGenerator().FromWordsNumber(Bip39WordsNum.WORDS_NUM_24)
print(f"mnemonic: {mnemonic}")
seed_bytes = Bip39SeedGenerator(mnemonic).Generate()
bip44_ctx = Bip44.FromPrivateKey(seed_bytes[:32], Bip44Coins.SOLANA)
print(bip44_ctx.PublicKey().ToAddress())
https://www.sollet.io/
Restore Existing Wallet with mnemonic
can't find the address,
It looks like seed_bytes is wrong。
Hi,
Can you add a cardano coin support into bip_utils ?
Thanks.
How do I get a hard key?
Hey,
This package is a super nice work. I have this suggestions, to see if you thinks it's possible to implement :)
Thanks for this awesome package.
Regards,
Aleix López
Can this library convert a Ledger recovery phrase to an ALGORAND recovery phrase? If yes, how?
ERROR: Command errored out with exit status 1: /usr/bin/python3 /usr/lib/python3/dist-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-313w608l/overlay --no-warn-script-location --no-binary :all: --only-binary :none: -i https://pypi.org/simple -- 'maturin>=0.12,<0.13' Check the logs for full command output.
Hi, Thanks for your awesome module.
I installed bip_utils on my own PC ( Arch/Manjaro ) and it works just perfect.
But when I try to install it on my RPi 4 (with Raspberry Pi OS), I get errors:
(venv) pi@raspberrypi:~/Desktop/backer $ pip install bip_utils
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting bip_utils
Using cached https://www.piwheels.org/simple/bip-utils/bip_utils-2.1.0-py3-none-any.whl (377 kB)
Collecting pynacl~=1.1
Using cached https://www.piwheels.org/simple/pynacl/PyNaCl-1.4.0-cp39-cp39-linux_armv7l.whl (599 kB)
Collecting pycryptodome~=3.6
Using cached https://www.piwheels.org/simple/pycryptodome/pycryptodome-3.12.0-cp35-abi3-linux_armv7l.whl (1.8 MB)
Collecting py-sr25519-bindings<2.0.0,>=0.1.3
Using cached py_sr25519_bindings-0.1.4.tar.gz (13 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... error
ERROR: Command errored out with exit status 1:
command: /home/pi/Desktop/coinopal_backer/venv/bin/python /tmp/tmpk7ridpje_in_process.py prepare_metadata_for_build_wheel /tmp/tmpaymolx6g
cwd: /tmp/pip-install-c6wxh9ub/py-sr25519-bindings_a7ba08a045b242d78cd2415ac56a67ce
Complete output (6 lines):
Cargo, the Rust package manager, is not installed or is not on PATH.
This package requires Rust and Cargo to compile extensions. Install it through
the system's package manager or via https://rustup.rs/
Checking for Rust toolchain....
----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/64/82/f55600547af686b1ef3db123471493800ce6f9a61ac7a9e355b3bd6360aa/py_sr25519_bindings-0.1.4.tar.gz#sha256=5e12ca977014f148f4bfb6ba662f1529b15cc8ce030719d726c4e16a379e976e (from https://pypi.org/simple/py-sr25519-bindings/). Command errored out with exit status 1: /home/pi/Desktop/coinopal_backer/venv/bin/python /tmp/tmpk7ridpje_in_process.py prepare_metadata_for_build_wheel /tmp/tmpaymolx6g Check the logs for full command output.
Using cached py_sr25519_bindings-0.1.3.tar.gz (13 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... error
ERROR: Command errored out with exit status 1:
command: /home/pi/Desktop/coinopal_backer/venv/bin/python /tmp/tmpb8bxbub1_in_process.py prepare_metadata_for_build_wheel /tmp/tmpx9wmg0wi
cwd: /tmp/pip-install-c6wxh9ub/py-sr25519-bindings_200e206b958348f289959e8c88a18fe5
Complete output (6 lines):
Cargo, the Rust package manager, is not installed or is not on PATH.
This package requires Rust and Cargo to compile extensions. Install it through
the system's package manager or via https://rustup.rs/
Checking for Rust toolchain....
----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/bd/32/1b0dd06842466d2e2f9d6af89752f8aafe4d8f85d7bdc5246cece985eb30/py_sr25519_bindings-0.1.3.tar.gz#sha256=8b72ac823b63adf30cd9596508773b93da5ae4a73fb869e1e27266fb3e7ddaea (from https://pypi.org/simple/py-sr25519-bindings/). Command errored out with exit status 1: /home/pi/Desktop/coinopal_backer/venv/bin/python /tmp/tmpb8bxbub1_in_process.py prepare_metadata_for_build_wheel /tmp/tmpx9wmg0wi Check the logs for full command output.
Collecting bip_utils
Using cached https://www.piwheels.org/simple/bip-utils/bip_utils-2.0.2-py3-none-any.whl (375 kB)
Requirement already satisfied: ecdsa~=0.14 in ./venv/lib/python3.9/site-packages (from bip_utils) (0.17.0)
Using cached https://www.piwheels.org/simple/bip-utils/bip_utils-2.0.1-py3-none-any.whl (370 kB)
Using cached https://www.piwheels.org/simple/bip-utils/bip_utils-2.0.0-py3-none-any.whl (370 kB)
Using cached https://www.piwheels.org/simple/bip-utils/bip_utils-1.11.1-py3-none-any.whl (157 kB)
Requirement already satisfied: pysha3 in ./venv/lib/python3.9/site-packages (from bip_utils) (1.0.2)
Requirement already satisfied: six>=1.9.0 in ./venv/lib/python3.9/site-packages (from ecdsa~=0.14->bip_utils) (1.16.0)
Installing collected packages: bip-utils
Successfully installed bip-utils-1.11.1
I'm trying restore a Bip32Secp256k1 context from a Secp256k1PrivateKey. This fails because the code does not restore the chain code and fingerprints correctly
mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
seed_bytes = Bip39SeedGenerator(mnemonic).Generate()
bip32_ctx1 = Bip32Secp256k1.FromSeedAndPath(seed_bytes, "m/44'/60'/0'/0")
bip32_prvkey1 = bip32_ctx1.PrivateKey()
bip32_pubkey1 = bip32_ctx1.PublicKey()
# Print other BIP32 data
print(bip32_ctx1.Index().ToInt())
print(bip32_ctx1.Depth().ToInt())
print(bip32_ctx1.ChainCode().ToHex())
print(bip32_ctx1.FingerPrint().IsMasterKey())
print(str(bip32_ctx1.FingerPrint()))
print(bip32_ctx1.ParentFingerPrint().IsMasterKey())
print(str(bip32_ctx1.ParentFingerPrint()))
secp256k1_prvkey = Secp256k1PrivateKey.FromBytes(bytes(bip32_prvkey1.Raw()))
assert bip32_prvkey1.Raw().ToHex() == secp256k1_prvkey.Raw().ToHex()
bip32_ctx2 = Bip32Secp256k1.FromPrivateKey(bytes(secp256k1_prvkey.Raw()))
bip32_ctx2 = bip32_ctx2.DerivePath("m/44'/60'/0'/0")
bip32_prvkey2 = bip32_ctx2.PrivateKey()
bip32_pubkey2 = bip32_ctx2.PublicKey()
# assert bip32_prvkey1.Raw().ToHex() == bip32_prvkey2.Raw().ToHex()
# assert bip32_pubkey1.RawCompressed().ToHex() == bip32_pubkey2.RawCompressed().ToHex()
# Print other BIP32 data
print()
print(bip32_ctx2.Index().ToInt())
print(bip32_ctx2.Depth().ToInt())
print(bip32_ctx2.ChainCode().ToHex())
print(bip32_ctx2.FingerPrint().IsMasterKey())
print(str(bip32_ctx2.FingerPrint()))
print(bip32_ctx2.ParentFingerPrint().IsMasterKey())
print(str(bip32_ctx2.ParentFingerPrint()))
Here the print output ...
0
4
c879d136f02003dc804811e42390714ea06448aeaee158c62d65f12a421d988f
False
e4389614
False
60b68b69
0
4
c7d5faabfe9e8aeb976a7bc1d65a64d6749c29243aac0d676e6f357ff0126c3d
False
4b89e1b1
False
8e9ef2a3
Is there a way to do this round-trip via Secp256k1PrivateKey, which I need for Bip38 encryption
I see this module is quite completed and provides many capabilities <round a lot of different blockchains, I'm trying to find a module which allows verifying various signatures from different chains, I'm aware in all of them the signature verification is using EDCSA
I would like to know if this module allows for signature verification given the message, Signature and Publickey?
If so, could you point to the appropriate resource within the module?
Many thanks,
Aleix
Hi.
When will FILECOIN address be supported?
1.How can I get HASH 160 instead of the address from the public key?
Hi
After ibrary update code stopped working. Complete code example gives the following error:
`Traceback (most recent call last):
File "./test.py", line 18, in
bip_obj_acc = bip_obj_mst.Purpose().Coin().Account(0)
File "/home/sergey/Документы/2/bip_utils/bip/bip44.py", line 102, in Purpose
return self._PurposeGeneric(self)
File "/home/sergey/Документы/2/bip_utils/bip/bip44_base.py", line 273, in _PurposeGeneric
return cls(bip_obj.m_bip32.ChildKey(cls._GetPurpose()), bip_obj.m_coin_type)
File "/home/sergey/Документы/2/bip_utils/bip/bip32.py", line 226, in ChildKey
return self.__CkdPriv(index) if not self.m_is_public else self.__CkdPub(index)
File "/home/sergey/Документы/2/bip_utils/bip/bip32.py", line 409, in __CkdPriv
fprint = self.FingerPrint(),
File "/home/sergey/Документы/2/bip_utils/bip/bip32.py", line 356, in FingerPrint
return self.KeyIdentifier()[:Bip32Const.FINGERPRINT_BYTE_LEN]
File "/home/sergey/Документы/2/bip_utils/bip/bip32.py", line 348, in KeyIdentifier
return CryptoUtils.Hash160(self.PublicKey().RawCompressed().ToBytes())
File "/home/sergey/Документы/2/bip_utils/bip/bip_keys.py", line 77, in RawCompressed
return BipKeyBytes(self.m_bip32_obj.EcdsaPublicKey().to_string("compressed"))
TypeError: to_string() takes 1 positional argument but 2 were given
`
How to fix it?
In the examples given in the documentation:
https://pypi.org/project/bip-utils/
it is shown in a table that different coins can be selected for Bip49 just like with Bip44.
With Bip44 everything works as expected. However, there is however no Bip49Coins
in bip_utils.
I did notice there is a Bip49Coin
, so without the 's' at the end, but this does not contain coins you can select.
I made sure to upgrad to bip_utils-1.11.1.
some wallets have more than 20 address in one account, how can get last address index?
For a given mnemonic, I can generate a number of ETH addresses that correspond to what Metamask and MEW show.
From Metamask I can then export the private key to use in uniswap_python
None of the keys that I get through bip44_ctx.PrivateKey().Raw().ToHex()
correspond to the metamask key, nor are they usable with uniswap
Could you pls show how to get a usable private key for these addresses from bip_utils?
roof blush uncover blouse basic retire bundle clinic champion guilt make globe
Metamask: 0xe6d13d33cd3ca24071b640fa0d33cf178006c7c8945f04f5db796bb3c8694482
Master-Key: 0xca557027464a183ebabf3db4497db106c44c341c1599aa191007c38888bc8c64
Account-Key: 0xda875f44f8a5aca81a72d9818d7fb91517409cb5c873ed668227185aa1e94ca1
Change-Key: 0xcadd8f17e40b541384273a5e5602b71eaf11ed34c1a88cf209119c5c7fabe645
m/44'/60'/0'/0/0 - 0xeF869F5f88268FbF9B3698F25A87Ea5B77690D1f
m/44'/60'/0'/0/1 - 0xA5E5D00F828F930d56c0DC7cEb059376dB4A257F
m/44'/60'/0'/0/2 - 0xf38FFAA9578C6935534403109A113aee59799132
m/44'/60'/0'/0/3 - 0xC07a971baCC0157651f46322D594Ef66915aDff8
m/44'/60'/0'/0/4 - 0xa16E4d321053cbA37A8D25cAeaF6b7667E417f14
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.