Bitcoin Wallet Architecture4.7(91)
Intermediate
Dive into the cryptographic principles that power Bitcoin wallets.
47' (0x8000002F), which refers to BIP47. An example of a derivation path for a reusable payment code would be as follows:m/47'/0'/0'/
PM8TJSBiQmNQDwTogMAbyqJe2PE2kQXjtgh88MRTxsrnHC8zpEtJ8j7Aj628oUFk8X6P5rJ7P5qDudE4Hwq9JXSRzGcZJbdJAjM9oVQ1UKU5j2nr7VR5
+ :+throbbingpond8B1 +twilightresonance487 +billowingfire340
xpub, in terms of both its position in the wallet structure and its role.0: The version. For the first version of BIP47, this byte is set to 0x01.1: The bit field. This space is reserved for integrating additional indications for specific uses. For classic PayNym use, this byte is set to 0x00.2 byte: The parity of y. This byte is 0x02 or 0x03, indicating whether the ordinate of the public key is even or odd, as a compressed public key is used.3 to byte 34: The value of x. These bytes represent the abscissa of the public key. The concatenation of x and the parity of y forms the complete compressed public key.35 to byte 66: The string code. This space contains the string code associated with the public key.67 to byte 79: The padding. This space is intended for possible future evolutions. For the current version, we simply place zeros here to reach the 80-byte size required for OP_RETURN output.0x010002a0716529bae6b36c5c9aa518a52f9c828b46ad8d907747f0d09dcd4d9a39e97c3c5f37c470c390d842f364086362f6122f412e2b0c7e7fc6e32287e364a7a36a00000000000000000000000000
P prefix byte must be added at the beginning to clearly indicate that this is a payment code. This byte is represented by 0x47:0x47010002a0716529bae6b36c5c9aa518a52f9c828b46ad8d907747f0d09dcd4d9a39e97c3c5f37c470c390d842f364086362f6122f412e2b0c7e7fc6e32287e364a7a36a00000000000000000000000000
HASH256, which consists of a double hash using the SHA256 function. The first four bytes of this hash are then concatenated at the end of the payment code:0x47010002a0716529bae6b36c5c9aa518a52f9c828b46ad8d907747f0d09dcd4d9a39e97c3c5f37c470c390d842f364086362f6122f412e2b0c7e7fc6e32287e364a7a36a00000000000000000000000000567080c4
PM8TJSBiQmNQDwTogMAbyqJe2PE2kQXjtgh88MRTxsrnHC8zpEtJ8j7Aj628oUFk8X6P5rJ7P5qDudE4Hwq9JXSRzGcZJbdJAjM9oVQ1UKU5j2nr7VR5
m/47'/0'/0'/
47 + 2^31 (hardened derivation). This is followed by two further successive derivations of daughter pairs, each using the index 2^31 (hardened derivation).s in https and the padlock in your browser's address bar - symbols of encrypted communications. By taking this course, you'll be using ECDH, and it's highly likely that you'll be using it on a daily basis without even knowing it.xpub would be simpler in this case - but rather result from a calculation combining the two payment codes: those of the sender and the recipient. Therefore, if the recipient loses their wallet and attempts to restore it from their seed, they will recover their own payment code, which is directly derived from their seed. However, to recover ephemeral addresses, he will also need the payment codes of all those who have sent him bitcoins via BIP47. Hence, the importance of the notification transaction lies in its ability to save this information on the Bitcoin blockchain, while still allowing it to be easily retrieved without requiring a search through the billions of transactions executed since its launch in 2009.XOR. The operation performed is comparable to the Vernam cipher, also known as the "One-Time Pad."XOR (or exclusive).OP_RETURN consisting of her payment code with the encrypted payload. This transaction serves as the notification transaction.OP_RETURN is an opcode that marks the output of a Bitcoin transaction as invalid. Today, it is used to broadcast or anchor information on the Bitcoin blockchain. It can store up to 80 bytes of data, which is then written to the chain and visible to all other users.OP_RETURN transaction output to communicate the hidden payment code to Bob.OP_RETURN, let's examine a real notification transaction. I carried out such a transaction on the testnet, which you can find by clicking here.OP_RETURN, which contains my hidden payment code.OP_RETURN. Let's take a closer look at what it contains. Here's the scriptPubKey in hexadecimal:6a4c50010002b13b2911719409d704ecc69f74fa315a6cb20fdd6ee39bc9874667703d67b164927b0e88f89f3f8b963549eab2533b5d7ed481a3bea7e953b546b4e91b6f50d800000000000000000000000000
6a4c
0x6a, which designates the OP_RETURN, and 0x4c, which designates the OP_PUSHDATA1.0x50, or 80 bytes:6a4c50
010002
b13b2911719409d704ecc69f74fa315a6cb20fdd6ee39bc9874667703d67b164
927b0e88f89f3f8b963549eab2533b5d7ed481a3bea7e953b546b4e91b6f50d8
OP_RETURN:00000000000000000000000000
PM8TJQCyt6ovbozreUCBrfKqmSVmTzJ5vjqse58LnBzKFFZTwny3KfCDdwTqAEYVasn11tTMPc2FJsFygFd3YzsHvwNXLEQNADgxeGnMK8Ugmin62TZU
4701000277507c9c17a89cfca2d3af554745d6c2db0e7f6b2721a3941a504933103cc42add94881210d6e752a9abc8a9fa0070e85184993c4f643f1121dd807dd556d1dc000000000000000000000000008604e4db
OP_RETURN, we can see that the HRP (0x47) and the checksum (0x8604e4db) are not transmitted. This is normal, as this information is intended for humans.0x01), the bit field (0x00), and the parity of the public key (0x02). And, at the end of the payment code, the empty bytes (0x000000000000000000000000000000) allow padding to reach a total of 80 bytes. All this metadata is transmitted unencrypted.0x77507c9c17a89cfca2d3af554745d6c2db0e7f6b2721a3941a504933103cc42a) and the string code (0xdd94881210d6e752a9abc8a9fa0070e85184993c4f643f1121dd807dd556d1dc) have been encrypted. This is the payload of the payment code.1 if the bits of the same rank are different, and it returns 0 if the bits of the same rank are equal. Here's the XOR truth table according to the values of the operands D and E:| D | E | D XOR E |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
0x01, Bob begins his search for a possible secret shared with ECDH:2^32 payments, without ever having to repeat a notification transaction of this type.m/47'/0'/0'. The following depth divides the indexes as follows:m/47'/0'/0'/0;m/47'/0'/0'/0 to m/47'/0'/0'/2,147,483,647;m/47'/0'/0'/0' to m/47'/0'/0'/2,147,483,647'.2^32 blank addresses belonging to Bob.94b2e59510f2e1fa78411634c98a77bbb638e28fb2da00c9f359cd5fc8f87254
2^32 payments.