fortesp / bitcoinaddress

Bitcoin Wallet Address Generator
https://pypi.org/project/bitcoinaddress/
MIT License
142 stars 51 forks source link

Compressed Public Address Error #8

Closed qwang12 closed 3 years ago

fortesp commented 3 years ago

We are not generating compressed public addresses yet. I or someone will implement it as soon. You are comparing the segwit address type 3 with compressed public address....

Cheers.

On Thu, 12 Nov 2020 at 16:39, Qi WANG notifications@github.com wrote:

If I use the code below:

from bitcoinaddress import Wallet wallet = Wallet() print(wallet)

partial result shows below:

Private Key HEX: 61ac90b3ec38f16f42c687bfd08e6b9218a9a5c4af79c8e35e3a4f416afb8065

Private Key WIF: 5JZJXyYaKQLoqKwVATd2c9eSMfNGYdapnpm5gxR6c4NgZUoiLu9 Private Key WIF compressed: KzVaPiaN4E2RiJbVJkW269AEvCLsccUHwFoZhMbMjjthc7xaVHyX

Public Key: 043f2c4ad7685b7d53f98999d38a3fdfdfd6ad1db5a82481dfbe4211af9cb3346b9bcdac346526c150fd09c623691c9b3878ae119ff839b3f77b37645e68a39a04 Public Key compressed: 023f2c4ad7685b7d53f98999d38a3fdfdfd6ad1db5a82481dfbe4211af9cb3346b

Public Address 1: 1ByQAi6syxMRvJn4rr5toZ1mmxAqeREodo Public Address 3: 3LF4YthSQBhX8ysyu4bGNa4K99kQtgzxVw

Compare with the results from this link: https://iancoleman.io/bitcoin-key-compression/

1Pf4zgQMwWSAohkMbc6XQopxFMqEF2ZwwC 1ByQAi6syxMRvJn4rr5toZ1mmxAqeREodo

The compressed public address is not correct.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/fortesp/bitcoinaddress/issues/8, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSDR6PIM4JI3A6EGDYUKEDSPP6T5ANCNFSM4TTOCQHQ .

qwang12 commented 3 years ago

Sorry, I just realized my mistake then I delete my post. Thank you for your reply.

Sibtigr commented 3 years ago

Your wonderful code gives out only two WIFI keys not counting the test network Private Key WIN Private Key WIF compressed: There's only one address Public Address 1: No compressed address 1 no WIFI keys from Public Address 3: Public Address bc1 P2WPKH: Public Address bc1 P2WSH: And the output is something like a package of calculations with a bunch of spaces after the keys and in the lines too Thanks for your attention

ver 0.1.2
=== (whitespaces)

Private Key HEX: 02e0a8e3c33e6a02bd1697532be291cf7dd87743f8d14f7951f93c17e2593fb9=

Private Key WIF: 5HqZ5uP3794ZLYNHccFPaCzRdbykXHUAqdZZXvWUCJdBi8dGd2n
Private Key WIF compressed: KwKJceCGJ6ahjFSxLAaWdZvTiZPV6fgvReNibVB52tniGLVdU1Qf
Private Key WIF (TESTNET): 91cBfeCahN8hJbsaEx9JSoYPHGLTgT1NBaRWcYryY3NEVB21nfQ
Private Key WIF compressed (TESTNET): cMgJ5ZC7jAGxtgvDiaPdztRXLngtm7ncVgXBhudaY1SiX5bH49Ai 
=======
Public Key: 04132b92c5d3399ed17f377a11ee118e294e3d2611858aa59090c6e5e354538e76d9af8bc1bd8ed8af31531062f1d5c5da0f282000d7a5d7c090a845568b8e569c 
Public Key compressed: 02132b92c5d3399ed17f377a11ee118e294e3d2611858aa59090c6e5e354538e76

Public Address 1: 1EU3gvhcAdLyLpqMvjKvRBnsqeZMoivSmV===
Public Address 3: 34VRqybYsZ8RSQ6A27MHh2wY1JQRdDJYTX===
Public Address bc1 P2WPKH: bc1qxmha907hm39k89ax52ga3mt9g58z7l4hd533f7q5zxqmffdt2wgsmccyv6===
Public Address bc1 P2WSH: bc1qlm4q3qen7lkt2hchy2xwgu0f9mvmp0eva99sa7==
Public Address 1 (TESTNET): mtyzyynayenE7wJyeJJJF71CheA4n33dAC===
Public Address 3 (TESTNET): 2Mv3duiXaV1dmeBihhEyAJyvoDecbMQCnW6===
Public Address tb1 P2WPKH (TESTNET): tb1qxmha907hm39k89ax52ga3mt9g58z7l4hd533f7q5zxqmffdt2wgsvswtk4
Public Address tb1 P2WSH (TESTNET): tb1qlm4q3qen7lkt2hchy2xwgu0f9mvmp0evhr7rxd 
fortesp commented 3 years ago

@Sibtigr len(wallet.address.__dict__['pubaddr1']) == len(wallet.address.__dict__['pubaddr1'].strip() result: True

Teimoon commented 3 years ago

The Problem is, the script shows a wrong compressed public key. compressed public keys should begin with 02 (y even) or 03 (y odd). I get: pubk_uncompressed: 04a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd5b8dec5235a0fa8722476c7709c02559e3aa73aa03918ba2d492eea75abea235 pubk_compressed: 14a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd this line in address.py looks like it: def _generate_publicaddress_bech32_testnet(self): _p = self.__generate_compressed_pubkey(b'\x02', b'\x14')

why \x14 and not \x03 ? Is that for bech32 alright?

Teimoon commented 3 years ago

I just changed it from (b'\x02', b'\x14') to (b'\x02', b'\x03') and the compressed public key is alright. I created an address from it and it looks well like an P2PKH compressed address.

I don't know if it is okay to the oher script parts, but everything looks alright.