InvalidChecksum fields disagree with their documentation
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
- v1 · created · 2026-11-03 03:48 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" } - v2 · edited · 2026-11-03 03:51 UTC
{ "evidence_url": "https://github.com/MasWag/crate-proofs/blob/1c8a2741db2110c65d2457d36723612560bbe5f4/bs58/0.5.1/evidence/reproduce-findings/src/main.rs", "edit_version": 1 }