BIP93: Refactor format and seed sections - #2285
BenWestgate wants to merge 6 commits into
Conversation
Group the regular and long checksum definitions in the codex32 format section. Move the master-seed application profile to the end of the specification and keep seed-specific checksum motivation in the rationale. This is a behavior-neutral organization change on top of the bitcoin#2258 profile commit.
|
eb7bb6c is ready for review. Most of the PR description is extra seasoning or nice-to-have house-keeping before I rebase #2040 on this PR. @roconnor if you'd like you can propose a bits vs bytes consistency fixup commit and I will add it to this PR. I'll add commits for any cACK'd idea in the description |
I wouldn't mind adding this here in a separate commit. Up to you.
Let's defer to another PR. This might require some discussion about whether we should allow shares to bytes, whether we should allow bytes to shares if you're super careful, etc etc
Yes please! |
|
In the existing text we say "String validity may be further restricted by specific applications, see Master seed format below.". This is a run-on sentence. Can we change the "," to a "." and capitalize See? (This is unrelated to the current diff but this PR seems like we could fit it in here since you also fixed a couple other typos/formatting things.) Lol @ the old text saying Other than these nits eb7bb6c looks good to me. This PR has no functional changes and is easy to review. |
|
bits vs bytes belongs here, anything non-functional, really. I will add a changelog and fix that run-on sentence. I dislike it too, too broad.
I added the correct number (but as base10 exponent) back in BenWestgate@98935ff we repeat numbers and phrases a lot in this standard. Did you ACK this TOC? Doc should start with shares if they want to do secret sharing (and read this section), as they are the most general codex32 string, they all have the same random payloads (unless we want to permit SLIP-0039 style constraints), while secrets are already application specific decoded/encoded. |
Yeah, I think that's a good idea.
Yep. |
Keep the common format rules and checksum properties in one place, and replace the broad application-validity sentence with a concrete reference to the master seed requirements. Remove the redundant symbol encoder and decoder examples. Preserve their validation rules in the format and master seed text, including the encoded-length restriction for both secrets and shares. Retained checksum and interpolation code is unchanged. Checked retained Python ASTs against eb7bb6c, all 36 valid and 55 invalid vector occurrences, all six size mappings, legacy sizes, 1024 header combinations, checksum boundaries, share recovery, and nonzero padding. Link-format, README table, and whitespace checks pass. Refs: bitcoin#2258, bitcoin#2285
Let readers implement unshared master seeds from the format and master seed sections without reading the secret sharing procedures. Keep the common header and unshared-secret rules under codex32, and group share generation and recovery under SSSS-awareness. Give checksum and error correction one TOC entry each. Use bold labels for the individual checksums and generation cases, and preserve both MediaWiki anchors and GitHub permalinks for demoted headings. Put the interpolation helpers with generation and its recovery wrapper afterward. Retained executable code is unchanged. Checked the retained Python ASTs, existing valid/invalid vectors, size mappings, header combinations, checksum boundaries, recovery, and padding. Inspected the rendered TOC and table and checked fragment targets. Link-format, README table, and whitespace checks pass. Refs: bitcoin#2285
Describe seed sizes in bits in the encoding instructions, checksum rationale, and retained-size list, matching generation and the vectors. Keep bytes for decoded output and the historical contiguous byte-size range, and retain both units in the size table. The supported sizes and all numeric constraints are unchanged. The existing rationale already explains that BIP39 produces 512-bit seeds. Checked retained Python ASTs, all existing vector occurrences, size mappings, header combinations, checksum boundaries, recovery, padding, and rendered markup. Link-format, README table, and whitespace checks pass. Refs: bitcoin#2258, bitcoin#2285
Add a reverse-chronological draft changelog and matching Version header so readers can distinguish the earlier checksum-boundary and seed-size changes from this behavior-neutral reorganization. Assign retrospective versions to significant revisions and use their upstream integration dates, rather than individual patch author dates. Keep the Draft status and BSD-3-Clause license unchanged. Checked the historical entries against first-parent upstream history, the version and date ordering, and the metadata-only diff. Python ASTs, existing vectors, size and checksum boundaries, header combinations, recovery, padding, rendered markup, link formatting, README table, and whitespace checks pass. Refs: bitcoin#2258, bitcoin#2285
|
I preserved reviewed commit eb7bb6c and appended four commits. I saw BIP-0380 did put Checksum in the TOC and since our Error Correction is not an after thought or warning like BIP-0173 decided both Checksum and Error Correct deserved a seat in the TOC. I put regular and long checksums as bold headings inside Checksum section. |
|
مرحبًا |
Define the integer-list representation once in the SSSS-awareness introduction, before either procedure needs it. Move the unchanged interpolation helpers there too, so recovery does not depend on code inside Generating shares. Describe interpolation's arguments and result beside its definition and refer to the shared representation from both generation and recovery. State that both checksum variants use the same procedures without an early reference to the interpolation function. Label the existing casing rules and remove the unnecessary word "workflows" from the rationale. No algorithms, validity conditions, version, or changelog entries change. Checked all Python blocks are byte-identical and that vectors, procedure conditions, casing rules, headings, anchors, and metadata are unchanged. Sixteen recovery cases pass using only the shared introduction and recovery snippets, covering regular and long checksums. Existing vector, size, header, checksum-boundary, recovery, and padding checks also pass. Local rendering, link formatting, README table, and whitespace checks pass; the casing label does not add a TOC entry. Refs: bitcoin#2285
|
I added one more 1978ac2 after re-reviewing the stacked changes. When I first tried to implement BIP93 it took me a moment because I also missed that when Generate and Recover were swapped, the definition of how to use the function was missing from it's first reference, so I put the functions in the ===SSSS-Awareness=== introduction. Maybe that title is better as ===Secret Sharing Scheme=== but not worth another commit. Hopefully this is still easy to review, the Changelog and bits/bytes commits are tiny and this final one is small also. I recommend reviewers view each individual commit, the whole stacked diff is hard to follow due to the movement of many blocks. File looks great on my last proof-read. Ready for review and rereview at 1978ac2. |
Motivation: the Specification should move from most general to specific cases.
Group the regular and long checksum definitions together in the codex32 format section. Move Master seed format application to after of the codex32 format specification and keep seed-specific checksum motivation in the rationale.
Deduplicate repeated explanations and redundant inline encoding/decoding helpers: 9621d3f
This is a behavior-neutral organization change on top of #2258, progressing from codex32 format → optional secret sharing → master seed encoding.
This PR retains the required
msHRP,There is also:
Discussion:
bits vs bytes
https://github.com/bitcoin/bips/pull/2258/changes#r3894597745
https://github.com/bitcoin/bips/pull/2258/changes#r3894609812
https://github.com/bitcoin/bips/pull/2258/changes#r3894685643
Optional: a changelog.
#2258 (comment)
A cautionary warning to not convert bytes to shares.
#2258 (comment)
Rationale
====Long Checksum==== seems like it belongs in ===codex32=== with bold, like it is in BIP173 and BIP350.
The final part of ==Specification== should be ===Master seed format===.
I'm undecided if every application must use the codex32 header, I think they can be free to choose and they may use it even if they do not support SSS, like
CL1rejectedthreshold != 0invalidating shared secrets even if another application did the secret recovery.It's most flexible and Bech32-like to not require it. OTOH, every application has used it thus far so making
codex32_decode(hrp, data)continue to require:improves the certainty damaged base32 data is codex32. If saving 6 characters were top priority, they'd Bech32-encode anyhow.
Nevertheless, ===SSSS-awareness=== feels like it belongs as the only === section between ===codex32=== and ===Master seed format===. That way it can be skipped over by readers who do not need sharing.
Future work
Generalized HRPs, optional headers, new helper APIs, and bytes-to-shares guidance/warning remain deferred.