## TP's Go Bitcoin Tests - Private keys

<- Go back.

### Wallet import format to private key

1 - Wallet import format

2 - Converting WIF as Base58 string to byte array

3 - Dropping last 4 checksum bytes

4 - Dropping first byte. This is the private key

### Private key to wallet import format

1 - Private key

2 - Add 0x80 byte to the front

3 - SHA-256 hash of 2

4 - SHA-256 hash of 3

5 - First 4 bytes of 4, this is the checksum

6 - Adding 5 at the end of 2

7 - Base58 encoding of 6

### WIF checksum checking

1 - Wallet import format

2 - Converting WIF as Base58 string to byte array

3 - Dropping last 4 checksum bytes from 2

4 - SHA-256 hash of 3

5 - SHA-256 hash of 4

6 - First 4 bytes of 5, this is the calculated checksum

7 - Take the last 4 bytes of 2, this is the original checksum

Are 6 and 7 identical? Does 2 start with a 0x80 byte? If so, success!