What is Happening in The Transaction

So far we have learned how we can handle operations to exchange cryptocurrencies.
But how does the cryptocurrency work under the way we are doing that?
From here, in accordance with the procedure introduced in the previous page "Transaction flow", while explaining the mechanism of the cryptocurrency, verifying the security of the cryptocurrency with the experiment, that is, "countermeasure against fake money" I will go.
In addition, the explanation here matches the most popular bitcoin in the world, and it may be slightly different from other cryptocurrency mechanisms.



cryptocurrency account and cryptographic signature

On the previous page, Mr. A first created a wallet and got a cryptocurrency account. The address of the cryptocurrency is added to the wallet.
Here, we prepared an address of a bitcoin as a sample.

Adress: 1D2o4RCjEZ3iNbkbkKtKvXW9ctaWkHCSAM

In the case of a bitcoin, the address is made of alphanumeric characters starting with 1 or 3, 27 to 34 digits.
If you want to send the cryptocurrency, anyone can deliver the cryptocurrency to the other party if you know this address. In other words, this address is a number for you to receive the cryptocurrency.




On the other hand, what about sending the cryptocurrency? As mentioned in the previous page, most wallets have a cryptocurrency sending function, and if you enter the address and amount, the cryptocurrency will be sent to the other party. So what is going on in Wallet at this time?
Actually, there are not many opportunities to actually see that number, but in the account created by Mr. A, there are two more strings to be used for sending in correspondence with the previous address. It is what is called public key, secret key.
Public key: 0409ddf50fb8001b5bbd7d1dc77dd45314e36a3b8f86eda822128ba70573cbd0bd67e97436e0f9885776e1b43e66e40026f84cc7f8f453a1dc6d4f25cbd77edabe Secret key: 67ce9c51d2cd54b37aa978816d79881eb51fa51804b71aa4eef3310490f7971f






Both are long strings compared to bitcoin addresses, but Wallet first creates the private key and then creates the public key and address. This is because the public key is created as a secret key and the bitcoin address is created as a public key by performing specific operations respectively.
To good understanding,let's explain with an easy example.
When it is assumed that the secret key is "an appropriate one or more integer", the public key is expressed as "the number obtained by multiplying the secret key number by 2 plus 5", the bitcoin address by "the public key number multiplied by 10 It is defined as the number subtracted by 7 ".
Then, when the secret key is 10, the public key becomes 10 × 2 + 5 = 25 and the bitcoin address becomes 25 × 10 + 7 = 257.
In this way, public keys and bitcoin addresses are created from a secret key under a certain rule.
In fact, it is made difficult to calculate backwards from bitcoin address and public key to secret key by using complicated calculation.



Transmission of Cryptocurrency and Fraud Control

So, what role does these have in the exchange of cryptocurrency?

Public keys are used to indicate "sender" when sending cryptocurrency.
When sending a mail, the sender's account remains as a record of the exchange so that not only the destination but also the sender's mail address is included as mail information, even when sending the cryptocurrency.

When the cryptocurrency is traded in this manner, information is recorded between the sender and the recipient, such as "when", "Who is from", "who is sent", "how much did I pay".
The data that wrote this information is called a transaction (trading meaning in English), and the cryptocurrency stores transactions all over the world on the network so that money can be exchanged by cryptocurrency is.

In addition, since the bitcoin address can be easily determined if the public key is known, from the record of transactions performed in the past, it is known how much money has been paid and used in that account in the past, so the actual cryptocurrency You can also check if you are going to pay more than the amount.




So far, I've been looking at the mechanisms for trading cryptocurrencies, but in fact this alone has serious flaws left.

As you can see from the description, the transaction data is stored on the net, and anyone can check the data that was taken in the past. And, of course, the address of the recipient and the public key of the sender are recorded.

In other words, with a public key alone, "third parties can use others' cryptocurrency without permission" can be done. Therefore, in the transaction of cryptocurrency, it is necessary to have a mechanism for checking whether "you are trying to send currency is the owner of the cryptocurrency itself".

By the way, when contracting in reality, the contract may use an autograph signature, a seal, a thumbprint or a blood test etc by the contractor himself to confirm the principal.
That is because they can not be counterfeited by third parties, so they can certainly serve as a basis for showing that they are transactions made by themselves.
Even in the transaction of cryptocurrency, it is only necessary to show that it is the principal by attaching "a signature which can not be written to other than the principal" in the same way, but in the digital data which can be easily copied, "imitation can not be done It is difficult to make a signature.

Therefore, we will be able to "sign" digital data by using secret key.
Technique called ECDSA is used for signature, and advanced mathematical knowledge is needed for this explanation, so although details are omitted here, it is calculated using transaction data and secret key By doing so, you can create "signature data".
Since the signature data can be confirmed correctly by performing calculations for confirmation using the sender's public key, it is possible to find out that currency transmission is done to the principal.
The point is that "If you do not know the secret key of the other party, you can see that the other party has a private key if the signature is correct."
Since it is impossible to copy things that do not understand the contents, someone can not copy the secret key and as long as you do not tell someone the secret key that signature can only be done by himself.




In this way, a mechanism is built to record transactions while preventing spoofing in the cryptocurrency.



Summary and Supplement

Let's review what you learned on this page.
"cryptocurrency account consists of three of address, public key, secret key"
"Public key and address are generated based on secret key"
"Since the address receives the currency, the public key sends the currency, so the private key exists to sign the data"

Also, even if you do not know by only a few times, if you use the same secret key many times, you may find the regularity from the signature data and identify the secret key.
Therefore, it is necessary to periodically issue new secret keys, and new accounts are created each time a secret key is issued.
It is also the role of Wallet to manage several wallets at once.

And another, from here, we will talk about countermeasures against wrongdoing by the technology called "blockchain" important for establishing the cryptocurrency and about the mechanism by which cryptocurrency is issued.