cryptnox_cli.lib.cryptos package

Subpackages

Submodules

cryptnox_cli.lib.cryptos.blocks module

Block header encoding/decoding utilities and related primitives.

cryptnox_cli.lib.cryptos.blocks.serialize_header(inp)[source]
cryptnox_cli.lib.cryptos.blocks.deserialize_header(inp)[source]
cryptnox_cli.lib.cryptos.blocks.mk_merkle_proof(header, hashes, index)[source]

cryptnox_cli.lib.cryptos.composite module

High-level composition utilities combining deterministic keys and transactions.

cryptnox_cli.lib.cryptos.composite.bip32_hdm_script(*args)[source]
cryptnox_cli.lib.cryptos.composite.bip32_hdm_addr(*args)[source]
cryptnox_cli.lib.cryptos.composite.setup_coinvault_tx(tx, script)[source]
cryptnox_cli.lib.cryptos.composite.sign_coinvault_tx(tx, priv)[source]

cryptnox_cli.lib.cryptos.constants module

Core constants and magic values used across cryptocurrency modules.

cryptnox_cli.lib.cryptos.deterministic module

Deterministic key and path derivation utilities (BIP32-like logic).

cryptnox_cli.lib.cryptos.deterministic.electrum_stretch(seed)[source]
cryptnox_cli.lib.cryptos.deterministic.electrum_mpk(seed)[source]
cryptnox_cli.lib.cryptos.deterministic.electrum_privkey(seed, n, for_change=0)[source]
cryptnox_cli.lib.cryptos.deterministic.electrum_pubkey(masterkey, n, for_change=0)[source]
cryptnox_cli.lib.cryptos.deterministic.electrum_address(masterkey, n, for_change=0, magicbyte=0)[source]
cryptnox_cli.lib.cryptos.deterministic.crack_electrum_wallet(mpk, pk, n, for_change=0)[source]
cryptnox_cli.lib.cryptos.deterministic.raw_bip32_ckd(rawtuple, i, prefixes=DEFAULT)[source]
cryptnox_cli.lib.cryptos.deterministic.bip32_serialize(rawtuple, prefixes=DEFAULT)[source]
cryptnox_cli.lib.cryptos.deterministic.bip32_deserialize(data, prefixes=DEFAULT)[source]
cryptnox_cli.lib.cryptos.deterministic.is_xprv(text, prefixes=DEFAULT)[source]
cryptnox_cli.lib.cryptos.deterministic.is_xpub(text, prefixes=DEFAULT)[source]
cryptnox_cli.lib.cryptos.deterministic.raw_bip32_privtopub(rawtuple, prefixes=DEFAULT)[source]
cryptnox_cli.lib.cryptos.deterministic.bip32_privtopub(data, prefixes=DEFAULT)[source]
cryptnox_cli.lib.cryptos.deterministic.bip32_ckd(key, path, prefixes=DEFAULT, public=False)[source]
cryptnox_cli.lib.cryptos.deterministic.bip32_master_key(seed, prefixes=DEFAULT)[source]
cryptnox_cli.lib.cryptos.deterministic.bip32_bin_extract_key(data, prefixes=DEFAULT)[source]
cryptnox_cli.lib.cryptos.deterministic.bip32_extract_key(data, prefixes=DEFAULT)[source]
cryptnox_cli.lib.cryptos.deterministic.bip32_derive_key(key, path, prefixes=DEFAULT, **kwargs)[source]
cryptnox_cli.lib.cryptos.deterministic.raw_crack_bip32_privkey(parent_pub, priv, prefixes=DEFAULT)[source]
cryptnox_cli.lib.cryptos.deterministic.crack_bip32_privkey(parent_pub, priv, prefixes=DEFAULT)[source]
cryptnox_cli.lib.cryptos.deterministic.coinvault_pub_to_bip32(*args, prefixes=DEFAULT)[source]
cryptnox_cli.lib.cryptos.deterministic.coinvault_priv_to_bip32(*args, prefixes=DEFAULT)[source]
cryptnox_cli.lib.cryptos.deterministic.bip32_descend(*args, prefixes=DEFAULT)[source]

Descend masterkey and return privkey

cryptnox_cli.lib.cryptos.deterministic.parse_bip32_path(path)[source]

Takes bip32 path, “m/0’/2H” or “m/0H/1/2H/2/1000000000.pub”, returns list of ints

cryptnox_cli.lib.cryptos.keystore module

HD wallet structures, serialization, derivation, and key store helpers.

class cryptnox_cli.lib.cryptos.keystore.KeyStore(coin, addresses=())[source]

