Skip to content

Chapter 4 - checksum should be double hashed? #277

Open
@ArmanTheParman

Description

@ArmanTheParman

On page 83 (chapter 4 under "Address Format", there is this code:

def encode_base58_checksum(b):
return encode_base58(b + hash256(b)[:4])

I believe the data should be hashed twice before extracting the checksum.
Also, hash256 isn't part of hashlib library, I used sha256.
I suppose if hash256 is a custom double sha256 function, then nothing to see here, move along folks.

I'm getting the right answer for the test with this code:

def base58check_encode(b):
checksum = hashlib.sha256(hashlib.sha256(b).digest()).digest()[:4]
return base58.b58encode(b + checksum)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions