Can anybody inform me how I can get the prolonged public key from an prolonged non-public key in python. I do know that I must get the general public key from the non-public key and that the general public key + chain key = prolonged public key. I have already got the general public key in a number of varieties however I do not know which one to make use of.

Prolonged Non-public Key:                    961901f50868df03db40e0a29d40092b3fc26f47a1c20540d1440be1cd70edbef9c82ec85c4f90a24a1f7a4f1de97ddf762bcb20142b12e9b6c3e348e5519b74
Non-public key:                             961901f50868df03db40e0a29d40092b3fc26f47a1c20540d1440be1cd70edbe
Chain Code:                              f9c82ec85c4f90a24a1f7a4f1de97ddf762bcb20142b12e9b6c3e348e5519b74
PREPENDED:                               80961901F50868DF03DB40E0A29D40092B3FC26F47A1C20540D1440BE1CD70EDBE
PRIV_UNCOMP+CHECKSUM:                    80961901F50868DF03DB40E0A29D40092B3FC26F47A1C20540D1440BE1CD70EDBE223FDFAE
Private_key_WIF_uncompressed_Base58:     5JxPdEGBsaP14hBpr3swh2GZeXctQdLn9ZvjyFEj6diN742em4R
PRIV_COMP+CHECKSUM:                      80961901F50868DF03DB40E0A29D40092B3FC26F47A1C20540D1440BE1CD70EDBE0151EA0003
Private_key_WIF_compressed_Base58:       L2FUruY2zEL7HJNnBVhrPebh6e9PuHQJGpLCfFqaos3a9eeosKVL
('5JxPdEGBsaP14hBpr3swh2GZeXctQdLn9ZvjyFEj6diN742em4R', 'L2FUruY2zEL7HJNnBVhrPebh6e9PuHQJGpLCfFqaos3a9eeosKVL')
Non-public key hex string:                  961901F50868DF03DB40E0A29D40092B3FC26F47A1C20540D1440BE1CD70EDBE
Non-public key bytes:                       b'x96x19x01xf5x08hxdfx03xdb@xe0xa2x9d@t+?xc2oGxa1xc2x05@xd1Dx0bxe1xcdpxedxbe'
Verifying key, x and y factors (bytes):  b'E.1xc8Zx02xf6x1e$x9dxf1xcfxc3x10x8ffx06x14UxceL3xf8xabOxbfx1crxe4xf6xf1x1cmxb9xc3x16xed6xbbx0cxe4xeaQx1b^Wxdex8dxd5xacx822Zxeaxcb#x82xf1xdaxb8x12xfdx8fxa9' <class 'bytes'>
Uncompressed non-public key (hex):          04452E31C85A02F61E249DF1CFC3108F66061455CE4C33F8AB4FBF1C72E4F6F11C6DB9C316ED36BB0CE4EA511B5E57DE8DD5AC82325AEACB2382F1DAB812FD8FA9
Compressed non-public key in (hex):         02452E31C85A02F61E249DF1CFC3108F66061455CE4C33F8AB4FBF1C72E4F6F11C
Public compressed key (hex):             13w1yEAhhMGk6E5UU2wGQyy7pP14K1q2tg
Prolonged Public Key:                     ?


Julian is a brand new contributor to this website. Take care in asking for clarification, commenting, and answering.
Take a look at our Code of Conduct.

From BIP32:

We signify an prolonged non-public key as (ok, c), with ok the conventional
non-public key, and c the chain code. An prolonged public secret’s
represented as (Ok, c), with Ok = level(ok) and c the chain code.

level(p): returns the coordinate pair ensuing from EC level
multiplication (repeated software of the EC group operation) of the
secp256k1 base level with the integer p.

ser256(p): serializes the integer p as a 32-byte sequence, most
vital byte first.

serp(P): serializes the coordinate pair P = (x,y) as a byte sequence
utilizing SEC1’s compressed type: (0x02 or 0x03) || ser256(x), the place the
header byte is determined by the parity of the omitted y coordinate.

Prolonged private and non-private keys are serialized as follows:

  • 4 byte: model bytes (mainnet: 0x0488B21E public, 0x0488ADE4 non-public; testnet: 0x043587CF public, 0x04358394 non-public)
  • 1 byte: depth: 0x00 for grasp nodes, 0x01 for level-1 derived keys, ….
  • 4 bytes: the fingerprint of the dad or mum’s key (0x00000000 if grasp key)
  • 4 bytes: youngster quantity. That is ser32(i) for i in xi = xpar/i, with xi the important thing being serialized. (0x00000000 if grasp key)
  • 32 bytes: the chain code
  • 33 bytes: the general public key or non-public key information (serp(Ok) for public keys, 0x00 || ser256(ok) for personal keys)

This 78 byte construction could be encoded like different Bitcoin information in
Base58, by first including 32 checksum bits (derived from the double
SHA-256 checksum), after which changing to the Base58 illustration.
This leads to a Base58-encoded string of as much as 112 characters.

Thus the prolonged public key (xpub) could be derived from the prolonged non-public key (xprv) as follows:

  1. Convert the xprv from Base58 to bytes and extract the non-public key from the final 33 bytes (ignoring the checksum).
  2. Calculate the general public key from the non-public key as per level(p).
  3. Serialize the end result:
    • 4 bytes: 0x0488B21E (mainnet) or 0x043587CF (testnet)
    • 41 bytes: depth, dad or mum fingerprint, youngster quantity and chain code are the identical as within the xprv
    • 33 bytes: public key serialized utilizing serp(Ok)
  4. Add the 4-byte checksum and convert to Base58.