Summary
Generalize codex32 so that the human-readable part is not restricted to
ms.
This PR is based on top of behavior neutral #2285.
BIP-32 master seeds and their shares continue to use ms, while other
applications can use their own human-readable parts.
Changes
- Specify the human-readable part as in BIP-173.
- Include the human-readable part in checksum construction and verification.
- Count its BIP-173 expansion toward the checksum length limits.
- Rename the inline
ms32checksum and interpolation helpers tocodex32. - Require all shares in a set to use the same human-readable part.
- Clarify that the interpolation helpers operate on the data part and do not check the valid set conditions.
- Limit fresh-secret generation to applications that accept every payload, or require rejection sampling otherwise.
- Do not recommend correcting errors in the human-readable part unless the application specifies how.
- Update the existing invalid vectors whose interpretation changes when other human-readable parts become valid.
- Add test vectors covering:
- the registered
clhuman-readable part used by Core Lightning; - checksum selection affected by human-readable-part length;
- an 83-character human-readable part containing
1; - expanded lengths 94 and 95;
- a checksum computed over an uppercase human-readable part;
- a human-readable part longer than 83 characters.
- the registered
Strings using ms are unchanged.
Testing
The codex32 checksum functions were checked against the previous ms32
functions for ms over random data parts of every length from 0 through 1029
symbols, including both checksum variants, the 94–95 expanded-length gap, and
lengths beyond 1023.
The new vectors were checked with both the specification's Python code and an
independent implementation, python-codex32. They agree except that
python-codex32 does not yet enforce the 83-character human-readable-part
limit.