Skip to content

Incrementing hardened nodes overflows to non-hardened ones and vice-versa #1259

Open

Description

@quapka

Hi,
While looking around the KeyPath implementation, because of #1258, I've stumbled upon the Increment method.

Consider the following examples:

Console.WriteLine(masterPrivateKey.Derive(KeyPath.Parse("2147483647'").Increment()) == masterPrivateKey.Derive(KeyPath.Parse("0"))); //
Console.WriteLine(masterPrivateKey.Derive(KeyPath.Parse("2147483647").Increment()) == masterPrivateKey.Derive(KeyPath.Parse("0'"))); //

Incrementing a child key seems like a benign and usable feature. However, crossing non-hardened and hardened boundaries silently seems like asking for an unexpected behavior somewhere down the line. Generally, key-reuse and thus address reuse is bad for privacy. Just the API cannot defend against an address reuse, but still I would definitely err on the side of caution and stop incrementing, when crossing both boundaries.

Increment is being used. However, I did not find it being used in any of the top projects listed in your README.md.

Activity

  1. lontivero commented on Mar 29, 2025

    @lontivero
    Contributor

    Good catch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions