Skip to content

fix: correct HDKey seed error message to report 64 bytes instead of 32#219

Merged
yshyn-iohk merged 1 commit intomainfrom
fix/hdkey-seed-error-message-151
Mar 5, 2026
Merged

fix: correct HDKey seed error message to report 64 bytes instead of 32#219
yshyn-iohk merged 1 commit intomainfrom
fix/hdkey-seed-error-message-151

Conversation

@yshyn-iohk
Copy link
Contributor

@yshyn-iohk yshyn-iohk commented Mar 5, 2026

The error message in HDKey and EdHDKey constructors was referencing ECConfig.PRIVATE_KEY_BYTE_SIZE (32 bytes) for the seed length validation message, but BIP32 HDKey derivation requires a 64-byte seed (512 bits, as produced by BIP39 PBKDF2-HMAC-SHA512).

Add a dedicated ECConfig.SEED_BYTE_SIZE = 64 constant and use it in all seed-length error messages across all platform targets.

Fixes #151

Description:

Summarize the changes you're submitting in a few sentences, including Jira ticket ATL-xxxx if applicable. Link to any discussion, related issues and bug reports to give the context to help the reviewer understand the PR.

Alternatives Considered (optional):

Link to existing ADR (Architecture Decision Record), if any. If relevant, describe other approaches explored and the selected approach. Documenting why the methods were not selected will create a knowledge base for future reference, helping prevent others from revisiting less optimal ideas.

Checklist:

  • My PR follows the contribution guidelines of this project
  • My PR is free of third-party dependencies that don't comply with the Allowlist
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked the PR title to follow the conventional commit specification

The error message in HDKey and EdHDKey constructors was referencing
ECConfig.PRIVATE_KEY_BYTE_SIZE (32 bytes) for the seed length validation
message, but BIP32 HDKey derivation requires a 64-byte seed (512 bits,
as produced by BIP39 PBKDF2-HMAC-SHA512).

Add a dedicated ECConfig.SEED_BYTE_SIZE = 64 constant and use it in all
seed-length error messages across all platform targets.

Fixes #151

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Yurii Shynbuiev <yurii.shynbuiev@iohk.io>
@yshyn-iohk yshyn-iohk requested a review from a team as a code owner March 5, 2026 11:03
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 5, 2026

@yshyn-iohk yshyn-iohk merged commit 1968e8c into main Mar 5, 2026
7 checks passed
@yshyn-iohk yshyn-iohk deleted the fix/hdkey-seed-error-message-151 branch March 5, 2026 12:30
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.

Inaccurate HDKey error message when seed length is invalid

2 participants