rust: select checksum by expanded codeword length - #76
BenWestgate wants to merge 3 commits into
Conversation
Account for the HRP expansion when selecting and slicing regular and long checksums. Enforce the invalid 94–95 value gap and update the affected test vectors. Aligns the reference implementation with bitcoin/bips#2258.
Finalize the checksum engine with input_own_target() before appending its residue so from_unchecksummed_string() returns strings that parse. Add a create-parse round-trip test, exact expanded-length boundary tests, and the BIP 93 vectors for 43-47-byte payloads.
|
added the new test vectors from bip-0093. |
|
In 581a472: It's worth commenting that the "expanded length" function differs from the "expanded length" in the BIP, because the BIP includes the checksum symbols while this code does not. Hence comparisons against 81 instead of 94 e.g. This also continues to enforce the 128-symbol maximum, which we should change to enforce the fixed set of allowed lengths. (I know this PR predates the changes to the BIP PR, I'm just writing them out for the record.) |
Restrict master-seed payloads to the six sizes in current BIP-0093, keep checksum selection HRP-agnostic, and update the reference vectors and invalid-length cases.\n\nfrom_seed now creates only secret-index encodings.\n\nValidation: cargo test (14 passed); git diff --check. cargo fmt --check still reports pre-existing formatting drift in unrelated existing code.
BenWestgate
left a comment
There was a problem hiding this comment.
I also fixed the issue with creating shares from bytes. Ready for re-review so the Rust matches bip93 bitcoin/bips master.
| if id.len() != 4 { | ||
| return Err(Error::IdNotLength4(id.len())); | ||
| } | ||
| if share_idx != Fe32::S { |
There was a problem hiding this comment.
the easy fix to constructing mispadded shares from bytes is have this command only work for "S"
Account for the HRP expansion when selecting and slicing regular and long checksums. Enforce the invalid 94–95 value gap and update the affected test vectors.
Aligns the reference implementation with bitcoin/bips#2258.
Closes #75