Skip to content

H1: Add two-level BIP-32 derivation with 62-bit entropy for V3+ projects#912

Open
DavidGershony wants to merge 1 commit into
mainfrom
security/h1-two-level-derivation-entropy
Open

H1: Add two-level BIP-32 derivation with 62-bit entropy for V3+ projects#912
DavidGershony wants to merge 1 commit into
mainfrom
security/h1-two-level-derivation-entropy

Conversation

@DavidGershony

Copy link
Copy Markdown
Collaborator

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

  • Add DeriveProjectIndicesV2(founderKey) that splits 62 bits into two 31-bit indices (each valid for BIP-32 hardened derivation, max 2^31-1)
  • Add BuildProjectSubPath(founderKey, projectVersion) that returns:
    • V1/V2: {upi}' (single level, backward compatible)
    • V3+: {hi}'/{lo}' (two levels, 62-bit entropy)
  • All derivation methods now have version-aware overloads defaulting to V1
  • DeriveAngorKey also supports V3+ with two-level Derive(hi).Derive(lo)

Version Gating

Uses projectVersion parameter (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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant