mirror of
https://github.com/bitcoinbook/bitcoinbook
synced 2025-01-11 00:01:03 +00:00
Merge pull request #483 from ChunshengZhao/patch-2
Update key-to-address-ecc-example.py
This commit is contained in:
commit
ec442a35f9
@ -35,7 +35,7 @@ print("Public Key (hex) is:", hex_encoded_public_key)
|
||||
# Compress public key, adjust prefix depending on whether y is even or odd
|
||||
(public_key_x, public_key_y) = public_key
|
||||
compressed_prefix = '02' if (public_key_y % 2) == 0 else '03'
|
||||
hex_compressed_public_key = compressed_prefix + bitcoin.encode(public_key_x, 16)
|
||||
hex_compressed_public_key = compressed_prefix + (bitcoin.encode(public_key_x, 16).zfill(64))
|
||||
print("Compressed Public Key (hex) is:", hex_compressed_public_key)
|
||||
|
||||
# Generate bitcoin address from public key
|
||||
|
Loading…
Reference in New Issue
Block a user