Imagine Ana opens her wallet and taps RECEIVE.

A combination of letters and numbers appears on the screen, accompanied by a QR code.

Ana can share this information to receive BTC.

But there’s a question few people ask...

WHERE DO THOSE LETTERS AND NUMBERS COME FROM? HOW DOES THE WALLET KNOW WHICH ADDRESS TO SHOW?

The answer lies in a cryptographic procedure that we’ll understand step by step.

In the previous section, we learned that an HD wallet can derive numerous private keys and their corresponding public keys.

Now we're going to find out how it uses one of those public keys to build a Bitcoin address....

To explain, we'll use a real example: a P2WPKH address, also known as a native SegWit address.

It's one of the types of addresses that start with bc1q.

WHAT DOES THE SOFTWARE DO FIRST?

The wallet obtains a public key corresponding to one of the private keys it manages.

In our example, it uses a compressed public key, represented by 33 bytes of information.

But pay attention...

A PUBLIC KEY IS NOT THE SAME AS A BITCOIN ADDRESS....

We still need to transform that information.

HOW DOES IT DO THAT?

The software applies a cryptographic function called SHA-256 to the public key.

Remember that a hash function can calculate a digital fingerprint from specific data.

Then it applies another function called RIPEMD-160 to the SHA-256 result.

This combination has a technical name: HASH160.

And what do we get?
A 20-byte cryptographic fingerprint, calculated from the public key.

BUT THAT FINGERPRINT ISN'T THE COMPLETE ADDRESS YET....

It's one of the pieces of information needed to build it.

SO HOW DOES THE ADDRESS WE SEE ON SCREEN COME ABOUT?

The wallet adds information that identifies the version of the mechanism being used.

In our example, it's version 0 of SegWit.

It then uses an encoding system called BECH32, defined in the BIP173 standard.

What is it for?

To represent that data as a sequence of characters that we can copy and share.

Bech32 doesn't encrypt or hide the information.

It encodes it according to specific rules and adds checksum characters that can detect many accidental errors.

AND THAT'S HOW WE GET AN ADDRESS THAT STARTS WITH bc1q...

But what do those characters mean?

bc identifies the Bitcoin main network.

The number 1 separates the prefix from the rest of the data.

And the letter q, immediately after that separator, represents version 0 in this encoding.

The remaining characters represent the information corresponding to the address and include checksum data.

THE WALLET PERFORMS THIS ENTIRE PROCESS AUTOMATICALLY.

Ana doesn't calculate hashes, convert numbers, or enter keys manually.... The software performs those calculations according to the format's rules.

CAN WE SUMMARIZE THE PROCESS?

Yes. In our example, the process is:

PUBLIC KEY - SHA-256 - RIPEMD 160 - VERSION DATA - BECH32 ENCODING - ADDRESS.

And now comes something important.

WHAT HAPPENS WHEN BRUNO SENDS BITCOIN TO THAT ADDRESS?

Bruno's wallet interprets the encoded information. Using that data, it prepares a transaction output with the corresponding conditions so that those BTC can be spent later.

As we've already learned, an address isn't a bank account or a container where digital coins are stored.

IT'S INFORMATION THAT INDICATES HOW A BITCOIN OUTPUT SHOULD BE CONSTRUCTED.

AND WHAT FUNCTION DOES THE QR CODE SERVE?

It makes it easier to share that information without having to type it.
It can contain just the address or a payment request with additional information, such as an amount.

But it doesn't change the private keys or the cryptographic procedure used to construct the address.

AND WHY IS IT SO IMPORTANT TO CHECK IT BEFORE SENDING BTC?

Because those characters represent precise information.

Bech32's checksum mechanism can detect many typing errors.

However, there's a different risk.

An attacker could replace the original address with another valid address they control.

In that case, the format could be perfectly correct, but the recipient would be someone else...

A VALID ADDRESS DOESN'T NECESSARILY MEAN IT'S THE RIGHT ADDRESS.

That's why we need to check that it really belongs to the person who will receive the funds.

WHAT DID WE LEARN?

That a Bitcoin address isn't an arbitrary combination of characters...

That its construction uses cryptographic information and specific encoding rules.

And that a public key can be involved in generating an address without revealing its corresponding private key.

But there's one question we still haven't answered...

IF ADDRESSES ARE USED TO RECEIVE BITCOIN, WHY DO SOME START WITH 1, OTHERS WITH 3, AND OTHERS WITH bc1q OR bc1p?

Are these just visual differences, or do they represent different mechanisms?

That leads us directly to the next section....

BECAUSE BEHIND EVERY ADDRESS IS A STRUCTURE THAT THE SOFTWARE MUST INTERPRET CORRECTLY.

AND NOW THAT WE KNOW HOW ONE IS BUILT, WE'RE READY TO UNDERSTAND WHY NOT ALL BITCOIN ADDRESSES ARE THE SAME....

$BTC $ETH $BNB

#bitcoin #blockchain #DireccionesBitcoin #Criptografia