Skip to content

Conversation

@QuantumExplorer
Copy link
Member

@QuantumExplorer QuantumExplorer commented Sep 2, 2025

This was done to have an easier way for clients to access private keys for viewing.

Summary by CodeRabbit

  • New Features

    • Expanded key derivation: derive extended/private keys from seed or mnemonic, and by index.
    • Added support for BLS and EdDSA account key derivations.
    • Optional WIF output for derived private keys.
    • Path utilities for BIP44, CoinJoin, and identity-related paths.
    • Master key creation and xpriv/xpub conversions with fingerprinting.
  • Bug Fixes

    • None.
  • Documentation

    • Updated public API docs to include new derivations and revised function counts.
  • Tests

    • Added tests for new derivation flows; removed legacy DIP9 tests.
  • Revert

    • Removed legacy DIP9 identity key derivation.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 2, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds a new account_derivation FFI module and public APIs for deriving extended/private keys from xpriv, seed, or mnemonic (including BLS and EdDSA variants), updates headers and docs, introduces supporting key wrappers, and extends core AccountDerivation trait/impls. Removes DIP9 identity key derivation API and its tests; wires the new module in lib.

Changes

Cohort / File(s) Change Summary
Docs (FFI API)
key-wallet-ffi/FFI_API.md
Documents new account derivation FFI functions (ECDSA, BLS, EdDSA), updates function counts, and removes DIP9 identity derivation entry.
Public FFI Header
key-wallet-ffi/include/key_wallet_ffi.h
Adds account_derive_* APIs, BLS/EdDSA mnemonic/seed derivations, derivation helpers (paths, xpriv/xpub conversions, master key, free fns); removes FFIDerivationPathType and dip9_derive_identity_key.
New FFI Module + Tests
key-wallet-ffi/src/account_derivation.rs, key-wallet-ffi/src/account_derivation_tests.rs
Introduces FFI account derivation implementations with pointer/error handling and feature-gated BLS/EdDSA flows; adds tests covering success/failure cases and null-safety.
Derivation Cleanup
key-wallet-ffi/src/derivation.rs, key-wallet-ffi/src/derivation_tests.rs
Deletes DIP9 FFI function and its tests; no replacement in this file.
FFI Key Internals
key-wallet-ffi/src/keys.rs
Adds internal constructors/accessors for FFIExtendedPrivateKey and FFIPrivateKey to support new flows.
Module Wiring
key-wallet-ffi/src/lib.rs
Exposes new account_derivation module.
Core Trait Expansion
key-wallet/src/account/derivation.rs
Expands AccountDerivation trait to include PrivKey type; adds defaults_to_hardened_derivation, has_internal_and_external, has_intermediate_derivation, and seed/mnemonic/xpriv-based derivation helpers.
Account Implementations (ECDSA/BLS/EdDSA)
key-wallet/src/account/mod.rs, key-wallet/src/account/bls_account.rs, key-wallet/src/account/eddsa_account.rs
Updates impls to new trait signature; implements new methods and intermediate-derivation behaviors; adds seed/mnemonic/xpriv-to-private/extended key derivations.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller
  participant FFI as FFI account_derive_private_key_from_mnemonic
  participant Acc as Account (Rust)
  participant Der as AccountDerivation Trait
  participant Mn as Mnemonic
  participant Seed as Seed Derivation

  Caller->>FFI: account_derive_private_key_from_mnemonic(account, mnemonic, passphrase, index)
  FFI->>FFI: Validate pointers, init FFIError
  FFI->>Mn: parse mnemonic
  Mn-->>FFI: Mnemonic or error
  FFI->>Seed: to_seed(mnemonic, passphrase)
  Seed-->>FFI: seed bytes
  FFI->>Acc: account.inner()
  Acc->>Der: derive_from_seed_private_key_at(seed, index)
  Der-->>FFI: PrivateKey or error
  alt success
    FFI-->>Caller: FFIPrivateKey*
  else error
    FFI-->>Caller: null + FFIError
  end
Loading
sequenceDiagram
  autonumber
  actor Caller
  participant FFI as FFI account_derive_private_key_at
  participant Acc as Account (Rust)
  participant Der as AccountDerivation Trait

  Caller->>FFI: account_derive_private_key_at(account, master_xpriv, index)
  FFI->>FFI: Validate pointers, ensure not watch-only
  FFI->>Acc: account.inner()
  Acc->>Der: derive_from_master_xpriv_private_key_at(master_xpriv, index)
  Der-->>FFI: PrivateKey or error
  alt success
    FFI-->>Caller: FFIPrivateKey*
  else error
    FFI-->>Caller: null + FFIError
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

Poem

A nibble, a hop, through mnemonic fields I roam,
Seeds sprout keys, along paths I call home.
BLS and EdDSA join my warren’s lore,
DIP9’s old burrow—used no more.
With WIFs in whiskers and xprivs in tow,
I sign the wind—then off I go! 🐇🔑


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between bc2a532 and 7ce3209.

📒 Files selected for processing (12)
  • key-wallet-ffi/FFI_API.md (7 hunks)
  • key-wallet-ffi/include/key_wallet_ffi.h (1 hunks)
  • key-wallet-ffi/src/account_derivation.rs (1 hunks)
  • key-wallet-ffi/src/account_derivation_tests.rs (1 hunks)
  • key-wallet-ffi/src/derivation.rs (0 hunks)
  • key-wallet-ffi/src/derivation_tests.rs (0 hunks)
  • key-wallet-ffi/src/keys.rs (1 hunks)
  • key-wallet-ffi/src/lib.rs (1 hunks)
  • key-wallet/src/account/bls_account.rs (3 hunks)
  • key-wallet/src/account/derivation.rs (3 hunks)
  • key-wallet/src/account/eddsa_account.rs (2 hunks)
  • key-wallet/src/account/mod.rs (3 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch featadd-account-derivation-functions

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link

github-actions bot commented Sep 2, 2025

⚠️ FFI Documentation Update Required

The FFI API documentation is out of date. Please regenerate it by running:

For key-wallet-ffi:

cd key-wallet-ffi
make update-docs

For dash-spv-ffi:

cd dash-spv-ffi
make update-docs

Then commit the changes:

git add */FFI_API.md
git commit -m "docs: update FFI API documentation"

This ensures the documentation stays in sync with the actual FFI functions.

@QuantumExplorer QuantumExplorer merged commit 1f83438 into v0.40-dev Sep 2, 2025
28 of 31 checks passed
@QuantumExplorer QuantumExplorer deleted the featadd-account-derivation-functions branch September 2, 2025 12:35
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