base58前缀
2 个回答
- 投票数
-
- 2019-02-01
Base58通过添加前缀,将字节视为大字节序号并将该大字节序号写入基数58来编码字符.
因此,特定的前缀可以固定Base58中最重要的"数字".
Tezos存储库的
b58_prefix.py
目录中的python脚本scripts
可以帮助找到这些前缀.请注意,要运行它,您将需要此版本的python libpybitcointools
pip install git+https://github.com/vbuterin/pybitcointools.git@aeb0a2bbb8bbfe421432d776c649650eaeb882a5#egg=master
Base58 encodes characters by appending a prefix, treating the bytes as a big endian number and writing that big endian number in base 58.
Therefore, specific prefixes can pin down the most significant "digits" in Base58.
The python script
b58_prefix.py
in thescripts
directory of the Tezos repo can help find those prefixes. Note that to run it you will need this version of the python libpybitcointools
pip install git+https://github.com/vbuterin/pybitcointools.git@aeb0a2bbb8bbfe421432d776c649650eaeb882a5#egg=master
-
如何将字节数组" \ 006 \ 161 \ 159"转换为可以传递给bitcoin.bin_to_b58check函数的magicbyte值? 我发现可以将struct.unpack与字节数组的十六进制值一起使用(生成p2sig(98))`P256_SIGNATURE=struct.unpack('> L',b'\ x36 \ xF0 \ x2C \ x34')[0],但是" \ 006 \ 161 \ 159"只有3个字节,因此无法打包为4个字节的大端整数.How do you convert the byte array `"\006\161\159"` into a magicbyte value that can be passed to the bitcoin.bin_to_b58check function? I discovered that you can use struct.unpack with the hex values of the byte array like this (generates p2sig(98))`P256_SIGNATURE = struct.unpack('>L', b'\x36\xF0\x2C\x34')[0]`, but `"\006\161\159"` is only 3 bytes so it can't be packed into a 4-byte big-endian integer.
- 0
- 2019-02-16
- Luke Youngblood
-
另请参见待定的MR https://gitlab.com/tezos/tezos/-/merge_requests/1528,该文档进一步记录了该脚本.see also the pending MR https://gitlab.com/tezos/tezos/-/merge_requests/1528 that documents this script further.
- 0
- 2020-04-08
- arvidj
-
- 2019-02-01
Base58前缀将始终为设置的输出长度产生带前缀的输出.因此,输入地址为20字节+ 3字节前缀给出了一个带有tz1的36个字符长的地址.
您可以通过猜测和检查来计算这些前缀.
Base58 prefixes will always produce a prefixed output for a set length of output. So the input address is 20 bytes + the 3 byte prefix gives a 36 char long address with tz1.
You calculate these prefixes by guess and check.
Prefix
中的模块
src/lib_crypto/base58.ml
具有诸如let ed25519_public_key_hash = "\006\161\159" (* tz1(36) *)
.人们如何从
"\006\161\159"
中获得tz1(36)
?