Bases: object

__init__(coin, addresses=())[source]
has_seed()[source]
is_watching_only()[source]
can_import()[source]
get_tx_derivations(tx)[source]
can_sign(tx)[source]
class cryptnox_cli.lib.cryptos.keystore.Software_KeyStore(coin, addresses=())[source]

Bases: KeyStore

may_have_password()[source]
class cryptnox_cli.lib.cryptos.keystore.Imported_KeyStore(d, coin)[source]

Bases: Software_KeyStore

__init__(d, coin)[source]
is_deterministic()[source]
can_change_password()[source]
get_master_public_key()[source]
dump()[source]
can_import()[source]
check_password(password=None)[source]
import_privkey(sec, password=None)[source]
delete_imported_key(key)[source]
get_private_key(pubkey, password=None)[source]
get_pubkey_derivation(x_pubkey)[source]
update_password(old_password, new_password)[source]
class cryptnox_cli.lib.cryptos.keystore.Deterministic_KeyStore(d, coin)[source]

Bases: Software_KeyStore

__init__(d, coin)[source]
is_deterministic()[source]
dump()[source]
has_seed()[source]
is_watching_only()[source]
can_change_password()[source]
add_seed(seed)[source]
get_seed(password)[source]
get_passphrase(password)[source]
class cryptnox_cli.lib.cryptos.keystore.Xpub[source]

Bases: object

__init__()[source]
get_master_public_key()[source]
derive_pubkey(for_change, n)[source]
classmethod get_pubkey_from_xpub(xpub, sequence, bip39_prefixes)[source]
class cryptnox_cli.lib.cryptos.keystore.BIP32_KeyStore(d, coin)[source]

Bases: Deterministic_KeyStore, Xpub

__init__(d, coin)[source]
format_seed(seed)[source]
dump()[source]
get_master_private_key(password=None)[source]
check_password(password=None)[source]
update_password(old_password, new_password)[source]
is_watching_only()[source]
add_xprv(xprv)[source]
add_xpub(xpub, xtype, electrum=False)[source]
add_xprv_from_seed(bip32_seed, xtype, derivation, electrum=False)[source]
get_private_key(sequence, password)[source]
class cryptnox_cli.lib.cryptos.keystore.Hardware_KeyStore(d, coin)[source]

Bases: KeyStore, Xpub

max_change_outputs = 1
__init__(d, coin)[source]
set_label(label)[source]
may_have_password()[source]
is_deterministic()[source]
dump()[source]
unpaired()[source]

A device paired with the wallet was diconnected. This can be called in any thread context.

paired()[source]

A device paired with the wallet was (re-)connected. This can be called in any thread context.

can_export()[source]
is_watching_only()[source]

The wallet is not watching-only; the user will be prompted for pin and passphrase as appropriate when needed.

can_change_password()[source]
cryptnox_cli.lib.cryptos.keystore.bip39_to_seed(mnemonic, passphrase)[source]
cryptnox_cli.lib.cryptos.keystore.bip39_is_checksum_valid(mnemonic)[source]
cryptnox_cli.lib.cryptos.keystore.from_bip39_seed(seed, passphrase, derivation, coin)[source]
cryptnox_cli.lib.cryptos.keystore.standard_from_bip39_seed(seed, passphrase, coin)[source]
cryptnox_cli.lib.cryptos.keystore.p2wpkh_from_bip39_seed(seed, passphrase, coin)[source]
cryptnox_cli.lib.cryptos.keystore.p2wpkh_p2sh_from_bip39_seed(seed, passphrase, coin)[source]
cryptnox_cli.lib.cryptos.keystore.xtype_from_derivation(derivation)[source]

Returns the script type to be used for this derivation.

