Skip to content

Conversation

@Raathmd
Copy link

@Raathmd Raathmd commented Nov 15, 2025

The BIP-32 specification requires that non-hardened child key derivation use the parent public key in the HMAC-SHA512 operation, not the private key.

Previous behavior:

  • Used 0x00 || private_key for all derivations from private keys

Fixed behavior:

  • Hardened derivation (index >= 0x80000000): 0x00 || private_key (correct)
  • Non-hardened derivation: parent public key (now matches BIP-32 spec)

This fix ensures compatibility with other BIP-32 implementations including @bsv/sdk and allows correct derivation of keys from BIP-39 mnemonics.

Tested against @bsv/sdk derivation to verify correctness.

The BIP-32 specification requires that non-hardened child key derivation
use the parent public key in the HMAC-SHA512 operation, not the private key.

Previous behavior:
- Used 0x00 || private_key for all derivations from private keys

Fixed behavior:
- Hardened derivation (index >= 0x80000000): 0x00 || private_key (correct)
- Non-hardened derivation: parent public key (now matches BIP-32 spec)

This fix ensures compatibility with other BIP-32 implementations including
@bsv/sdk and allows correct derivation of keys from BIP-39 mnemonics.

Tested against @bsv/sdk derivation to verify correctness.
- Replace base58 0.2.0 with bsv58 (SIMD-accelerated, BSV-specific)
- Update address encoding/decoding to use bsv58 API
- Update ExtendedKey (BIP32) encode/decode
- Remove FromBase58Error, map to BadData instead
- Add comprehensive CHANGELOG_BSV58.md documentation
- All 129 tests pass
- 5.2x faster encoding, 5.1x faster decoding (AVX2/NEON SIMD)
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