Skip to content

checksum verification isn't correct #10

@dooglus

Description

@dooglus
> base58Check.encode(base58Check.decode('mqqa8xSMVDyf9QxihGnPtap6Mh6qemUkcz'));
'mqqa8xSMVDyf9QxihGnPtap6Mh6qemUkcu'

Note I changed the last character of the input string to a 'z', making the checksum invalid, but the error wasn't detected.

Something like this fixes the error:

--- Backup/base58.js.~1~    2014-05-24 07:06:08.000000000 -0700
+++ base58.js   2014-11-30 16:53:50.625920249 -0800
@@ -94,7 +94,7 @@
     var hash = doubleSHA256(data);
     var hash4 = hash.slice(0, 4);

-    if (csum.toString() != hash4.toString()) {
+    if (JSON.stringify(csum) != JSON.stringify(hash4)) {
       throw new Error("checksum mismatch");
     }

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