proofs.rs

InvalidChecksum fields disagree with their documentation

InvalidChecksum fields disagree with their documentation

Found in Report #19 v1 · Updated 2026-11-03 23:44 UTC

Description

InvalidChecksum returns field values in the reverse order from their documentation.

Steps to Reproduce

With bs58 0.5.1 and the check feature enabled, run this example. Its success reproduces the discrepancy:

let input = bs58::encode([42, 0, 0, 0, 0]).into_string();
assert_eq!(
    bs58::decode(input).with_check(None).into_vec(),
    Err(bs58::decode::Error::InvalidChecksum {
        checksum: [255, 18, 44, 14],
        expected_checksum: [0, 0, 0, 0],
    })
);
Expected Behavior

The field documentation describes checksum as supplied and expected_checksum as calculated.

Actual Behavior

The supplied checksum is [0, 0, 0, 0]; the calculated checksum is [255, 18, 44, 14]. The returned values are reversed. The same mismatch occurs with cb58. Invalid checksums are still rejected, and the Display implementation follows the returned field order; code interpreting the structured fields according to their documentation receives reversed diagnostics.

Environment

bs58 0.5.1 with check; the analogous path uses cb58.

Change history
  1. v1 · created · 2026-11-03 23:44 UTC
    {
      "title": "InvalidChecksum fields disagree with their documentation",
      "body": "## Description\n\n`InvalidChecksum` returns field values in the reverse order from their documentation.\n\n## Steps to Reproduce\n\nWith bs58 0.5.1 and the `check` feature enabled, run this example. Its success reproduces the discrepancy:\n\n```rust\nlet input = bs58::encode([42, 0, 0, 0, 0]).into_string();\nassert_eq!(\n    bs58::decode(input).with_check(None).into_vec(),\n    Err(bs58::decode::Error::InvalidChecksum {\n        checksum: [255, 18, 44, 14],\n        expected_checksum: [0, 0, 0, 0],\n    })\n);\n```\n\n## Expected Behavior\n\nThe field documentation describes `checksum` as supplied and `expected_checksum` as calculated.\n\n## Actual Behavior\n\nThe supplied checksum is `[0, 0, 0, 0]`; the calculated checksum is `[255, 18, 44, 14]`. The returned values are reversed. The same mismatch occurs with `cb58`. Invalid checksums are still rejected, and the `Display` implementation follows the returned field order; code interpreting the structured fields according to their documentation receives reversed diagnostics.\n\n## Environment\n\nbs58 0.5.1 with `check`; the analogous path uses `cb58`.",
      "validity": "reported",
      "upstream_status": "not_reported"
    }

Read and join the discussion on the report →