Skip to content

[ZIP TBD]: Draft for historical wallet key gen/derivation schemes#1176

Draft
dorianvp wants to merge 3 commits intozcash:mainfrom
dorianvp:key-derivation
Draft

[ZIP TBD]: Draft for historical wallet key gen/derivation schemes#1176
dorianvp wants to merge 3 commits intozcash:mainfrom
dorianvp:key-derivation

Conversation

@dorianvp
Copy link

@dorianvp dorianvp commented Feb 8, 2026

Closes #1175.


(TODO: document whether mnemonic/seed originates from BIP 39 and how it was stored/encoded.)

### Derivation / address generation
Copy link
Author

Choose a reason for hiding this comment

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

Expand using information from here: zingolabs/zingolib#2060 (comment)

- Document the v4.7.0+ migration flow in more detail (how/when the emergency recovery phrase is generated, confirmation requirement, export mechanism via `z_exportwallet`, `zcashd-wallet-tool` behavior).
- Specify the exact derivation path structure used for the legacy account and any gap-limit expectations for recovery.

## Zecwallet Lite
Copy link
Author

Choose a reason for hiding this comment

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

It might make more sense to rename this to just zecwallet, or zecwallet-lib, as both Zecwallet Lite and zecwallet-light-cli rely on the same library, and thus inherit the same behaviors.

Copy link
Contributor

Choose a reason for hiding this comment

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

I disagree; don't forget that Zecwallet had a full-node variant that was simply a UI atop the zcashd RPC API. The behavior here was specifically for Zecwallet Lite, in both its desktop and mobile wallet versions.

Copy link
Author

@dorianvp dorianvp left a comment

Choose a reason for hiding this comment

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

Some notes for myself.

@nuttycom nuttycom self-requested a review February 10, 2026 15:01

### Summary

Historically, `zcashd` generated keys from system randomness.
Copy link
Contributor

Choose a reason for hiding this comment

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

This summary should include the pre-v4.7.0 HD derivation of Sapling addresses.


For Sapling, `zcashd` implemented HD derivation according to ZIP 32, but used a seed generated directly from system randomness, rather than seed material derived from a BIP 39 mnemonic phrase.

In `zcashd` v4.7.0, the wallet added support for deriving the wallet’s HD seed from a mnemonic phrase (BIP 39) and referred to the HD seed derived from the emergency recovery phrase as the wallet’s “mnemonic seed”.
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to document the approach that zcashd took to creating seed phrases for existing wallets in particular and clearly document how to recover funds from such wallets, see https://github.com/zcash/zcash/blob/master/doc/release-notes/release-notes-4.7.0.md?plain=1#L71-L79


After v4.7.0, new addresses are derived from the mnemonic seed using ZIP 32 and ZIP 316.

For legacy RPC behavior such as `z_getnewaddress`, `zcashd` derives Sapling addresses under a high account index `account = 0x7FFFFFFF` to avoid collision with Sapling addresses for account 0.
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to also explain the change in behavior of getnewaddress for derivation of transparent addresses, and how the legacy account is structured. Specifically, the semantics of the legacy pool as an undifferentiated pool of transparent funds (that is not partitioned by address) needs to be documented.


### Derivation / address generation

Sapling keys are derived using ZIP 32.
Copy link
Contributor

Choose a reason for hiding this comment

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

Describe the pre-v4.7.0 derivation process here, and how it relates to extracting a pre-v4.7.0 HD seed from the mnemonic phrase via the nonstandard pathway described above.


### Recovery implications

Recovery tooling may need to support Sapling HD derivation from wallet-internal seed material that is not reproducible from a BIP 39 mnemonic.
Copy link
Contributor

Choose a reason for hiding this comment

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

As described in the v4.7.0 release notes, the mnemonic generated for existing wallets was not random; it was an encoding of the existing HD seed as a BIP 39 phrase. Such wallets then had two seeds: the original HD seed, which we wanted to make recoverable via the nonstandard pathway, and the new seed that was generated by hashing the phrase according to BIP 39. After the v4.7.0 upgrade, all new addresses generated by the wallet were produced via derivation from the new seed, with the particular carve-outs in derivation paths for the legacy transparent pool and z_getnewaddress.


## `zcash_client_sqlite`

TBD
Copy link
Contributor

Choose a reason for hiding this comment

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

Key derivation in zcash_client_backend/zcash_client_sqlite based wallets has always been based on BIP 39 seed phrases. The "default transparent address" is the address derived according to BIP 44 at child index 0; additional transparent receivers may have been generated by either normal BIP 44 derivation or by unified address derivation according to ZIP 317.


TBD

# Security and Privacy Considerations
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that the Security and Privacy Considerations section is supposed to go directly after the Motivation section


# Reference Implementation

None.
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this be zexcavator?

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.

[ZIP TBD]: Document all historic and present Zcash key generation and/or derivation schemes.

2 participants