BIP38
- bip38.bip38.uncompress_public_key(public_key: str | bytes) str
Uncompress public key converter
- Parameters:
public_key (Union[str, bytes]) – Public key
- Returns:
str – Uncompressed public key
>>> from bip38 import uncompress_public_key >>> uncompress_public_key(public_key="0348ca8b4e7c0c75ecfd4b437535d186a12f3027be0c29d2125e9c0dec48677caa") '0448ca8b4e7c0c75ecfd4b437535d186a12f3027be0c29d2125e9c0dec48677caacb4cd50b4c5ea3313a69402c8b0a336b183d39ea18215ff69f59fdb540f00559'
- bip38.bip38.compress_public_key(public_key: str | bytes) str
Compress public key converter
- Parameters:
public_key (Union[str, bytes]) – Public key
- Returns:
str – Compressed public key
>>> from bip38 import compress_public_key >>> compress_public_key(public_key="0448ca8b4e7c0c75ecfd4b437535d186a12f3027be0c29d2125e9c0dec48677caacb4cd50b4c5ea3313a69402c8b0a336b183d39ea18215ff69f59fdb540f00559") '0348ca8b4e7c0c75ecfd4b437535d186a12f3027be0c29d2125e9c0dec48677caa'
- bip38.bip38.private_key_to_public_key(private_key: str | bytes, public_key_type: Literal['uncompressed', 'compressed'] = 'compressed') str
Private key to public key converter
- Parameters:
private_key (Union[str, bytes]) – Private key
public_key_type (Literal["uncompressed", "compressed"]) – Public key type, default to
compressed
- Returns:
str – Public key
>>> from bip38 import private_key_to_public_key >>> private_key_to_public_key(private_key="cbf4b9f70470856bb4f40f80b87edb90865997ffee6df315ab166d713af433a5", public_key_type="compressed") '02d2ce831dd06e5c1f5b1121ef34c2af4bcb01b126e309234adbc3561b60c9360e' >>> private_key_to_public_key(private_key="cbf4b9f70470856bb4f40f80b87edb90865997ffee6df315ab166d713af433a5", public_key_type="uncompressed") '04d2ce831dd06e5c1f5b1121ef34c2af4bcb01b126e309234adbc3561b60c9360ea7f23327b49ba7f10d17fad15f068b8807dbbc9e4ace5d4a0b40264eefaf31a4'
- bip38.bip38.private_key_to_wif(private_key: str | bytes, wif_type: Literal['wif', 'wif-compressed'] = 'wif-compressed', network: Literal['mainnet', 'testnet'] = 'mainnet') str
Private key to WIF (Wallet Important Format) converter
- Parameters:
private_key (Union[str, bytes]) – Private key
wif_type (Literal["wif", "wif-compressed"]) – WIF (Wallet Important Format) type, default to
wif-compressed
network (Literal[“mainnet”, “testnet”], default to
mainnet
) – Network type
- Returns:
str – Wallet Important Format
>>> from bip38 import private_key_to_wif >>> private_key_to_wif(private_key="cbf4b9f70470856bb4f40f80b87edb90865997ffee6df315ab166d713af433a5", network="mainnet", wif_type="wif") '5KN7MzqK5wt2TP1fQCYyHBtDrXdJuXbUzm4A9rKAteGu3Qi5CVR' >>> private_key_to_wif(private_key="cbf4b9f70470856bb4f40f80b87edb90865997ffee6df315ab166d713af433a5", network="mainnet", wif_type="wif-compressed") 'L44B5gGEpqEDRS9vVPz7QT35jcBG2r3CZwSwQ4fCewXAhAhqGVpP' >>> private_key_to_wif(private_key="cbf4b9f70470856bb4f40f80b87edb90865997ffee6df315ab166d713af433a5", network="testnet", wif_type="wif") '938jwjergAxARSWx2YSt9nSBWBz24h8gLhv7EUfgEP1wpMLg6iX' >>> private_key_to_wif(private_key="cbf4b9f70470856bb4f40f80b87edb90865997ffee6df315ab166d713af433a5", network="testnet", wif_type="wif-compressed") 'cURAYbG6FtvUasdBsooEmmY9MqUfhJ8tdybQWV7iA4BAwunCT2Fu'
- bip38.bip38.wif_to_private_key(wif: str) str
WIF (Wallet Important Format) to Private key converter
- Parameters:
wif (str) – Wallet Important Format
- Returns:
str – Private key
>>> from bip38 import wif_to_private_key >>> wif_to_private_key(wif="L44B5gGEpqEDRS9vVPz7QT35jcBG2r3CZwSwQ4fCewXAhAhqGVpP", network="mainnet") 'cbf4b9f70470856bb4f40f80b87edb90865997ffee6df315ab166d713af433a5' >>> wif_to_private_key(wif="5KN7MzqK5wt2TP1fQCYyHBtDrXdJuXbUzm4A9rKAteGu3Qi5CVR", network="mainnet") 'cbf4b9f70470856bb4f40f80b87edb90865997ffee6df315ab166d713af433a5' >>> wif_to_private_key(wif="938jwjergAxARSWx2YSt9nSBWBz24h8gLhv7EUfgEP1wpMLg6iX", network="testnet") 'cbf4b9f70470856bb4f40f80b87edb90865997ffee6df315ab166d713af433a5' >>> wif_to_private_key(wif="cURAYbG6FtvUasdBsooEmmY9MqUfhJ8tdybQWV7iA4BAwunCT2Fu", network="testnet") 'cbf4b9f70470856bb4f40f80b87edb90865997ffee6df315ab166d713af433a5'
- bip38.bip38.get_wif_type(wif: str) Literal['wif', 'wif-compressed']
Get WIF (Wallet Important Format) type
- Parameters:
wif (str) – Wallet Important Format
- Returns:
Literal[“wif”, “wif-compressed”] – WIF type
>>> from bip38 import get_wif_type >>> get_wif_type(wif="5KN7MzqK5wt2TP1fQCYyHBtDrXdJuXbUzm4A9rKAteGu3Qi5CVR") 'wif' >>> get_wif_type(wif="L44B5gGEpqEDRS9vVPz7QT35jcBG2r3CZwSwQ4fCewXAhAhqGVpP") 'wif-compressed' >>> get_wif_type(wif="938jwjergAxARSWx2YSt9nSBWBz24h8gLhv7EUfgEP1wpMLg6iX") 'wif' >>> get_wif_type(wif="cURAYbG6FtvUasdBsooEmmY9MqUfhJ8tdybQWV7iA4BAwunCT2Fu") 'wif-compressed'
- bip38.bip38.get_wif_checksum(wif: str) str
Get WIF (Wallet Important Format) checksum
- Parameters:
wif (str) – Wallet Important Format
- Returns:
str – WIF checksum
>>> from bip38 import get_wif_checksum >>> get_wif_checksum(wif="L44B5gGEpqEDRS9vVPz7QT35jcBG2r3CZwSwQ4fCewXAhAhqGVpP") 'dc37f844' >>> get_wif_checksum(wif="5KN7MzqK5wt2TP1fQCYyHBtDrXdJuXbUzm4A9rKAteGu3Qi5CVR") 'f0a25c0c'
- bip38.bip38.get_wif_network(wif: str) Literal['mainnet', 'testnet']
Get WIF (Wallet Important Format) network type
- Parameters:
wif (str) – Wallet Important Format
- Returns:
Literal[“mainnet”, “testnet”] – Network type
>>> from bip38 import get_wif_network >>> get_wif_network(wif="5KN7MzqK5wt2TP1fQCYyHBtDrXdJuXbUzm4A9rKAteGu3Qi5CVR") 'mainnet' >>> get_wif_network(wif="L44B5gGEpqEDRS9vVPz7QT35jcBG2r3CZwSwQ4fCewXAhAhqGVpP") 'mainnet' >>> get_wif_network(wif="938jwjergAxARSWx2YSt9nSBWBz24h8gLhv7EUfgEP1wpMLg6iX") 'testnet' >>> get_wif_network(wif="cURAYbG6FtvUasdBsooEmmY9MqUfhJ8tdybQWV7iA4BAwunCT2Fu") 'testnet'
- bip38.bip38.public_key_to_addresses(public_key: str | bytes, network: Literal['mainnet', 'testnet'] = 'mainnet') str
Public key to address converter
- Parameters:
public_key (Union[str, bytes]) – Public key
network (Literal[“mainnet”, “testnet”], default to
mainnet
) – Network type
- Returns:
str – Address
>>> from bip38 import public_key_to_addresses >>> public_key_to_addresses(public_key="02d2ce831dd06e5c1f5b1121ef34c2af4bcb01b126e309234adbc3561b60c9360e", network="mainnet") '164MQi977u9GUteHr4EPH27VkkdxmfCvGW' >>> public_key_to_addresses(public_key="04d2ce831dd06e5c1f5b1121ef34c2af4bcb01b126e309234adbc3561b60c9360ea7f23327b49ba7f10d17fad15f068b8807dbbc9e4ace5d4a0b40264eefaf31a4", network="mainnet") '1Jq6MksXQVWzrznvZzxkV6oY57oWXD9TXB' >>> public_key_to_addresses(public_key="02d2ce831dd06e5c1f5b1121ef34c2af4bcb01b126e309234adbc3561b60c9360e", network="testnet") 'mkaJhmE5vvaXG17uZdCm6wKpckEfnG4yt9' >>> public_key_to_addresses(public_key="04d2ce831dd06e5c1f5b1121ef34c2af4bcb01b126e309234adbc3561b60c9360ea7f23327b49ba7f10d17fad15f068b8807dbbc9e4ace5d4a0b40264eefaf31a4", network="testnet") 'myM3eoxWDWxFe7GYHZw8K21rw7QDNZeDYM'
- bip38.bip38.intermediate_code(passphrase: str, lot: int | None = None, sequence: int | None = None, owner_salt: str | bytes = b'\x9dfJ\xbd(\xfc<4') str
Intermediate passphrase generator
- Parameters:
passphrase (str) – Passphrase or password text
lot (Optional[int]) – Lot number between 100000 <= lot <= 999999 range, default to
None
sequence (Optional[int]) – Sequence number between 0 <= sequence <= 4095 range, default to
None
owner_salt (Optional[str, bytes]) – Owner salt, default to
os.urandom(8)
- Returns:
str – Intermediate passphrase
>>> from bip38 import intermediate_code >>> intermediate_code(passphrase="TestingOneTwoThree") 'passphraseqVKbgU4mWMakKGgCtaeVWoETQdzMBy5696bG2w7ckVBeQmoLhMF9vLaxhmzhT3' >>> intermediate_code(passphrase="TestingOneTwoThree", lot=199999, sequence=1, owner_salt="75ed1cdeb254cb38") 'passphraseb7ruSN4At4Rb8hPTNcAVezfsjonvUs4Qo3xSp1fBFsFPvVGSbpP2WTJMhw3mVZ'
- bip38.bip38.bip38_encrypt(wif: str, passphrase: str, network: Literal['mainnet', 'testnet'] = 'mainnet') str
BIP38 Encrypt WIF (Wallet Important Format) using passphrase/password
- Parameters:
wif (str) – Wallet important format
passphrase (str) – Passphrase or password text
network (Literal[“mainnet”, “testnet”], default to
mainnet
) – Network type
- Returns:
str – Encrypted WIF (Wallet Important Format)
>>> from bip38 import bip38_encrypt >>> bip38_encrypt(wif="5KN7MzqK5wt2TP1fQCYyHBtDrXdJuXbUzm4A9rKAteGu3Qi5CVR", passphrase="TestingOneTwoThree") '6PRVWUbkzzsbcVac2qwfssoUJAN1Xhrg6bNk8J7Nzm5H7kxEbn2Nh2ZoGg' >>> bip38_encrypt(wif="L44B5gGEpqEDRS9vVPz7QT35jcBG2r3CZwSwQ4fCewXAhAhqGVpP", passphrase="TestingOneTwoThree") '6PYNKZ1EAgYgmQfmNVamxyXVWHzK5s6DGhwP4J5o44cvXdoY7sRzhtpUeo' >>> bip38_encrypt(wif="938jwjergAxARSWx2YSt9nSBWBz24h8gLhv7EUfgEP1wpMLg6iX", passphrase="TestingOneTwoThree") '6PRVWUbkzzsbcVac2qwfssoUJAN1Xhrg6bNk8J7Nzm5H7kxEbn2Nh2ZoGg' >>> bip38_encrypt(wif="cURAYbG6FtvUasdBsooEmmY9MqUfhJ8tdybQWV7iA4BAwunCT2Fu", passphrase="TestingOneTwoThree") '6PRVWUbkzzsbcVac2qwfssoUJAN1Xhrg6bNk8J7Nzm5H7kxEbn2Nh2ZoGg'
- bip38.bip38.create_new_encrypted_wif(intermediate_passphrase: str, public_key_type: Literal['uncompressed', 'compressed'] = 'uncompressed', seed: str | bytes = b"\xf2\xbc\xdb_\x13V\xcbe\x0eUG&\xf6\x18'_\x9e\x10$\x14`\n\x12\x1f", network: Literal['mainnet', 'testnet'] = 'mainnet') dict
Create new encrypted WIF (Wallet Important Format)
- Parameters:
intermediate_passphrase (str) – Intermediate passphrase text
public_key_type (Literal["uncompressed", "compressed"]) – Public key type, default to
uncompressed
seed (Optional[str, bytes]) – Seed, default to
os.urandom(24)
network (Literal[“mainnet”, “testnet”], default to
mainnet
) – Network type
- Returns:
dict – Encrypted WIF (Wallet Important Format)
>>> from bip38 import create_new_encrypted_wif >>> create_new_encrypted_wif(intermediate_passphrase="passphraseb7ruSN4At4Rb8hPTNcAVezfsjonvUs4Qo3xSp1fBFsFPvVGSbpP2WTJMhw3mVZ", network="testnet", public_key_type="uncompressed") {'encrypted_wif': '6PgMqVygYm6reoPXjsUPxtPDhExjFtUFfHAPYM5svyzVKQmDR1hRy2kgu8', 'confirmation_code': 'cfrm38V8ZQSdCuzcrYYKGNXVwbHgdjsUEfAbFGoEUouB4YEKaXVdFiMcBWai1Exdu8jN7DcoKtM', 'public_key': '04cb64d6e93174b827d3c54965cff210348888bf959f8e198f2483ff9d61d7de3f938e11b7198455fde1f1dea7d3823cc71cbe4c5ac46a71f3931cd6cdd2193bac', 'seed': 'b8e9e1178307d5863d011a25f4d887f61d3b2531a990fe37', 'public_key_type': 'uncompressed', 'address': 'mwW38M23zvDmhbsTdnVFzw3bVnueDhrKec'} >>> create_new_encrypted_wif(intermediate_passphrase="passphraseb7ruSN4At4Rb8hPTNcAVezfsjonvUs4Qo3xSp1fBFsFPvVGSbpP2WTJMhw3mVZ", network="mainnet", public_key_type="compressed", seed="99241d58245c883896f80843d2846672d7312e6195ca1a6c") {'encrypted_wif': '6PoM8coZNg4AGPhQs91RbmmRmfLz6kmnU3XUGGLQxsJ5xN62LsUzMWYcdP', 'confirmation_code': 'cfrm38VXL5T6qVke13sHUWtEjibAkK1RquBqMXb2azCv1Zna6JKvBhD1Gf2b15wBj7UPv2BQnf6', 'public_key': '02100bb0440ff4106a1743750813271e66a7017431e92921e520319f537c7357c1', 'seed': '99241d58245c883896f80843d2846672d7312e6195ca1a6c', 'public_key_type': 'compressed', 'address': '15PuNwFmDqYhRsC9MDPNFvNY4Npzibm67c'}
- bip38.bip38.confirm_code(passphrase: str, confirmation_code: str, network: Literal['mainnet', 'testnet'] = 'mainnet', detail: bool = False) str | dict
Confirm passphrase
- Parameters:
passphrase (str) – Passphrase or password text
confirmation_code (str) – Confirmation code
network (Literal[“mainnet”, “testnet”], default to
mainnet
) – Network typedetail (bool) – To show in detail, default to
False
- Returns:
Union[str, dict] – Confirmation of address info’s
>>> from bip38 import confirm_code >>> confirm_code(passphrase="TestingOneTwoThree", confirmation_code="cfrm38V8ZQSdCuzcrYYKGNXVwbHgdjsUEfAbFGoEUouB4YEKaXVdFiMcBWai1Exdu8jN7DcoKtM", network="testnet") 'mwW38M23zvDmhbsTdnVFzw3bVnueDhrKec' >>> confirm_code(passphrase="TestingOneTwoThree", confirmation_code="cfrm38V8Foq3WpRPMXJD34SF6pGT6ht5ihYMWWMbezkzHgPpA1jVkfbTHwQzvuSA4ReF86PHZJY", network="mainnet") '1JbyXoVN4hXWirGB265q9VE4pQ6qbY6kmr' >>> confirm_code(passphrase="TestingOneTwoThree", confirmation_code="cfrm38VXL5T6qVke13sHUWtEjibAkK1RquBqMXb2azCv1Zna6JKvBhD1Gf2b15wBj7UPv2BQnf6", network="mainnet", detail=True) {'public_key': '02100bb0440ff4106a1743750813271e66a7017431e92921e520319f537c7357c1', 'public_key_type': 'compressed', 'address': '15PuNwFmDqYhRsC9MDPNFvNY4Npzibm67c', 'lot': 199999, 'sequence': 1}
- bip38.bip38.bip38_decrypt(encrypted_wif: str, passphrase: str, network: Literal['mainnet', 'testnet'] = 'mainnet', detail: bool = False) str | dict
BIP38 Decrypt encrypted WIF (Wallet Important Format) using passphrase/password
- Parameters:
encrypted_wif (str) – Encrypted WIF (Wallet Important Format)
passphrase (str) – Passphrase or password text
network (Literal[“mainnet”, “testnet”], default to
mainnet
) – Network typedetail (bool) – To show in detail, default to
False
- Returns:
Union[str, dict] – WIF or All private Key info’s
>>> from bip38 import bip38_decrypt >>> bip38_decrypt(encrypted_wif="6PRVWUbkzzsbcVac2qwfssoUJAN1Xhrg6bNk8J7Nzm5H7kxEbn2Nh2ZoGg", passphrase="TestingOneTwoThree", network="mainnet") '5KN7MzqK5wt2TP1fQCYyHBtDrXdJuXbUzm4A9rKAteGu3Qi5CVR' >>> bip38_decrypt(encrypted_wif="6PRL8jj6dLQjBBJjHMdUKLSNLEpjTyAfmt8GnCnfT87NeQ2BU5eAW1tcsS", passphrase="TestingOneTwoThree", network="testnet") '938jwjergAxARSWx2YSt9nSBWBz24h8gLhv7EUfgEP1wpMLg6iX' >>> bip38_decrypt(encrypted_wif="6PRVWUbkzzsbcVac2qwfssoUJAN1Xhrg6bNk8J7Nzm5H7kxEbn2Nh2ZoGg", passphrase="TestingOneTwoThree", network="mainnet", detail=True) {'wif': '5KN7MzqK5wt2TP1fQCYyHBtDrXdJuXbUzm4A9rKAteGu3Qi5CVR', 'private_key': 'cbf4b9f70470856bb4f40f80b87edb90865997ffee6df315ab166d713af433a5', 'wif_type': 'wif', 'public_key': '04d2ce831dd06e5c1f5b1121ef34c2af4bcb01b126e309234adbc3561b60c9360ea7f23327b49ba7f10d17fad15f068b8807dbbc9e4ace5d4a0b40264eefaf31a4', 'public_key_type': 'uncompressed', 'seed': None, 'address': '1Jq6MksXQVWzrznvZzxkV6oY57oWXD9TXB', 'lot': None, 'sequence': None} >>> bip38_decrypt(encrypted_wif="6PRL8jj6dLQjBBJjHMdUKLSNLEpjTyAfmt8GnCnfT87NeQ2BU5eAW1tcsS", passphrase="TestingOneTwoThree", network="testnet", detail=True) {'wif': '938jwjergAxARSWx2YSt9nSBWBz24h8gLhv7EUfgEP1wpMLg6iX', 'private_key': 'cbf4b9f70470856bb4f40f80b87edb90865997ffee6df315ab166d713af433a5', 'wif_type': 'wif', 'public_key': '04d2ce831dd06e5c1f5b1121ef34c2af4bcb01b126e309234adbc3561b60c9360ea7f23327b49ba7f10d17fad15f068b8807dbbc9e4ace5d4a0b40264eefaf31a4', 'public_key_type': 'uncompressed', 'seed': None, 'address': 'myM3eoxWDWxFe7GYHZw8K21rw7QDNZeDYM', 'lot': None, 'sequence': None}