Skip to content

Fix encryptedDerivePublic to return Either instead of throwing on har…#687

Merged
lehins merged 2 commits into
masterfrom
sl/fix-cardano-crypto-wallet-backport
Jul 13, 2026
Merged

Fix encryptedDerivePublic to return Either instead of throwing on har…#687
lehins merged 2 commits into
masterfrom
sl/fix-cardano-crypto-wallet-backport

Conversation

@disassembler

Copy link
Copy Markdown
Contributor

…dened indices

Replace both partial error branches in encryptedDerivePublic with structured failures: hardened indices now return Left XPrvHardenedDerivationUnsupported and FFI failures return Left XPrvInternalError. The return type changes from the pure (PublicKey, ChainCode) to Either XPrvError (PublicKey, ChainCode), matching the style of the sibling encryptedDerivePrivate API and eliminating the crash vector when callers forward attacker-controlled derivation paths.

Description

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated
  • All visible changes are prepended to the latest section of a CHANGELOG.md for the affected packages.
    New section is never added with the code changes. (See RELEASING.md)
  • When applicable, versions are updated in .cabal and CHANGELOG.md files according to the
    versioning process.
  • The version bounds in .cabal files for all affected packages are updated.
    If you change the bounds in a cabal file, that package itself must have a version increase. (See RELEASING.md)
  • Self-reviewed the diff

…dened indices

Replace both partial `error` branches in `encryptedDerivePublic` with structured
failures: hardened indices now return `Left XPrvHardenedDerivationUnsupported` and
FFI failures return `Left XPrvInternalError`. The return type changes from the pure
`(PublicKey, ChainCode)` to `Either XPrvError (PublicKey, ChainCode)`, matching the
style of the sibling `encryptedDerivePrivate` API and eliminating the crash vector
when callers forward attacker-controlled derivation paths.

@lehins lehins left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from missing necessary version bump and changelog it looks good. Thank you!

Comment thread cardano-crypto-wallet/src/Cardano/Crypto/WalletHD/Encrypted.hs
@lehins

lehins commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Oh yeah, and it needs some fourmolu

Breaking API change from previous commit: version bump, changelog entry,
and fourmolu formatting fix in RoundTripSpec.

@lehins lehins left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! Thank you!

@lehins lehins enabled auto-merge (squash) July 13, 2026 13:51
@lehins lehins merged commit c61a885 into master Jul 13, 2026
26 of 27 checks passed
@lehins lehins deleted the sl/fix-cardano-crypto-wallet-backport branch July 13, 2026 14:27
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.

2 participants