「Base58Check encoding」の版間の差分

提供: tezos-wiki
移動先: 案内検索
(1版 をインポートしました)
 
(4人の利用者による、間の5版が非表示)
1行目: 1行目:
A modified Base 58 [http://en.wikipedia.org/wiki/Binary-to-text_encoding binary-to-text encoding] known as '''Base58Check''' is used for encoding [[Bitcoin address|Bitcoin addresses]].
+
['Bitcoin address | Bitcoin addresses]をエンコードするために、' '' 'Base58Check' ''として知られている更新されたBase 58 [http://en.wikipedia.org/wiki/Binary-to-text_encodingバイナリからテキストへのエンコーディング] ]
  
More generically, Base58Check encoding is used for encoding byte arrays in Bitcoin into human-typable strings.
+
より一般的には、Base58Checkエンコーディングは、Bitcoinのバイト配列を人間が入力可能な文字列にエンコードするために使用されます。
  
==Background==
+
==背景==
The original Bitcoin client source code explains the reasoning behind base58 encoding:
+
オリジナルのBitcoinクライアントソースコードは、base58エンコーディングの背後にある推論を説明しています。
  
base58.h:
+
base58.h:
  // Why base-58 instead of standard base-64 encoding?
+
  //標準base-64エンコーディングの代わりにbase-58を使用する理由
  // - Don't want 0OIl characters that look the same in some fonts and
+
  // - いくつかのフォントで同じように見える0の文字を望んではいけません。
  //     could be used to create visually identical looking account numbers.
+
  //視覚的に同じ見た目の口座番号を作成するために使用できます。
  // - A string with non-alphanumeric characters is not as easily accepted as an account number.
+
  // - 英数字以外の文字列は、口座番号ほど簡単には受け入れられません。
  // - E-mail usually won't line-break if there's no punctuation to break at.
+
  // - 電子メールは通常、折り返す句読点がない場合は改行しません。
  // - Doubleclicking selects the whole number as one word if it's all alphanumeric.
+
  // - Doubleclickingは、数字がすべて英数字の場合は1つの単語として選択します。
  
==Features of Base58Check==
+
== Base58Checkの機能==
Base58Check has the following features:
+
Base58Checkには、次の機能があります。
* An arbitrarily sized payload.
+
*任意のサイズのペイロード。
* A set of 58 alphanumeric symbols consisting of easily distinguished uppercase and lowercase letters (0OIl are not used)
+
*簡単に区別できる大文字と小文字からなる58文字の英数字記号のセット(0101は使用されません)
* One byte of version/application information.  Bitcoin addresses use 0x00 for this byte (future ones may use 0x05).
+
* 1バイトのバージョン/アプリケーション情報。 Bitcoinアドレスはこのバイトに0x00を使用します(将来の0x05を使用する可能性があります)。
* Four bytes (32 bits) of SHA256-based error checking code.  This code can be used to automatically detect and possibly correct typographical errors.
+
* 4バイト(32ビット)のSHA256ベースのエラーチェックコード。このコードは、誤植を自動的に検出し、訂正するために使用できます。
* An extra step for preservation of leading zeroes in the data.
+
*データの先行ゼロを保存するための追加ステップ。
  
==Creating a Base58Check string==
+
== Base58Check文字列の作成==
A Base58Check string is created from a version/application byte and payload as follows.
+
Base58Check文字列は、バージョン/アプリケーションバイトとペイロードから次のように作成されます。
# Take the version byte and payload bytes, and concatenate them together (bytewise).
+
#バージョンのバイトとペイロードのバイトを取り出し、一緒に連結します(バイト単位)。
# Take the first four bytes of SHA256(SHA256(results of step 1))
+
#SHA256の最初の4バイトを取得する(SHA256(ステップ1の結果))
# Concatenate the results of step 1 and the results of step 2 together (bytewise).
+
#手順1の結果と手順2の結果を結合します(バイト単位)。
# Treating the results of step 3 - a series of bytes - as a single big-endian bignumber, convert to base-58 using normal mathematical steps (bignumber division) and the base-58 alphabet described below.  The result should be normalized to not have any leading base-58 zeroes (character '1').
+
#ステップ3の結果を一連のバイトとして扱う - 単一のビッグエンディアンのbignumberとして、通常の数学的ステップ(bignumber除算)と下で説明するbase-58アルファベットを使用してbase-58に変換します。結果は、先行するbase-58のゼロ(文字 '1')を持たないように正規化する必要があります。
# The leading character '1', which has a value of zero in base58, is reserved for representing an entire leading zero '''byte''', as when it is in a leading position, has no value as a base-58 symbol.  There can be one or more leading '1's when necessary to represent one or more leading zero bytes.  Count the number of leading zero bytes that were the result of step 3 (for old Bitcoin addresses, there will always be at least one for the version/application byte; for new addresses, there will never be any).  Each leading zero byte shall be represented by its own character '1' in the final result.
+
#先頭の文字 '1'は、base58の値が0であり、先行ゼロの ''バイト '' '全体を表すために予約されています。シンボル。 1つ以上の先行ゼロバイトを表すのに必要なときに、1つ以上の先行する '1'が存在することがあります。ステップ3の結果であった先頭の0バイトの数を数えます(古いBitcoinアドレスの場合、バージョン/アプリケーションバイトには常に1つ以上あります;新しいアドレスの場合は決して存在しません)。先頭の各ゼロバイトは、最終結果においてそれ自身の文字「1」によって表される。
# Concatenate the 1's from step 5 with the results of step 4.  '''This is the Base58Check result.'''
+
#ステップ5の1をステップ4の結果と連結します。 '' 'これはBase58Checkの結果です。' ''
A more detailed example is provided on the page describing the [[Technical_background_of_version_1_Bitcoin_addresses#How_to_create_Bitcoin_Address | technical background]] of the bitcoin address.
+
より詳細な例は、[[Technical_background_of_version_1_Bitcoin_addresses#How_to_create_Bitcoin_Address |テクニカルバックグラウンド]]
  
==Encoding a Bitcoin address==
+
== Bitcoinアドレスのエンコード==
Bitcoin addresses are implemented using the Base58Check encoding of the hash of either:
+
Bitcoinアドレスは、次のいずれかのハッシュのBase58Checkエンコードを使用して実装されます。
* Pay-to-script-hash (p2sh): payload is: <code>[[RIPEMD160]]([[SHA256]]('''redeemScript'''))</code> where '''redeemScript''' is a script the wallet knows how to spend; version <code>0x05</code> (these addresses begin with the digit '3')
+
'' 'redeemScript' ''))</ code>ここで、 '' redeemScript ''は、 'は、財布がどのように使うべきかを知っているスクリプトです。バージョン<code> 0x05 </ code>(これらのアドレスは数字「3」で始まります)
* Pay-to-pubkey-hash (p2pkh): payload is <code>[[RIPEMD160]]([[SHA256]]('''ECDSA_publicKey'''))</code> where '''ECDSA_publicKey''' is a public key the wallet knows the private key for; version <code>0x00</code> (these addresses begin with the digit '1')
+
Payload to Pubkey-Hash(p2pkh):ペイロードは<code> [[RIPEMD160]]['' 'ECDSA_publicKey' ''))</ code>ウォレットが秘密鍵を知っている公開鍵です。バージョン<code> 0x00 </ code>(これらのアドレスは数字「1」で始まります)
  
The resulting hash in both of these cases is always exactly 20 bytes.
+
これらの場合のハッシュ結果は常に正確に20バイトです。
These are big-endian (most significant byte first).  (Beware of [[bignumber]] implementations that clip leading 0x00 bytes, or prepend extra 0x00 bytes to indicate sign - your code must handle these cases properly or else you may generate valid-looking addresses which can be sent to, but cannot be spent from - which would lead to the permanent loss of coins.)
+
これらはビッグエンディアンです(最上位バイトが最初です)。 (先頭の0x00バイトをクリップする[[bignumber]]実装に注意するか、または符号を示すために余分な0x00バイトを前に付けてください - あなたのコードはこれらのケースを適切に処理しなければなりません。そうでなければ、送信することは可能ですが、それは硬貨の恒久的な損失につながります)。
  
==Encoding a private key==
+
==秘密鍵の符号化==
Base58Check encoding is also used for encoding [[private key|ECDSA private keys]] in the [[wallet import format]].
+
Base58Checkエンコードは、[[ウォレットのインポート形式]][[秘密鍵| ECDSA秘密鍵]]のエンコードにも使用されます。
This is formed exactly the same as a Bitcoin address, except that 0x80 is used for the version/application byte, and the payload is 32 bytes instead of 20 (a private key in Bitcoin is a single 32-byte unsigned big-endian integer).
+
これは、バージョン/アプリケーションバイトに0x80が使用され、ペイロードが20ではなく32バイトであることを除いて、Bitcoinアドレスとまったく同じように形成されます(Bitcoinの秘密鍵は単一の32バイトの符号なしビッグエンディアン整数です) 。
For private keys associated with an uncompressed public key, such encodings will always yield a 51-character string that starts with '5', or more specifically, either '5H', '5J', or '5K'.
+
圧縮されていない公開鍵に関連付けられた秘密鍵の場合、そのようなエンコーディングは常に '5'、またはより具体的には '5H''5J'または '5K'で始まる51文字の文字列を生成します。
  
==Base58 symbol chart==
+
== Base58シンボルチャート==
The Base58 symbol chart used in Bitcoin is specific to the Bitcoin project and is not intended to be the same as any other Base58 implementation used outside the context of Bitcoin (the characters excluded are: 0, O, I, and l).
+
Bitcoinで使用されるBase58シンボルチャートは、Bitcoinプロジェクトに固有のもので、Bitcoinのコンテキスト外で使用される他のBase58実装と同じではありません(0、O、I、およびl以外の文字は除外されます)。
{| class="wikitable"  
+
{| class = "wikitable"
|-
+
|- !値
!Value
+
!キャラクター
!Character
+
!
!Value
+
!キャラクター
!Character
+
!
!Value
+
!キャラクター
!Character
+
!
!Value
+
!キャラクター
!Character
+
!
|-
+
|-  
|0
+
| 0
|1
+
| 1
|1
+
| 1
|2
+
| 2
|2
+
| 2
|3
+
| 3
|3
+
| 3
|4
+
| 4
|-
+
|-  
|4
+
| 4
|5
+
| 5
|5
+
| 5
|6
+
| 6
|6
+
| 6
|7
+
| 7
|7
+
| 7
|8
+
| 8
|-
+
|-  
|8
+
| 8
|9
+
| 9
|9
+
| 9
|A
+
| A
|10
+
| 10
|B
+
| B
|11
+
| 11
|C
+
| C
|-
+
|-  
|12
+
| 12
|D
+
| D
|13
+
| 13
|E
+
| E
|14
+
| 14
|F
+
| F
|15
+
| 15
|G
+
| G
|-
+
|-  
|16
+
| 16
|H
+
| H
|17
+
| 17
|J
+
| J
|18
+
| 18
|K
+
| K
|19
+
| 19
|L
+
| L
|-
+
|-  
|20
+
| 20
|M
+
| M
|21
+
| 21
|N
+
| N
|22
+
| 22
|P
+
| P
|23
+
| 23
|Q
+
| Q
|-
+
|-  
|24
+
| 24
|R
+
| R
|25
+
| 25
|S
+
| S
|26
+
| 26
|T
+
| T
|27
+
| 27
|U
+
| U
|-
+
|-  
|28
+
| 28
|V
+
| V
|29
+
| 29
|W
+
| W
|30
+
| 30
|X
+
| X
|31
+
| 31
|Y
+
| Y
|-
+
|-  
|32
+
| 32
|Z
+
| Z
|33
+
| 33
|a
+
| a
|34
+
| 34
|b
+
| b
|35
+
| 35
|c
+
| c
|-
+
|-  
|36
+
| 36
|d
+
| d
|37
+
| 37
|e
+
| e
|38
+
| 38
|f
+
| f
|39
+
| 39
|g
+
| g
|-
+
|-  
|40
+
| 40
|h
+
| h
|41
+
| 41
|i
+
| i
|42
+
| 42
|j
+
| j
|43
+
| 43
|k
+
| k
|-
+
|-  
|44
+
| 44
|m
+
| m
|45
+
| 45
|n
+
| n
|46
+
| 46
|o
+
| o
|47
+
| 47
|p
+
| p
|-
+
|-  
|48
+
| 48
|q
+
| q
|49
+
| 49
|r
+
| r
|50
+
| 50
|s
+
| s
|51
+
| 51
|t
+
| t
|-
+
|-  
|52
+
| 52
|u
+
|あなた
|53
+
| 53
|v
+
| v
|54
+
| 54
|w
+
| w
|55
+
| 55
|x
+
| x
|-
+
|-  
|56
+
| 56
|y
+
| y
|57
+
| 57
|z
+
| z
 
|}
 
|}
  
The algorithm for encoding address_byte_string (consisting of 1-byte_version + hash_or_other_data + 4-byte_check_code) is
+
address_byte_stringを符号化するアルゴリズム(1バイトのバージョン+ハッシュまたはその他のデータ+ 4バイトのチェックコードからなる)は、
  
 
     code_string = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
 
     code_string = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
     x = convert_bytes_to_big_integer(hash_result)
+
     x = convert_bytes_to_big_integer(hash_result)
 
      
 
      
 
     output_string = ""
 
     output_string = ""
 
      
 
      
     while(x > 0)
+
     一方、(x> 0)
 
         {
 
         {
             (x, remainder) = divide(x, 58)
+
             (x、剰余)=除算(x、58)
             output_string.append(code_string[remainder])
+
             output_string.append(code_string [remainder]
 
         }
 
         }
 
      
 
      
     repeat(number_of_leading_zero_bytes_in_hash)
+
     繰り返し(number_of_leading_zero_bytes_in_hash)
 
         {
 
         {
         output_string.append(code_string[0]);
+
         output_string.append(code_string [0];
 
         }
 
         }
 
      
 
      
     output_string.reverse();
+
     output_string.reverse();
  
==Version bytes==
+
==バージョンバイト==
Here are some common version bytes:
+
ここにいくつかの共通バージョンのバイトがあります。
  
{| class="wikitable"  
+
{| class = "wikitable"
|-
+
|-  
!Decimal version
+
!10進数バージョン
!Leading symbol
+
!先頭のシンボル
!Use
+
!つかいます
|-
+
|-  
|0
+
| 0
|1
+
| 1
|Bitcoin pubkey hash
+
| Bitcoin pubkey hash
|-
+
|-  
|5
+
| 5
|3
+
| 3
|Bitcoin script hash
+
| Bitcoinスクリプトハッシュ
|-
+
|-  
|21
+
| 21
|4
+
| 4
|Bitcoin (compact) public key (proposed)
+
| Bitcoin(コンパクト)公開鍵(提案)
|-
+
|-  
|52
+
| 52
|M or N
+
| MまたはN
|Namecoin pubkey hash
+
| Namecoin pubkey hash
|-
+
|-  
|128
+
| 128
|5
+
| 5
|Private key
+
|秘密鍵
|-
+
|-  
|111
+
| 111
|m or n
+
| mまたはn
|Bitcoin testnet pubkey hash
+
| Bitcoin testnet pubkeyハッシュ
|-
+
|-  
|196
+
| 196
|2
+
| 2
|Bitcoin testnet script hash
+
| Bitcoin testnetスクリプトハッシュ
 
|}
 
|}
[[List of address prefixes]] is a more complete list.
+
[[アドレスプレフィックス一覧]]より完全なリストです。
  
== See Also ==
+
==関連項目==
* [http://lenschulwitz.com/base58 Online Base58 Decoder, Encoder, and Validator]
+
* [http://lenschulwitz.com/base58オンラインBase58デコーダ、エンコーダ、バリデータ]
  
== Source code ==
+
==ソースコード==
* [https://github.com/bitcoin/bitcoin/blob/master/src/base58.cpp "Satoshi" C++ codebase (decode and encode, no external libraries needed)]
+
* [https://github.com/bitcoin/bitcoin/blob/master/src/base58.cpp "Satoshi" C ++コードベース(デコードとエンコード、外部ライブラリは不要)]
* [https://github.com/luke-jr/libbase58 libbase58 C code (decode and encode, no external libraries needed)]
+
* [https://github.com/luke-jr/libbase58 libbase58 Cコード(デコードとエンコード、外部ライブラリは不要)]
* [http://lenschulwitz.com/b58/base58perl.txt Base58 Decode, Encode, and Validate in Perl]
+
* [http://lenschulwitz.com/b58/base58perl.txt PerlでBase58のデコード、エンコード、検証]
  
[[Category:Technical]]
+
[[Category:技術]]
  
[[es:Codificación Base58Check]]
+
[[es:CodificaciónBase58Check]]

2018年5月11日 (金) 13:05時点における最新版

['Bitcoin address | Bitcoin addresses]をエンコードするために、' 'Base58Check' として知られている更新されたBase 58 [1] ]。

より一般的には、Base58Checkエンコーディングは、Bitcoinのバイト配列を人間が入力可能な文字列にエンコードするために使用されます。

背景[編集]

オリジナルのBitcoinクライアントソースコードは、base58エンコーディングの背後にある推論を説明しています。

base58.h:

//標準base-64エンコーディングの代わりにbase-58を使用する理由
// - いくつかのフォントで同じように見える0の文字を望んではいけません。
//視覚的に同じ見た目の口座番号を作成するために使用できます。
// - 英数字以外の文字列は、口座番号ほど簡単には受け入れられません。
// - 電子メールは通常、折り返す句読点がない場合は改行しません。
// - Doubleclickingは、数字がすべて英数字の場合は1つの単語として選択します。

Base58Checkの機能[編集]

Base58Checkには、次の機能があります。

  • 任意のサイズのペイロード。
  • 簡単に区別できる大文字と小文字からなる58文字の英数字記号のセット(0101は使用されません)
  • 1バイトのバージョン/アプリケーション情報。 Bitcoinアドレスはこのバイトに0x00を使用します(将来の0x05を使用する可能性があります)。
  • 4バイト(32ビット)のSHA256ベースのエラーチェックコード。このコードは、誤植を自動的に検出し、訂正するために使用できます。
  • データの先行ゼロを保存するための追加ステップ。

Base58Check文字列の作成[編集]

Base58Check文字列は、バージョン/アプリケーションバイトとペイロードから次のように作成されます。 #バージョンのバイトとペイロードのバイトを取り出し、一緒に連結します(バイト単位)。 #SHA256の最初の4バイトを取得する(SHA256(ステップ1の結果)) #手順1の結果と手順2の結果を結合します(バイト単位)。 #ステップ3の結果を一連のバイトとして扱う - 単一のビッグエンディアンのbignumberとして、通常の数学的ステップ(bignumber除算)と下で説明するbase-58アルファベットを使用してbase-58に変換します。結果は、先行するbase-58のゼロ(文字 '1')を持たないように正規化する必要があります。 #先頭の文字 '1'は、base58の値が0であり、先行ゼロの バイト '全体を表すために予約されています。シンボル。 1つ以上の先行ゼロバイトを表すのに必要なときに、1つ以上の先行する '1'が存在することがあります。ステップ3の結果であった先頭の0バイトの数を数えます(古いBitcoinアドレスの場合、バージョン/アプリケーションバイトには常に1つ以上あります;新しいアドレスの場合は決して存在しません)。先頭の各ゼロバイトは、最終結果においてそれ自身の文字「1」によって表される。 #ステップ5の1をステップ4の結果と連結します。 'これはBase58Checkの結果です。' より詳細な例は、テクニカルバックグラウンド

Bitcoinアドレスのエンコード[編集]

Bitcoinアドレスは、次のいずれかのハッシュのBase58Checkエンコードを使用して実装されます。 ( 'redeemScript' ))</ code>ここで、 redeemScript は、 'は、財布がどのように使うべきかを知っているスクリプトです。バージョン 0x05 </ code>(これらのアドレスは数字「3」で始まります) Payload to Pubkey-Hash(p2pkh):ペイロードは<code> RIPEMD160([ 'ECDSA_publicKey' ))</ code>ウォレットが秘密鍵を知っている公開鍵です。バージョン<code> 0x00 </ code>(これらのアドレスは数字「1」で始まります)

これらの場合のハッシュ結果は常に正確に20バイトです。 これらはビッグエンディアンです(最上位バイトが最初です)。 (先頭の0x00バイトをクリップするbignumber実装に注意するか、または符号を示すために余分な0x00バイトを前に付けてください - あなたのコードはこれらのケースを適切に処理しなければなりません。そうでなければ、送信することは可能ですが、それは硬貨の恒久的な損失につながります)。

秘密鍵の符号化[編集]

Base58Checkエンコードは、ウォレットのインポート形式 ECDSA秘密鍵のエンコードにも使用されます。 これは、バージョン/アプリケーションバイトに0x80が使用され、ペイロードが20ではなく32バイトであることを除いて、Bitcoinアドレスとまったく同じように形成されます(Bitcoinの秘密鍵は単一の32バイトの符号なしビッグエンディアン整数です) 。 圧縮されていない公開鍵に関連付けられた秘密鍵の場合、そのようなエンコーディングは常に '5'、またはより具体的には '5H'、 '5J'または '5K'で始まる51文字の文字列を生成します。

Base58シンボルチャート[編集]

Bitcoinで使用されるBase58シンボルチャートは、Bitcoinプロジェクトに固有のもので、Bitcoinのコンテキスト外で使用される他のBase58実装と同じではありません(0、O、I、およびl以外の文字は除外されます)。

キャラクター キャラクター キャラクター キャラクター
0 1 1 2 2 3 3 4
4 5 5 6 6 7 7 8
8 9 9 A 10 B 11 C
12 D 13 E 14 F 15 G
16 H 17 J 18 K 19 L
20 M 21 N 22 P 23 Q
24 R 25 S 26 T 27 U
28 V 29 W 30 X 31 Y
32 Z 33 a 34 b 35 c
36 d 37 e 38 f 39 g
40 h 41 i 42 j 43 k
44 m 45 n 46 o 47 p
48 q 49 r 50 s 51 t
52 あなた 53 v 54 w 55 x
56 y 57 z

address_byte_stringを符号化するアルゴリズム(1バイトのバージョン+ハッシュまたはその他のデータ+ 4バイトのチェックコードからなる)は、

   code_string = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
   x = convert_bytes_to_big_integer(hash_result)
   
   output_string = ""
   
   一方、(x> 0)
       {
           (x、剰余)=除算(x、58)
           output_string.append(code_string [remainder])
       }
   
   繰り返し(number_of_leading_zero_bytes_in_hash)
       {
       output_string.append(code_string [0]);
       }
   
   output_string.reverse();

バージョンバイト[編集]

ここにいくつかの共通バージョンのバイトがあります。

10進数バージョン 先頭のシンボル つかいます
0 1 Bitcoin pubkey hash
5 3 Bitcoinスクリプトハッシュ
21 4 Bitcoin(コンパクト)公開鍵(提案)
52 MまたはN Namecoin pubkey hash
128 5 秘密鍵
111 mまたはn Bitcoin testnet pubkeyハッシュ
196 2 Bitcoin testnetスクリプトハッシュ

アドレスプレフィックス一覧より完全なリストです。

関連項目[編集]

ソースコード[編集]

Category:技術

es:CodificaciónBase58Check