H1: Add two-level BIP-32 derivation with 62-bit entropy for V3+ projects#912
Open
DavidGershony wants to merge 1 commit into
Open
H1: Add two-level BIP-32 derivation with 62-bit entropy for V3+ projects#912DavidGershony wants to merge 1 commit into
DavidGershony wants to merge 1 commit into
Conversation
Add DeriveProjectIndicesV2() that splits 62 bits of a SHA-256d hash into
two 31-bit indices, enabling a two-level hardened derivation path that
reduces collision probability from ~46k projects to ~2 billion.
Add BuildProjectSubPath() that returns the appropriate path component:
- V1/V2: single level '{upi}' (31-bit, backward compatible)
- V3+: two levels '{hi}/{lo}' (62-bit)
All derivation methods (DeriveInvestorKey, DeriveFounderRecoveryKey,
DeriveNostrPubKey, DeriveAngorKey, etc.) now have version-aware overloads
that default to V1 behavior for backward compatibility.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add two-level BIP-32 hardened derivation paths for V3+ projects, increasing path entropy from 31 bits (~46k collision threshold) to 62 bits (~2 billion collision threshold).
Problem
The current single-level derivation uses 31 bits of entropy from SHA-256d(founderKey), giving a Birthday-bound collision probability of ~46k projects before a 50% chance of path collision.
Solution
DeriveProjectIndicesV2(founderKey)that splits 62 bits into two 31-bit indices (each valid for BIP-32 hardened derivation, max 2^31-1)BuildProjectSubPath(founderKey, projectVersion)that returns:{upi}'(single level, backward compatible){hi}'/{lo}'(two levels, 62-bit entropy)DeriveAngorKeyalso supports V3+ with two-levelDerive(hi).Derive(lo)Version Gating
Uses
projectVersionparameter (defaults to 1). Callers pass the project's version when creating V3+ projects. Existing V1/V2 projects continue using the single-level path.Testing
All 154 shared tests pass.