Bitcoin under the hood part 2

Hey guys,

Funnily enough, roughly this time last year I asked a similar question on how Bitcoin transactions happen ( https://www.cplusplus.com/forum/lounge/278136/ )

Helios helped explain how Bitcoin transactions happen. Well, one year on and I have some follow up questions. Let me first recap what I know in summarised form.

- Transactions(TX) have an input and output.
- An output will be input to an input transaction
- Each unreferenced output can only be spent ( this stops double spending or spending what you don't have)


I know it has something to do with public/private key pairs, but let's say that I want to send 1 BTC to a friend, how does my friend verify that I actually have the rights(own the bitcoin) to the BTC being sent?

Also (and hopefully this is not too vague) how do I know somebody else can't just send my Bitcoin? ** Probably a stupid question..

Thanks :)

Last edited on
I know it has something to do with public/private key pairs, but let's say that I want to send 1 BTC to a friend, how does my friend verify that I actually have the rights(own the bitcoin) to the BTC being sent?
Your friend doesn't need to verify that. If the transaction comes through the network verifies that. It does that like this:
When someone sent you those bitcoins they assembled the TXOs with a small script. The TXI in your spending transaction will contain another small script. To verify that your TXI is allowed to spend that TXO the node concatenates both scripts and executes the concatenation; the TXI is valid if the result is 1. The script could be something like

TXI script:
Push [signature of challenge with your private key]
TXO script:
Push [random 32 bytes (challenge)]
Push [your public key]
VerifySecp256k1

Someone can know that you're able to spend those UTXOs because your BTC address is your public key encoded, so your BTC address must match the public key in the TXO script.

Also (and hopefully this is not too vague) how do I know somebody else can't just send my Bitcoin? ** Probably a stupid question..
The security of ECC signatures is based on the difficulty of solving the discrete logarithm problem in a reasonable time. It's currently (mathematically) unproven that the problem has no fast solution in a non-quantum computer, but no such solution is currently known. If quantum computers become feasible, though, both ECC and RSA are broken.
some light reading (seriously, its dumbed down to oblivion of course).
https://www.nbcnews.com/tech/security/bitcoin-crypto-exchange-hacks-little-anyone-can-do-rcna7870

its just like the @#$% encryption algorithms. They may take a whole nation's worth of super computers to crack just 1 file every year or whatever, but none of that matters if you can steal the password, now does it?
Last edited on
Really interesting, I'm quite far behind on Crypto these days. Need to invest some time into it. It's truly a fascinating field
treat it like you would a trip to vegas... only invest what you don't mind losing. If you win big, good, if you lose it all, don't care...
Topic archived. No new replies allowed.