Skip to content

Remove BitcoinECC dependency #1585

@anoadragon453

Description

@anoadragon453

As far as I can see, BitcoinECC is only used for backwards-compatible methods, which I am not sure are still in use (please correct me if I'm wrong).

BitcoinECC is only used in src/Crypt/CryptBitcoin.py:

def privatekeyToAddress(privatekey): # Return address from private key
if privatekey.startswith("23") and len(privatekey) > 52: # Backward compatibility to broken lib
bitcoin = BitcoinECC.Bitcoin()
bitcoin.BitcoinAddressFromPrivate(privatekey)
return bitcoin.BitcoinAddresFromPublicKey()
else:
try:
return btctools.privkey_to_address(privatekey)
except Exception: # Invalid privatekey
return False

def signOld(data, privatekey): # Return sign to data using private key (backward compatible old style)
bitcoin = BitcoinECC.Bitcoin()
bitcoin.BitcoinAddressFromPrivate(privatekey)
sign = bitcoin.SignECDSA(data)
return sign

def verify(data, address, sign): # Verify data using address and sign
if hasattr(sign, "endswith"):
if opensslVerify: # Use the faster method if avalible
pub = opensslVerify.getMessagePubkey(data, sign)
sign_address = btctools.pubtoaddr(pub)
else: # Use pure-python
pub = btctools.ecdsa_recover(data, sign)
sign_address = btctools.pubtoaddr(pub)
if type(address) is list: # Any address in the list
return sign_address in address
else: # One possible address
return sign_address == address
else: # Backward compatible old style
bitcoin = BitcoinECC.Bitcoin()
return bitcoin.VerifyMessageFromBitcoinAddress(address, data, sign)

I believe the signOld method can be removed immediately since it is only used in tests. The others seem a little more rooted in some useful methods.

What are your thoughts on this lib @HelloZeroNet, is it difficult to just strip out at the moment?

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions