Skip to content

Commit 530c4fb

Browse files
authored
Merge pull request bitcoin#924 from Coding-Enthusiast/patch-3
[BIP-0137] Correct small mistakes
2 parents 357419a + 9bb9824 commit 530c4fb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

bip-0137.mediawiki

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ The header byte has a few components to it. First, it stores something known as
5252

5353
===Procedure for signing/verifying a signature===
5454

55-
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:
56-
27-30: P2PKH uncompressed
57-
31-34: P2PKH compressed
58-
35-38: Segwit P2SH
59-
39-42: Segwit Bech32
55+
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:
56+
* 27-30: P2PKH uncompressed
57+
* 31-34: P2PKH compressed
58+
* 35-38: Segwit P2SH
59+
* 39-42: Segwit Bech32
6060
6161
To verify a signature, the recId is obtained by subtracting this constant from the header value.
6262

0 commit comments

Comments
 (0)