cryptnox_cli.lib.cryptos.keystore.is_xpubkey(x_pubkey)[source]
cryptnox_cli.lib.cryptos.keystore.parse_xpubkey(x_pubkey)[source]
cryptnox_cli.lib.cryptos.keystore.xpubkey_to_address(x_pubkey, coin)[source]
cryptnox_cli.lib.cryptos.keystore.xpubkey_to_pubkey(x_pubkey, coin)[source]
cryptnox_cli.lib.cryptos.keystore.register_keystore(hw_type, constructor)[source]
cryptnox_cli.lib.cryptos.keystore.hardware_keystore(d)[source]
cryptnox_cli.lib.cryptos.keystore.is_address_list(text, coin)[source]
cryptnox_cli.lib.cryptos.keystore.get_private_keys(text)[source]
cryptnox_cli.lib.cryptos.keystore.is_private_key_list(text)[source]
cryptnox_cli.lib.cryptos.keystore.is_private(x)
cryptnox_cli.lib.cryptos.keystore.is_master_key(x)
cryptnox_cli.lib.cryptos.keystore.is_private_key(x)
cryptnox_cli.lib.cryptos.keystore.is_bip32_key(x)
cryptnox_cli.lib.cryptos.keystore.from_electrum_seed(seed, passphrase, is_p2sh, coin)[source]
cryptnox_cli.lib.cryptos.keystore.from_private_key_list(text, coin)[source]
cryptnox_cli.lib.cryptos.keystore.from_xpub(xpub, coin, xtype, electrum=False)[source]
cryptnox_cli.lib.cryptos.keystore.from_xprv(xprv, coin)[source]
cryptnox_cli.lib.cryptos.keystore.from_master_key(text, coin)[source]

cryptnox_cli.lib.cryptos.main module

Core cryptographic and encoding primitives used by higher-level modules.

This module is based on code from pybitcointools: https://github.com/primal100/pybitcointools/blob/master/cryptos/main.py

cryptnox_cli.lib.cryptos.main.change_curve(p, n, a, b, gx, gy)[source]
cryptnox_cli.lib.cryptos.main.getG()[source]
cryptnox_cli.lib.cryptos.main.inv(a, n)[source]
cryptnox_cli.lib.cryptos.main.access(obj, prop)[source]
cryptnox_cli.lib.cryptos.main.multiaccess(obj, prop)[source]
cryptnox_cli.lib.cryptos.main.slice(obj, start=0, end=2**200)[source]
cryptnox_cli.lib.cryptos.main.count(obj)[source]
cryptnox_cli.lib.cryptos.main.sum(obj)[source]
cryptnox_cli.lib.cryptos.main.isinf(p)[source]
cryptnox_cli.lib.cryptos.main.to_jacobian(p)[source]
cryptnox_cli.lib.cryptos.main.jacobian_double(p)[source]
cryptnox_cli.lib.cryptos.main.jacobian_add(p, q)[source]
cryptnox_cli.lib.cryptos.main.from_jacobian(p)[source]
cryptnox_cli.lib.cryptos.main.jacobian_multiply(a, n)[source]
cryptnox_cli.lib.cryptos.main.fast_multiply(a, n)[source]
cryptnox_cli.lib.cryptos.main.fast_add(a, b)[source]
cryptnox_cli.lib.cryptos.main.get_pubkey_format(pub)[source]
cryptnox_cli.lib.cryptos.main.encode_pubkey(pub, formt)[source]
cryptnox_cli.lib.cryptos.main.decode_pubkey(pub, formt=None)[source]
cryptnox_cli.lib.cryptos.main.get_privkey_format(priv)[source]
cryptnox_cli.lib.cryptos.main.encode_privkey(priv, formt, vbyte=128)[source]
cryptnox_cli.lib.cryptos.main.decode_privkey(priv, formt=None)[source]
cryptnox_cli.lib.cryptos.main.add_pubkeys(p1, p2)[source]
cryptnox_cli.lib.cryptos.main.add_privkeys(p1, p2)[source]
cryptnox_cli.lib.cryptos.main.mul_privkeys(p1, p2)[source]
cryptnox_cli.lib.cryptos.main.multiply(pubkey, privkey)[source]
cryptnox_cli.lib.cryptos.main.divide(pubkey, privkey)[source]
cryptnox_cli.lib.cryptos.main.compress(pubkey)[source]
cryptnox_cli.lib.cryptos.main.decompress(pubkey)[source]
cryptnox_cli.lib.cryptos.main.privkey_to_pubkey(privkey)[source]
cryptnox_cli.lib.cryptos.main.privtopub(privkey)
cryptnox_cli.lib.cryptos.main.privkey_to_address(priv, magicbyte=0)[source]
cryptnox_cli.lib.cryptos.main.privtoaddr(priv, magicbyte=0)
cryptnox_cli.lib.cryptos.main.neg_pubkey(pubkey)[source]
cryptnox_cli.lib.cryptos.main.neg_privkey(privkey)[source]
cryptnox_cli.lib.cryptos.main.subtract_pubkeys(p1, p2)[source]
cryptnox_cli.lib.cryptos.main.subtract_privkeys(p1, p2)[source]
cryptnox_cli.lib.cryptos.main.bin_hash160(string)[source]
cryptnox_cli.lib.cryptos.main.hash160(string)[source]
cryptnox_cli.lib.cryptos.main.hex_to_hash160(s_hex)[source]
cryptnox_cli.lib.cryptos.main.bin_sha256(string)[source]
cryptnox_cli.lib.cryptos.main.sha256(string)[source]
cryptnox_cli.lib.cryptos.main.bin_ripemd160(string)[source]
cryptnox_cli.lib.cryptos.main.ripemd160(string)[source]
cryptnox_cli.lib.cryptos.main.bin_dbl_sha256(s)[source]
cryptnox_cli.lib.cryptos.main.dbl_sha256(string)[source]
cryptnox_cli.lib.cryptos.main.bin_slowsha(string)[source]
cryptnox_cli.lib.cryptos.main.slowsha(string)[source]
cryptnox_cli.lib.cryptos.main.hash_to_int(x)[source]
cryptnox_cli.lib.cryptos.main.num_to_var_int(x)[source]
cryptnox_cli.lib.cryptos.main.electrum_sig_hash(message)[source]
cryptnox_cli.lib.cryptos.main.random_key()[source]
cryptnox_cli.lib.cryptos.main.random_electrum_seed()[source]
cryptnox_cli.lib.cryptos.main.b58check_to_bin(inp)[source]
cryptnox_cli.lib.cryptos.main.get_version_byte(inp)[source]
cryptnox_cli.lib.cryptos.main.hex_to_b58check(inp, magicbyte=0)[source]
cryptnox_cli.lib.cryptos.main.b58check_to_hex(inp)[source]
cryptnox_cli.lib.cryptos.main.pubkey_to_hash(pubkey)[source]
cryptnox_cli.lib.cryptos.main.pubkey_to_hash_hex(pubkey)[source]
cryptnox_cli.lib.cryptos.main.pubkey_to_address(pubkey, magicbyte=0)[source]
cryptnox_cli.lib.cryptos.main.pubtoaddr(pubkey, magicbyte=0)
cryptnox_cli.lib.cryptos.main.is_privkey(priv)[source]
cryptnox_cli.lib.cryptos.main.is_pubkey(pubkey)[source]
cryptnox_cli.lib.cryptos.main.encode_sig(v, r, s)[source]
cryptnox_cli.lib.cryptos.main.decode_sig(sig)[source]
cryptnox_cli.lib.cryptos.main.deterministic_generate_k(msghash, priv)[source]
cryptnox_cli.lib.cryptos.main.ecdsa_raw_sign(msghash, priv)[source]
cryptnox_cli.lib.cryptos.main.ecdsa_sign(msg, priv, coin)[source]
cryptnox_cli.lib.cryptos.main.ecdsa_raw_verify(msghash, vrs, pub)[source]
cryptnox_cli.lib.cryptos.main.ecdsa_verify_addr(msg, sig, addr, coin)[source]
cryptnox_cli.lib.cryptos.main.ecdsa_verify(msg, sig, pub, coin)[source]
cryptnox_cli.lib.cryptos.main.ecdsa_raw_recover(msghash, vrs)[source]
cryptnox_cli.lib.cryptos.main.ecdsa_recover(msg, sig)[source]
cryptnox_cli.lib.cryptos.main.add(p1, p2)[source]
cryptnox_cli.lib.cryptos.main.subtract(p1, p2)[source]
cryptnox_cli.lib.cryptos.main.magicbyte_to_prefix(magicbyte)[source]

