Skip to content

NUMS_UNSPENDABLE_KEY_HEX is not supposed to be used as is (privacy concerns) #218

Open

Description

@tvpeter

I believe technically the NUMS_UNSPENDABLE_KEY_HEX is not supposed to be used as is (privacy concerns), though for now it's fine. Per BIP-0431, should add an issue to do the following:

"In order to avoid leaking the information that key path spending is not possible it is recommended to pick a fresh integer r in the range 0...n-1 uniformly at random and use H + rG as internal key. It is possible to prove that this internal key does not have a known discrete logarithm with respect to G by revealing r to a verifier who can then reconstruct how the internal key was created."

Originally posted by @notmandatory in #208 (comment)

Activity

  1. vadim-anfv commented on Sep 9, 2025

    @vadim-anfv
    Collaborator

    If this is planned to be done not in 2.0.0, but in a subsequent version, then please assign this to me.

  2. vadim-anfv commented on Oct 9, 2025

    @vadim-anfv
    Collaborator

    Should the compile command optionally return the randomness value r for Taproot descriptors?

    For Taproot descriptor compilation, the approach is to generate a randomized unspendable internal key using H + rG where:

    • H = NUMS point (constant)
    • r = random scalar
    • G = generator point

    Should we expose r to allow independent verification of the descriptor construction (verifying internal_key = H + rG)?

    Implementation options:

    1. Never return r - simpler UX, cleaner output
    2. Always return r - maximum transparency, may clutter output
    3. Optional flag --return-randomness - users opt-in when needed

    Which approach do you prefer?

  3. notmandatory commented on Oct 11, 2025

    @notmandatory
    Contributor

    Since the bdk-cli tool is primarily used for testing and education I'd prefer option 2, to always output it when creating a descriptor that uses one. It may also be useful to add a new CLI command to verify the NUMS unspendable key for a descriptor given the r value.

  4. added
    enhancement
    on Oct 11, 2025
  5. moved this from Todo to In Progress in BDK-CLIon Oct 11, 2025
  6. added this to the CLI 3.0.0 milestone on Feb 26, 2026
  7. vadim-anfv commented on Feb 27, 2026

    @vadim-anfv
    Collaborator

    #225 covers the creation and output of r. Now I'm thinking about the follow-up PR to add a command for verifying r against a descriptor. We could place the new command in a few ways:

    • compile subcommands (compile create / compile verify) - cleanest grouping, but it's a breaking change for all descriptor types (sh, wsh, sh-wsh, tr). bdk-cli compile <POLICY> becomes bdk-cli compile create <POLICY>. Feels disproportionate since verification only applies to taproot.
    • compile --verify flag - no breaking change, but mixes two different operations with different inputs (policy vs descriptor + r) in one command. Makes policy optional and needs complex validation logic.

    We could also place verify outside of compile as a separate top-level command, but I'm less keen on that - verification is closely tied to compile.

    Since we're targeting CLI 3.0.0, it's a good time for breaking changes. That said, restructuring compile into subcommands for a taproot-only feature might be overkill.

    I'm leaning towards compile create / compile verify - it's more explicit, and since we're also planning to add shell completions in 3.0.0 (#234), the extra subcommand shouldn't complicate the UX much.

    Thoughts?

  8. removed this from the CLI 3.0.0 milestone on Mar 25, 2026
  9. added this to the CLI 4.0.0 milestone on May 6, 2026
  10. added a commit that references this issue on Jun 28, 2026
  11. modified the milestones: CLI 4.0.0, CLI 4.1.0 on Jun 30, 2026
  12. vadim-anfv commented on Aug 19, 2026

    @vadim-anfv
    Collaborator

    @tvpeter @notmandatory ping - any thoughts on the question above?
    Happy to pick this up once there is a direction.

  13. tvpeter commented on Nov 10, 2026

    @tvpeter
    CollaboratorAuthor

    #225 covers the creation and output of r. Now I'm thinking about the follow-up PR to add a command for verifying r against a descriptor. We could place the new command in a few ways:

    • compile subcommands (compile create / compile verify) - cleanest grouping, but it's a breaking change for all descriptor types (sh, wsh, sh-wsh, tr). bdk-cli compile <POLICY> becomes bdk-cli compile create <POLICY>. Feels disproportionate since verification only applies to taproot.
    • compile --verify flag - no breaking change, but mixes two different operations with different inputs (policy vs descriptor + r) in one command. Makes policy optional and needs complex validation logic.

    We could also place verify outside of compile as a separate top-level command, but I'm less keen on that - verification is closely tied to compile.

    Since we're targeting CLI 3.0.0, it's a good time for breaking changes. That said, restructuring compile into subcommands for a taproot-only feature might be overkill.

    I'm leaning towards compile create / compile verify - it's more explicit, and since we're also planning to add shell completions in 3.0.0 (#234), the extra subcommand shouldn't complicate the UX much.

    Thoughts?

    Hi @vadim-anfv ,

    Apologies for the late response on this issue.

    Amongst the options you provided, I will choose the second because compile is a verb and --verify will be a flag but flags should not accept values. So my opinion is that, we should make policy top level command, then the verb compile will of course compile policies, while policy verify will verify given a descriptor and r. So I think #368 should address this remaining part of the issue directly rather than doing so in another PR.

  14. vadim-anfv commented on Nov 18, 2026

    @vadim-anfv
    Collaborator

    @tvpeter to be sure I got you: policy becomes a top level command, with policy compile and policy verify? If so, agreed, and it's better than either of the two I listed.

    Happy to do all of it in #368 then, the restructure plus the verify command on top of the helper already in there. That makes #368 breaking, so I'd suggest 5.0.0 for it.

    I'd finish #378 first though: it changes the same code and brings its own tests, and both would get reworked for the rename. It probably belongs in 5.0.0 too, since the same compile --type tr call starts returning a different descriptor.

  15. tvpeter commented on Nov 18, 2026

    @tvpeter
    CollaboratorAuthor

    @tvpeter to be sure I got you: policy becomes a top level command, with policy compile and policy verify? If so, agreed, and it's better than either of the two I listed.

    Yes that's correct, policy should become a top level command.

  16. removed this from the CLI 4.1.0 milestone on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

  • Status
    In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions