nectargraphenebase.bip32 module

class nectargraphenebase.bip32.BIP32Key(secret: bytes | PublicKey, chain: bytes, depth: int, index: int, fpr: bytes, public: bool = False, testnet: bool = False)

Bases: object

Address() str

Return compressed public key address

CKDpriv(i: int) BIP32Key | None

Create a child key of index ‘i’.

If the most significant bit of ‘i’ is set, then select from the hardened key set, otherwise, select a regular child key.

Returns a BIP32Key constructed with the child key parameters, or None if i index would result in an invalid key.

CKDpub(i: int) BIP32Key | None

Create a publicly derived child key of index ‘i’.

If the most significant bit of ‘i’ is set, this is an error.

Returns a BIP32Key constructed with the child key parameters, or None if index would result in invalid key.

ChainCode() bytes

Return chain code as string

ChildKey(i: int) BIP32Key | None

Create and return a child key of this one at index ‘i’.

The index ‘i’ should be summed with BIP32_HARDEN to indicate to use the private derivation algorithm.

ExtendedKey(private: bool = True, encoded: bool = True) str | bytes

Return extended private or public key as string, optionally base58 encoded

Fingerprint() bytes

Return key fingerprint as string

Identifier() bytes

Return key identifier as string

P2WPKHoP2SHAddress() str

Return P2WPKH over P2SH segwit address

PrivateKey() bytes

Return private key as string

PublicKey() bytes

Return compressed public key encoding

SetPublic() None

Convert a private BIP32Key into a public one

WalletImportFormat() str

Returns private key encoded for wallet import

dump()

Dump key fields mimicking the BIP0032 test vector format

classmethod fromEntropy(entropy: bytes | None = None, public: bool = False, testnet: bool = False) BIP32Key

Create a BIP32Key using supplied entropy >= MIN_ENTROPY_LEN

static fromExtendedKey(xkey: str, public: bool = False) BIP32Key

Create a BIP32Key by importing from extended private or public key string

If public is True, return a public-only key regardless of input type.

hmac(data: bytes) Tuple[bytes, bytes]

Calculate the HMAC-SHA512 of input data using the chain code as key.

Returns a tuple of the left and right halves of the HMAC

nectargraphenebase.bip32.int_to_hex(x: int) bytes
nectargraphenebase.bip32.parse_path(nstr: str, as_bytes: bool = False) List[int] | bytes

Parse a derivation path like “m/0’/1/2” into a list of indexes or bytes.

nectargraphenebase.bip32.test()