NEO study notes, from WIF to address

Author: Li Jianying

Original link: http://www.cnblogs.com/crazylights/p/8166690.html


The beginning of 2018, I would like to wish you a new year, Happy Neo Year.

At the beginning of the new year, I have to write something, so I plan to continue to open a series of study notes and analyze NEO carefully bit by bit.

Today, let's talk about the relationship from WIF to address.

 

Just a picture:

or his simpler version

OK, it's done. ^_^

 

Of course, if you want to figure out the specific calculation method between them, let's look down.

Flow Description

Details about WIF

L13wAkUX1SAx6K9zztkS8RjxDMedBEzbtgZSZRYKUUBMP23BEgLM

This is a WIF, this string of things has no meaning, no need to look for its meaning, it is a byte58 encoded string

Unfortunately base58 is not as popular as base64, so it is difficult to find web decoding tools, we can analyze them with two lines of code.

8072520405d2ab00326dbcacfddd350b01222a7cc9efc5f304f742077ec9ade4630178a41006

This string of things is the real data saved in Wif

The red part is the private key, the yellow part is the added salt, the fixed information. The blue part is a hash of the first 34 bytes, and four bytes of hash are taken.

It can be seen from this

1. WIF can be exchanged with private key

2. WIF saves the hash and has a self-verification function. It is not a legal WIF if you just type a string.

private key

NEO's public and private key verification method uses the ECC elliptic curve algorithm.

The basic mechanism of this type of asymmetric encryption algorithm is as follows. You keep the private key and the public key is public. You sign a string of data with your private key.

Others can use the data, signature, and public key to determine whether the three match and whether the signature is valid.

The most important authorization authentication method on the NEO blockchain is signature, so the private key is very important and should be protected well

public key

The public key is part of the private key and can be calculated from the private key, but conversely, the public key cannot calculate the private key.

This calculation is one-way

address script

The address script, which looks like it adds a byte to the front and back of the public key

In fact, he is a smart contract. If he decompiles it,

that is:

PushBytes[pubkey]

CheckSig

这样两条指令。

当你访问你的账户的时候,比如用你的账户给别人转账,就会调用这个合约来验证。

这个合约的意义是用你的公钥和交易数据 和交易签名进行验证。

只有你签名的合约才能动你的账户

地址ScriptHash

地址ScriptHash就是地址脚本取了个Hash

一次sha256,一次ripemd160

地址

地址和WIF很相似,不过他是ScriptHash 加了盐,加了验证功能,然后base58编码

 

简化版的图是怎么回事

因为私钥和WIF可以互相转换,通常我们在讲到私钥的时候,WIF也是私钥,私钥也是私钥,不会分那么清楚。

因为地址ScriptHash 和 地址字符串可以互相转换,通常我们在讲到地址的时候,也不会分那么清楚

另外因为地址脚本大多数用户根本接触不到,在和一般用户谈论这个话题的时候也可以省略掉

所以这个关系图可以简化如下

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325675766&siteId=291194637