Bitcoin Transactions, Pay-To-Public-Key-Hash Discussion

It’s now called blockchain and bitcoin 101,
Long time ago on the teachable platform it was called blockchain deep fundamentals

1 Like

Yeah, that was the first class I bought when it first came out. It was really a great overview soup-to-nuts of actually programming on the blockchain(s) in multiple languages.

Now I see the way the tracks are set up and how much more polished the Academy has become, and is becoming every day.

Great job to @ivan and @filip!

1 Like

@filip
Can you guys please teach us/walkthrough how to install and/or use this BTCDEB at https://github.com/kallewoof/btcdeb? The IDE at https://siminchen.github.io/bitcoinIDE/build/editor.html is useless it seems as it cannot process a Bitcoin tx. Even just installation help tutorial would be awesome.

Hi, I tried running the script (from the pdf file) but it failed because the hash didn’t match…

02dc109689e8655dc90d09544397d8b04989cd42b8037d15ba629b12d5ab77c068 OP_HASH 160

the result I get is 0x02424E212EF22653854D5C4B5122376A9375A9C1

Any ideas???

Above (Dec’19) somebody has the same problem as I read. There is some bug with the IDE. https://forum.toshitimes.com/t/bitcoin-transactions-pay-to-public-key-hash-discussion/7904/30?u=tetemtotem

Hello everybody, and thank you for the great lecture.

I do not understand how OP_CHECKSIG is working. It makes me afraid because of the security of the blockchain.

OP_CHECKSIG is checking that the signature and the public key is derived from the same private key? Am I right?

Then we said it earlier, that it is very difficult to find out from the public key what is private key. Am I right?

Then how can a simple OP_CHECKSIG function, that is do not know what is the private key - find out that the pair of the public key is the same private key what we used for the signature.

and is the signature is the hash of the private key and some message.?
What is that message?

Somebody shared a link above - i think it was the firs comment - that how signatures works. That link says we do some mathematics with the public key and with the message. What kind of mathematics we do exactly?

Thank you for the answer. :slight_smile:

Hi there. In Transaction Script Walkthrough and Execution. We see the sig, before you place in the stack, as being 60ca60… but after you add to stack it is 3044…

Can you explain what happened there? This is around minute 7:10 of the video

Hi @albertovasquez, welcome to the forum! :slight_smile: the number is so large it doesn’t fit on the screen :stuck_out_tongue: if you revert the video back to around 5:52 you will see the entire number :slight_smile:

2 Likes

Thank you! I appreciate it.

From my understanding:
<Signature> is proof that you own the private key without revealing it.

OP_CHECKSIG pops 2 elements, <Signature> and <PubKey> to verify if both came from the same <PrivKey>. The math behind it is complex but this is the best analogy I came with:

Imagine you are in a completely dark room. Test condition: you have 1 shot to hit 2 targets (pubkey and transaction data) to prove you are the setter of the target (rightful owner of UTXO). The verifier doesn’t need to know where you shooting from. But if they could hear the 2 targets been hit at the same time meaning you are the originator of that PubKey with the correspondent Value IN (VIN).

The chance of a random person claim to know the set up is so small, that if this condition passed you are the assumed owner. OP_CHECKSIG amount to TRUE and you can spend that transaction.

Hope I make the right analogy @Alko89 @filip

1 Like

Hmmm I don’t fully understand the analogy :stuck_out_tongue:

The formula is kind of like this where you have (k + j)*H = kH + jH

Where k is the private key and j is the shared secret. So if you reveal k + j you can prove you know k.

3 Likes

Hi there, some questions, perhaps they are general but I think I need clarification:

1.- In Bitcoin, a public key is the same as an address ? How are these two terms in the Bitcoin world associated? An address is derived from a public key?

In the example shown in the lecture the Public keys seem to clearly be a hexadecimal number, but addresses seem to be just be random letters and numbers so what is the relationship; please clarify.

2.- I believe the “signature” is some type of construction using the Private Key; but how is a “signature” constructed or built?

3.- I see that a wallet has an “extended private masterkey”, and the same wallet can have several private keys, with corresponding public addresses. To create a signature which is used?

4.- In programming terms, private keys in Bitcoin are, Strings, Integer, a Float Number, etc?

2 Likes

No. Address is the HASH(PubKey). The result of hash function always result in HEX.

The math behind it is complicated https://www.instructables.com/Understanding-how-ECDSA-protects-your-data/. However, what you need is the PrivKey, transaction hash to come up with Signature(R,S).

XPrv and XPub keys are implementation of BIP32-44, which allow HD wallets. Main features are you can use XPub keys to generate a bunch of PubKey without the PrivKey. Whereas the original way is to generate a pair Priv/PubKey which is less secured.

PubKey = SHA256(PrivKey)
ie: it’s a 256bit, (49 digit long integer)

2 Likes

Yes address is the hash of the public key. But its not hex. Technically this is a binary buffer and can be displayed in any base numerical format, hex (or base16) being the most common.
Bitcoin uses base58 format to display addresses.

Public key is not the hash of the private key. Public keys are derived using the elliptic curve function. :slight_smile:

3 Likes

Thanks for the clarification. Especially the Base58Check encoding format.

My bad, I was jumping ahead of myself. I found that Bitcoin uses secp256k1 as its ECDSA. My question for you @Alko89 @filip is:

  1. Is this the same Algo that sign and provide PubKey?

Secp256k1 are the parameters of the elliptic curve, these are the fixed values of the function. There are a lot of variations of it, you could technically even make up your own.
I admit I’m not a cryptography expert and am not entirely sure how these parameters influence the function itself, except change how the curve looks on a coordinate system. :stuck_out_tongue:

2 Likes

I thought I had a good grasp of UTXO’s but these bits are kind of confusing to me
I went back through the blockchain fundamentals notes…

-Is a wallet always a node? Is a node always a wallet?
-Is the UTXO pool in the wallet, or only on one of the addresses? It seems to be the same as your balance.
-Is every address local to a wallet?
-Is there a process by which a transaction that received btc becomes a UTXO, or are they the same?

I’m still having trouble wrapping my brain around the fundamental difference between nodes, wallets, and addresses (in terms of how they interact with the UTXO pool).

1 Like

A node is the software that connects to the network and stores the blockchain (if its not an SPV), the wallet stores your private keys and signs transactions. They are not necessarily the same software and can work independently.

UTXOs are unspent transaction outputs. An address can have many UTXOs and a wallet can have multiple addresses. The sum of all UTXOs the wallet contains is the balance of the wallet.

I’m not sure what you mean exactly. Every address has a corresponding private key and a wallet can contain many private keys.

They are not the same. UTXOs are the outputs of a transaction that can be used as inputs in a new transaction. One transaction can have many inputs and outputs (that become UTXOs) :slight_smile:

3 Likes

Is the UTXO set equivalent to all the bitcoin in circulation?

1 Like

Yes the sum of all UTXOs should be the same as all Bitcoin available. :slight_smile:

2 Likes