0
I'm trying to create a transaction on the testnet (manually). I have the following private key: cQKqSNkEdyLJziQSr4iKTUJC95s9HHFo4bY88gi2i6v2quiVVLZb which belongs to the following public address: mkhn3gfrGHmd4b1ZmHLdMsbQd2eHRKg8wN. When I try to sign the transaction, the public (uncompressed) key that I generate, is: 042d7331345e0da6ab1125eb39488a542a9923f31c585c20114d211a9f6bc9f3bf55d1d843cb7cf1d36b32d1cb00d2f140ef028e726a19a766f6ca7cef7b956583. This turns out to be invalid (because the transaction gets rejected by the network). However, when I tried using a tool for signing the transaction, it generated the following (correct) public key: 040b4a4274222d7239d33c17ce39d753eee97103773b7e5a89e62f0ef0121032d7331345e0da6ab1125eb39488a542a9923f31c585c20114d211a9f6bc9f3b.
What is the difference between these keys? How come the first one is incorrect when signing the tx but correct when I generated the public address for it?

Thank you for your responses, you've been very helpful with my questions. I will look into the online book hoping it will provide me better understanding. However, following the procedures you mentioned (which is what I've been doing so far), generates a single pubkey, what is the process for generating the second one? – user2298995 – 2018-01-02T11:02:07.633
Now I got it, seems like I misunderstood your point. How can an uncompressed pubkey and a compressed pubkey result in the same public address? – user2298995 – 2018-01-02T12:36:33.103
1compressed and uncompressed pubkeys never result in the same address. The root is the hex private key (64 hexadecimal digits). From this you can create a WIF encoded key, and depending on the prefix, you get a key starting with "5", or with "L" or "K". The process is well described in Andreas' book. When creating the pubkeys, there are uncompressed pubkeys for WIF keys starting with "5", the others would create compressed pubkeys. – pebwindkraft – 2018-01-02T14:28:52.150
1Summary: with the same private key you can create compressed or uncompressed WIF keys (a representation of hex keys), and from there create the two pubkeys, which can be converted into two different bitcoin addresses. Though both addresses (and keys) are based on the same priv key, they are not "interchangeable". In Bitcoin they lead to completly different addresses. – pebwindkraft – 2018-01-02T14:31:50.067