Bitcoin Forum
May 10, 2024, 10:28:11 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoin wallet doesn't store public keys  (Read 801 times)
marley (OP)
Newbie
*
Offline Offline

Activity: 7
Merit: 0


View Profile
June 18, 2014, 02:54:01 PM
 #1

Why the qt bitcoin client doesn't store the public keys associated with the private keys?
Sure it can be computed from the private key alone, but it is a costly operation to do every single time when it could just store a few extra bytes in the wallet.
Any other good reason for this behaviour? Anyone knows if every wallet does the same?

Thanks,
1715380091
Hero Member
*
Offline Offline

Posts: 1715380091

View Profile Personal Message (Offline)

Ignore
1715380091
Reply with quote  #2

1715380091
Report to moderator
1715380091
Hero Member
*
Offline Offline

Posts: 1715380091

View Profile Personal Message (Offline)

Ignore
1715380091
Reply with quote  #2

1715380091
Report to moderator
1715380091
Hero Member
*
Offline Offline

Posts: 1715380091

View Profile Personal Message (Offline)

Ignore
1715380091
Reply with quote  #2

1715380091
Report to moderator
"This isn't the kind of software where we can leave so many unresolved bugs that we need a tracker for them." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715380091
Hero Member
*
Offline Offline

Posts: 1715380091

View Profile Personal Message (Offline)

Ignore
1715380091
Reply with quote  #2

1715380091
Report to moderator
wumpus
Hero Member
*****
qt
Offline Offline

Activity: 812
Merit: 1022

No Maps for These Territories


View Profile
June 18, 2014, 03:13:13 PM
 #2

Where did you get this information? It's wrong.
Bitcoin Core's wallet does store the public keys.
See here for the code that loads keys: https://github.com/bitcoin/bitcoin/blob/master/src/walletdb.cpp#L409

Bitcoin Core developer [PGP] Warning: For most, coin loss is a larger risk than coin theft. A disk can die any time. Regularly back up your wallet through FileBackup Wallet to an external storage or the (encrypted!) cloud. Use a separate offline wallet for storing larger amounts.
marley (OP)
Newbie
*
Offline Offline

Activity: 7
Merit: 0


View Profile
June 20, 2014, 12:32:39 PM
 #3

Where did you get this information? It's wrong.
Bitcoin Core's wallet does store the public keys.
See here for the code that loads keys: https://github.com/bitcoin/bitcoin/blob/master/src/walletdb.cpp#L409

My point is that it appears that bitcoin client is not using this "stored" public keys value, because every time it needs to check the public key associated with a private key it just sets the private key to a EC_KEY openssl object and then asks for its public key. What openssl does is to compute the public key related to the private key, so if bitcoin is storing the public keys it's being useless.
Also the CKey class that is used in the wallet to persist the keys to storage only represents private key data, not public keys, so every time it needs to know the public key, it have to go through openssl mechanism.
You can easily check this by modifying the code to store a key pair where the public key is not related to the private key (just for demonstrations sake), so what it will do is actually store only the private key, and query for its corresponding public key, which will result in the correct private/public keys. So, by this behaviour we see that it's not actually using the stored public keys.
I'm just wondering why this happens.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!