cryptnox_cli.lib.cryptos.mnemonic module

Mnemonic phrase generation and seed handling (BIP39-style operations).

This module is based on code from pybtctools: https://github.com/danvergara/pybtctools/blob/master/bitcoin/mnemonic.py

cryptnox_cli.lib.cryptos.mnemonic.is_CJK(c)[source]
cryptnox_cli.lib.cryptos.mnemonic.normalize_text(seed)[source]
cryptnox_cli.lib.cryptos.mnemonic.eint_to_bytes(entint, entbits)[source]
cryptnox_cli.lib.cryptos.mnemonic.mnemonic_int_to_words(mint, mint_num_words, wordlist=wordlist_english)[source]
cryptnox_cli.lib.cryptos.mnemonic.entropy_cs(entbytes)[source]
cryptnox_cli.lib.cryptos.mnemonic.entropy_to_words(entbytes, wordlist=wordlist_english)[source]
cryptnox_cli.lib.cryptos.mnemonic.words_bisect(word, wordlist=wordlist_english)[source]
cryptnox_cli.lib.cryptos.mnemonic.words_split(wordstr, wordlist=wordlist_english)[source]
cryptnox_cli.lib.cryptos.mnemonic.words_to_mnemonic_int(words, wordlist=wordlist_english)[source]
cryptnox_cli.lib.cryptos.mnemonic.words_verify(words, wordlist=wordlist_english)[source]
cryptnox_cli.lib.cryptos.mnemonic.bip39_normalize_passphrase(passphrase)[source]
cryptnox_cli.lib.cryptos.mnemonic.bip39_is_checksum_valid(mnemonic)[source]
cryptnox_cli.lib.cryptos.mnemonic.mnemonic_to_seed(mnemonic_phrase, passphrase='', passphrase_prefix=b'mnemonic')[source]
cryptnox_cli.lib.cryptos.mnemonic.bip39_mnemonic_to_seed(mnemonic_phrase, passphrase='')[source]
cryptnox_cli.lib.cryptos.mnemonic.electrum_mnemonic_to_seed(mnemonic_phrase, passphrase='')[source]
cryptnox_cli.lib.cryptos.mnemonic.is_old_seed(seed)[source]
cryptnox_cli.lib.cryptos.mnemonic.seed_prefix(seed_type)[source]
cryptnox_cli.lib.cryptos.mnemonic.seed_type(x)[source]
cryptnox_cli.lib.cryptos.mnemonic.is_seed(x)
cryptnox_cli.lib.cryptos.mnemonic.words_mine(prefix, entbits, satisfunction, wordlist=wordlist_english, randombits=random.getrandbits)[source]

