summaryrefslogtreecommitdiff
path: root/bip-0137.mediawiki
diff options
context:
space:
mode:
Diffstat (limited to 'bip-0137.mediawiki')
-rw-r--r--bip-0137.mediawiki12
1 files changed, 6 insertions, 6 deletions
diff --git a/bip-0137.mediawiki b/bip-0137.mediawiki
index 7ef89f4..43addba 100644
--- a/bip-0137.mediawiki
+++ b/bip-0137.mediawiki
@@ -25,7 +25,7 @@ This BIP is licensed under the 2-clause BSD license.
==Motivation==
-Since Bitcoin private keys can not only be used to sign Bitcoin transactions, but also any other message, it has become customary to use them to sign various messages for differing purposes. Some applications of signing messages with a Bitcoin private key are as follows: proof of funds for collateral, credit worthiness, enterence to events, airdrops, audits as well as other applications. While there was no BIP written for how to digitally sign messages with Bitcoin private keys with P2PKH addresses it is a fairly well understood process, however with the introduction of Segwit (both in the form of P2SH and bech32) addresses, it is unclear how to distinguish a P2PKH, P2SH, or bech32 address from one another. This BIP proposes a standard signature format that will allow clients to distinguish between the different address formats.
+Since Bitcoin private keys can not only be used to sign Bitcoin transactions, but also any other message, it has become customary to use them to sign various messages for differing purposes. Some applications of signing messages with a Bitcoin private key are as follows: proof of funds for collateral, credit worthiness, entrance to events, airdrops, audits as well as other applications. While there was no BIP written for how to digitally sign messages with Bitcoin private keys with P2PKH addresses it is a fairly well understood process, however with the introduction of Segwit (both in the form of P2SH and bech32) addresses, it is unclear how to distinguish a P2PKH, P2SH, or bech32 address from one another. This BIP proposes a standard signature format that will allow clients to distinguish between the different address formats.
==Specification==
@@ -52,11 +52,11 @@ The header byte has a few components to it. First, it stores something known as
===Procedure for signing/verifying a signature===
-As noted above the signature is composed of three components, the header, r and s values. r/s can be computed with standard ECDSA library functions. Part of the header includes something called a recId. This is part of every ECDSA signature and should be generated by the ECDSA library. The recId is a number between 0 and 3 inclusive. The header is the recId plus a constant which indicates what time of Bitcoin private key this is. For P2PKH uncompressed keys, this value is 27. For P2PKH compressed keys, this value is 31. For P2SH Segwit keys, this value is 35 and for bech32 keys, this value is 35. So, you have the following ranges:
-27-30: P2PKH uncompressed
-31-34: P2PKH compressed
-35-38: Segwit P2SH
-39-42: Segwit Bech32
+As noted above the signature is composed of three components, the header, r and s values. r/s can be computed with standard ECDSA library functions. Part of the header includes something called a recId. This is part of every ECDSA signature and should be generated by the ECDSA library. The recId is a number between 0 and 3 inclusive. The header is the recId plus a constant which indicates what type of Bitcoin address this is. For P2PKH address using an uncompressed public key this value is 27. For P2PKH address using compressed public key this value is 31. For P2SH-P2WPKH this value is 35 and for P2WPKH (version 0 witness) address this value is 39. So, you have the following ranges:
+* 27-30: P2PKH uncompressed
+* 31-34: P2PKH compressed
+* 35-38: Segwit P2SH
+* 39-42: Segwit Bech32
To verify a signature, the recId is obtained by subtracting this constant from the header value.