Post
Topic
Board Bitcoin Technical Support
Merits 12 from 6 users
Re: Verify ownership of keys for paper wallet
by
pooya87
on 03/08/2023, 04:40:05 UTC
⭐ Merited by LoyceV (4) ,apogio (2) ,Charles-Tim (2) ,ETFbitcoin (2) ,BitMaxz (1) ,DdmrDdmr (1)
For educational purposes I have developed an app in java that generates  paper wallets. I have run it multiple times offline and I have tested it in Bitcoin's testnet.
Keep this educational and don't create any serious addresses using this. Most importantly is that you won't find bugs by just testing it a couple of times with random cases, there are a lot of edge cases that you may not know of and may not face in your "random tests" but can encounter in a real scenario.
Off the top of my head since you mentioned Java and are probably using the BigInteger class,is that you may forget the necessary padding for the public key and use a smaller than 32 byte x/y coordinate in the pubkey for your hash and end up with coins that can never be spent.

The best real life example I can think of that is similar to what I explained here is the bitcore-lib by Bitpay written in Javascript that had a similar bug with lack of padding. https://github.com/bitpay/bitcore-lib/issues/47