cryptnox_cli.lib.cryptos.pbkdf2 module

PBKDF2 key derivation function implementation and helpers.

cryptnox_cli.lib.cryptos.pbkdf2.isunicode(s)[source]
cryptnox_cli.lib.cryptos.pbkdf2.isbytes(s)[source]
cryptnox_cli.lib.cryptos.pbkdf2.isinteger(n)[source]
cryptnox_cli.lib.cryptos.pbkdf2.callable(obj)[source]
cryptnox_cli.lib.cryptos.pbkdf2.b(s)[source]
cryptnox_cli.lib.cryptos.pbkdf2.binxor(a, b)[source]
cryptnox_cli.lib.cryptos.pbkdf2.b64encode(data, chars='+/')[source]
cryptnox_cli.lib.cryptos.pbkdf2.b2a_hex(s)[source]
class cryptnox_cli.lib.cryptos.pbkdf2.PBKDF2(passphrase, salt, iterations=1000, digestmodule=SHA1, macmodule=HMAC)[source]

Bases: object

__init__(passphrase, salt, iterations=1000, digestmodule=SHA1, macmodule=HMAC)[source]
static crypt(word, salt=None, iterations=None)

PBKDF2-based unix crypt(3) replacement.

The number of iterations specified in the salt overrides the ‘iterations’ parameter.

The effective hash length is 192 bits.

read(bytes)[source]

Read the specified number of key bytes.

hexread(octets)[source]

Read the specified number of octets. Return them as hexadecimal.

Note that len(obj.hexread(n)) == 2*n.

close()[source]

Close the stream.

cryptnox_cli.lib.cryptos.pbkdf2.crypt(word, salt=None, iterations=None)[source]

PBKDF2-based unix crypt(3) replacement.

The number of iterations specified in the salt overrides the ‘iterations’ parameter.

The effective hash length is 192 bits.

cryptnox_cli.lib.cryptos.ripemd module

RIPEMD-160 hash function implementation in pure Python.

class cryptnox_cli.lib.cryptos.ripemd.RIPEMD160(arg=None)[source]

Bases: object

Return a new RIPEMD160 object. An optional string argument may be provided; if present, this string will be automatically hashed.

__init__(arg=None)[source]
update(arg)[source]
digest()[source]
hexdigest()[source]
copy()[source]
cryptnox_cli.lib.cryptos.ripemd.new(arg=None)[source]

Return a new RIPEMD160 object. An optional string argument may be provided; if present, this string will be automatically hashed.

class cryptnox_cli.lib.cryptos.ripemd.RMDContext[source]

Bases: object

__init__()[source]
copy()[source]
cryptnox_cli.lib.cryptos.ripemd.ROL(n, x)[source]
cryptnox_cli.lib.cryptos.ripemd.F0(x, y, z)[source]
cryptnox_cli.lib.cryptos.ripemd.F1(x, y, z)[source]
cryptnox_cli.lib.cryptos.ripemd.F2(x, y, z)[source]
cryptnox_cli.lib.cryptos.ripemd.F3(x, y, z)[source]
cryptnox_cli.lib.cryptos.ripemd.F4(x, y, z)[source]
cryptnox_cli.lib.cryptos.ripemd.R(a, b, c, d, e, Fj, Kj, sj, rj, X)[source]
cryptnox_cli.lib.cryptos.ripemd.RMD160Transform(state, block)[source]
cryptnox_cli.lib.cryptos.ripemd.RMD160Update(ctx, inp, inplen)[source]
cryptnox_cli.lib.cryptos.ripemd.RMD160Final(ctx)[source]

