1) How to generate a private key safely? Online tools are obviously undesirable as they might keep a back door on all keys generated. Similar reason for any library or packages even they operate offline (I cannot check if these keys generated are in fact following some predetermined sequence).
I can use a random number generator on an offline PC. But I am not a real 'hacker' and have concerns on whether any programming language can produce truly random numbers that cannot be reproduced (or say predicted) on another PC. They might all rely on some external factors (such as time) which greatly reduce the possible key generated and make brutal force algorithms possible.
Currently, I can only think of throwing dice for key generating but that cannot scale.
The 1Feex and 12ib addresses prove that it is possible to store things long term.
As for random, a random number generator is mostly fine, except these things aren't random. You need a little bit of entropy. from any second source
A little bit goes a long way. This could be adding in a few characters to those random numbers that you personally have come up with.
A few bytes changed makes it more random than a computer.
A much more important thing is not using the default generated address from bitcoin core.
Every key has like 2^99 addresses that can be associated with it.
Bitcoin core uses the first one or two these possibilities. (I wish core was programmed so that you can put in your own
magic number / k value? Random is unnecessary here. I forget what it's called. Ideally you want this number to be very large..)
Using the default address generated by core and its low k means that all an 'attacker' has to do is match their key with few possibilities of addresses.
Still a lengthy process, but much less lengthy than any other method.
Python software is pretty good at generating addresses from keys, and you can easily look through most of it to see that the code doesn't open internet connections.
This can generate a wallet-import-format or wif,
https://github.com/crcarlo/btcwif/blob/master/btcwif.py , although it is older.
pybitcoinwallet can generate addresses from this wif. Check that your software can make more than one address from any given key or wif.
import btcwif
key = '
'
wif1 = btcwif.privToWif(key)
Separate out your keys into more than one to avoid the hopefully unlikely loss via any number of means.
2) I do not want to use any 3rd party software as a wallet. Suppose I just store my private key on a piece of paper and later transfer coins into it using exchanges. Would that be a valid transaction and allows me later to spend these coins? Is there anything else I need to store together with the private key (like the hashed transaction number in transaction_input in the blockchain? ScriptSig?) I really want to avoid 3rd party software because it might be obsolete in the future and data can be degraded. (Say if I use some sophisticated cold wallet, I may experience hardware degradation in 10 yrs, no one at that time used this software, programmers 10 yrs ago cannot be reached, and any trick in coding or encoding in the original version becomes obsolete. I would be a consumer rather than an investor of BTC...)
What's a wallet?
You don't need any software to save bitcoin since it's distributed across miners and nodes on the net. It is much harder to do without software though! You can import your key when ready into bitcoin core, but you will have to rescan the entire blockchain, which can take a while. I recommend trying it out with a small sum first. You don't want to make a mistake here. This test takes a long time.
Try not to spend your coin after transferring to your wallet to not give out your public address, although 12ib proves again that you can be 'safe' since it has several transactions out.
Degradation of code, software, and economics will always be an issue. You may want to keep an old computer that can use bitcoin core software. The internet and miner protocols shouldn't change over that time, but who knows. If quantum computing takes off in big ways or certain fakes have their way, then very old transactions may one day become invalid, so ideally you shouldn't become completely disconnected from your wealth for too long in the event of the unforeseeable.