cryptnox_cli.lib.cryptos.segwit_addr module

SegWit address encoding/decoding utilities (bech32/bech32m).

cryptnox_cli.lib.cryptos.segwit_addr.bech32_polymod(values)[source]

Internal function that computes the Bech32 checksum.

cryptnox_cli.lib.cryptos.segwit_addr.bech32_hrp_expand(hrp)[source]

Expand the HRP into values for checksum computation.

cryptnox_cli.lib.cryptos.segwit_addr.bech32_verify_checksum(hrp, data)[source]

Verify a checksum given HRP and converted data characters.

cryptnox_cli.lib.cryptos.segwit_addr.bech32_create_checksum(hrp, data)[source]

Compute the checksum values given HRP and data.

cryptnox_cli.lib.cryptos.segwit_addr.bech32_encode(hrp, data)[source]

Compute a Bech32 string given HRP and data values.

cryptnox_cli.lib.cryptos.segwit_addr.bech32_decode(bech)[source]

Validate a Bech32 string, and determine HRP and data.

cryptnox_cli.lib.cryptos.segwit_addr.convertbits(data, frombits, tobits, pad=True)[source]

General power-of-2 base conversion.

cryptnox_cli.lib.cryptos.segwit_addr.decode(hrp, addr)[source]

Decode a segwit address.

cryptnox_cli.lib.cryptos.segwit_addr.encode(hrp, witver, witprog)[source]

Encode a segwit address.

cryptnox_cli.lib.cryptos.specials module

Low-level helpers, type adapters, and encoding utilities shared across modules.

cryptnox_cli.lib.cryptos.specials.bin_dbl_sha256(s)[source]
cryptnox_cli.lib.cryptos.specials.lpad(msg, symbol, length)[source]
cryptnox_cli.lib.cryptos.specials.get_code_string(base)[source]
cryptnox_cli.lib.cryptos.specials.changebase(string, frm, to, minlen=0)[source]
cryptnox_cli.lib.cryptos.specials.bin_to_b58check(inp, magicbyte=0)[source]
cryptnox_cli.lib.cryptos.specials.bytes_to_hex_string(b)[source]
cryptnox_cli.lib.cryptos.specials.safe_from_hex(s)[source]
cryptnox_cli.lib.cryptos.specials.from_int_representation_to_bytes(a)[source]
cryptnox_cli.lib.cryptos.specials.from_int_to_byte(a)[source]
cryptnox_cli.lib.cryptos.specials.from_byte_to_int(a)[source]
cryptnox_cli.lib.cryptos.specials.from_string_to_bytes(a)[source]
cryptnox_cli.lib.cryptos.specials.safe_hexlify(a)[source]
cryptnox_cli.lib.cryptos.specials.encode(val, base, minlen=0)[source]
cryptnox_cli.lib.cryptos.specials.decode(string, base)[source]
cryptnox_cli.lib.cryptos.specials.random_string(x)[source]

cryptnox_cli.lib.cryptos.stealth module

Stealth address generation and parsing utilities.

cryptnox_cli.lib.cryptos.stealth.shared_secret_sender(scan_pubkey, ephem_privkey)[source]
cryptnox_cli.lib.cryptos.stealth.shared_secret_receiver(ephem_pubkey, scan_privkey)[source]
cryptnox_cli.lib.cryptos.stealth.uncover_pay_pubkey_sender(scan_pubkey, spend_pubkey, ephem_privkey)[source]
cryptnox_cli.lib.cryptos.stealth.uncover_pay_pubkey_receiver(scan_privkey, spend_pubkey, ephem_pubkey)[source]
cryptnox_cli.lib.cryptos.stealth.uncover_pay_privkey(scan_privkey, spend_privkey, ephem_pubkey)[source]
cryptnox_cli.lib.cryptos.stealth.pubkeys_to_basic_stealth_address(scan_pubkey, spend_pubkey, magic_byte=42)[source]
cryptnox_cli.lib.cryptos.stealth.basic_stealth_address_to_pubkeys(stealth_address)[source]
cryptnox_cli.lib.cryptos.stealth.mk_stealth_metadata_script(ephem_pubkey, nonce)[source]
cryptnox_cli.lib.cryptos.stealth.mk_stealth_tx_outputs(stealth_addr, value, ephem_privkey, nonce, network='btc')[source]
cryptnox_cli.lib.cryptos.stealth.ephem_pubkey_from_tx_script(stealth_tx_script)[source]

cryptnox_cli.lib.cryptos.transaction module

Transaction building, serialization, signing, and parsing utilities.

cryptnox_cli.lib.cryptos.transaction.json_is_base(obj, base)[source]
cryptnox_cli.lib.cryptos.transaction.json_changebase(obj, changer)[source]
cryptnox_cli.lib.cryptos.transaction.encode_1_byte(val)[source]
cryptnox_cli.lib.cryptos.transaction.encode_4_bytes(val)[source]
cryptnox_cli.lib.cryptos.transaction.encode_8_bytes(val)[source]
cryptnox_cli.lib.cryptos.transaction.list_to_bytes(vals)[source]
cryptnox_cli.lib.cryptos.transaction.dbl_sha256_list(vals)[source]
cryptnox_cli.lib.cryptos.transaction.is_segwit(tx)[source]
cryptnox_cli.lib.cryptos.transaction.deserialize(tx)[source]
cryptnox_cli.lib.cryptos.transaction.serialize(txobj, include_witness=True)[source]
cryptnox_cli.lib.cryptos.transaction.uahf_digest(txobj, i)[source]
cryptnox_cli.lib.cryptos.transaction.signature_form(tx, i, script, hashcode=SIGHASH_ALL)[source]
cryptnox_cli.lib.cryptos.transaction.der_encode_sig(v, r, s)[source]
cryptnox_cli.lib.cryptos.transaction.der_decode_sig(sig)[source]
cryptnox_cli.lib.cryptos.transaction.is_bip66(sig)[source]

Checks hex DER sig for BIP66 consistency

cryptnox_cli.lib.cryptos.transaction.txhash(tx, hashcode=None, wtxid=True)[source]
cryptnox_cli.lib.cryptos.transaction.public_txhash(tx, hashcode=None)[source]
cryptnox_cli.lib.cryptos.transaction.bin_txhash(tx, hashcode=None)[source]
cryptnox_cli.lib.cryptos.transaction.ecdsa_tx_sign(tx, priv, hashcode=SIGHASH_ALL)[source]
cryptnox_cli.lib.cryptos.transaction.ecdsa_tx_verify(tx, sig, pub, hashcode=SIGHASH_ALL)[source]
cryptnox_cli.lib.cryptos.transaction.ecdsa_tx_recover(tx, sig, hashcode=SIGHASH_ALL)[source]
cryptnox_cli.lib.cryptos.transaction.mk_pubkey_script(addr)[source]

Used in converting p2pkh address to input or output script

cryptnox_cli.lib.cryptos.transaction.mk_scripthash_script(addr)[source]

Used in converting p2sh address to output script

cryptnox_cli.lib.cryptos.transaction.output_script_to_address(script, magicbyte=0)[source]
cryptnox_cli.lib.cryptos.transaction.mk_p2w_scripthash_script(witver, witprog)[source]

Used in converting a decoded pay to witness script hash address to output script

cryptnox_cli.lib.cryptos.transaction.mk_p2wpkh_redeemscript(pubkey)[source]

Used in converting public key to p2wpkh script

cryptnox_cli.lib.cryptos.transaction.mk_p2wpkh_script(pubkey)[source]

Used in converting public key to p2wpkh script

cryptnox_cli.lib.cryptos.transaction.mk_p2wpkh_scriptcode(pubkey)[source]

Used in signing for tx inputs

cryptnox_cli.lib.cryptos.transaction.p2wpkh_nested_script(pubkey)[source]
cryptnox_cli.lib.cryptos.transaction.deserialize_script(script)[source]
cryptnox_cli.lib.cryptos.transaction.serialize_script_unit(unit)[source]
cryptnox_cli.lib.cryptos.transaction.serialize_script(script)[source]
cryptnox_cli.lib.cryptos.transaction.mk_multisig_script(*args)[source]
Parameters:

args – List of public keys to used to create multisig and M, the number of signatures required to spend

Returns:

multisig script

cryptnox_cli.lib.cryptos.transaction.verify_tx_input(tx, i, script, sig, pub)[source]
cryptnox_cli.lib.cryptos.transaction.multisign(tx, i, script, pk, hashcode=SIGHASH_ALL)[source]
cryptnox_cli.lib.cryptos.transaction.apply_multisignatures(txobj, i, script, *args)[source]
cryptnox_cli.lib.cryptos.transaction.is_inp(arg)[source]
cryptnox_cli.lib.cryptos.transaction.select(unspent, value)[source]

cryptnox_cli.lib.cryptos.wallet module

Simple wallet abstractions for addresses, balances, and signing flows.

This module is based on code from pybtctools: https://github.com/primal100/pybitcointools/blob/master/cryptos/wallet.py

class cryptnox_cli.lib.cryptos.wallet.HDWallet(keystore, num_addresses=0, last_receiving_index=0, last_change_index=0)[source]

Bases: object

__init__(keystore, num_addresses=0, last_receiving_index=0, last_change_index=0)[source]
privkey(address, formt='wif_compressed', password=None)[source]
export_privkeys(password=None)[source]
pubkey_receiving(index)[source]
pubkey_change(index)[source]
pubtoaddr(pubkey)[source]
receiving_address(index)[source]
change_address(index)[source]
property receiving_addresses
property change_addresses
new_receiving_address_range(num)[source]
new_change_address_range(num)[source]
new_receiving_addresses(num=10)[source]
new_change_addresses(num=10)[source]
new_receiving_address()[source]
new_change_address()[source]
balance()[source]
unspent()[source]
select()[source]
history()[source]
sign(tx, password=None)[source]
mksend(outs)[source]
sign_message(message, address, password=None)[source]
is_mine(address)[source]
is_change(address)[source]
account(address, password=None)[source]
details(password=None)[source]

cryptnox_cli.lib.cryptos.wallet_utils module

General wallet helper functions (formatting, hashing, conversions).

cryptnox_cli.lib.cryptos.wallet_utils.hmac_sha_512(x, y)
cryptnox_cli.lib.cryptos.wallet_utils.rev_hex(s)[source]
cryptnox_cli.lib.cryptos.wallet_utils.int_to_hex(i, length=1)[source]
exception cryptnox_cli.lib.cryptos.wallet_utils.InvalidPassword[source]

Bases: Exception

exception cryptnox_cli.lib.cryptos.wallet_utils.InvalidPasswordException[source]

Bases: Exception

exception cryptnox_cli.lib.cryptos.wallet_utils.InvalidPadding[source]

Bases: Exception

cryptnox_cli.lib.cryptos.wallet_utils.assert_bytes(*args)[source]

porting helper, assert args type

cryptnox_cli.lib.cryptos.wallet_utils.append_PKCS7_padding(data)[source]
cryptnox_cli.lib.cryptos.wallet_utils.strip_PKCS7_padding(data)[source]
cryptnox_cli.lib.cryptos.wallet_utils.aes_encrypt_with_iv(key, iv, data)[source]
cryptnox_cli.lib.cryptos.wallet_utils.aes_decrypt_with_iv(key, iv, data)[source]
cryptnox_cli.lib.cryptos.wallet_utils.EncodeAES(secret, s)[source]
cryptnox_cli.lib.cryptos.wallet_utils.DecodeAES(secret, e)[source]
cryptnox_cli.lib.cryptos.wallet_utils.pw_encode(s, password)[source]
cryptnox_cli.lib.cryptos.wallet_utils.pw_decode(s, password)[source]
cryptnox_cli.lib.cryptos.wallet_utils.is_new_seed(x, prefix=version.SEED_PREFIX)[source]
cryptnox_cli.lib.cryptos.wallet_utils.seed_type(x)[source]
cryptnox_cli.lib.cryptos.wallet_utils.is_seed(x)
cryptnox_cli.lib.cryptos.wallet_utils.inv_dict(d)[source]
cryptnox_cli.lib.cryptos.wallet_utils.is_minikey(text)[source]
cryptnox_cli.lib.cryptos.wallet_utils.minikey_to_private_key(text)[source]
cryptnox_cli.lib.cryptos.wallet_utils.get_pubkeys_from_secret(secret)[source]
cryptnox_cli.lib.cryptos.wallet_utils.xprv_header(xtype)[source]
cryptnox_cli.lib.cryptos.wallet_utils.xpub_header(xtype)[source]
cryptnox_cli.lib.cryptos.wallet_utils.number_of_significant_digits(number: float) int[source]

Module contents

Cryptocurrency utilities package - aggregates and re-exports submodules for easier imports.

The cryptnox_cli.lib.cryptos package provides cryptocurrency utilities and re-exports functionality from:

All public members from these modules are available directly from cryptnox_cli.lib.cryptos.