wallet: support independent create scrypt parameters - #1298
Draft
Roasbeef wants to merge 1 commit into
Draft
Conversation
In this commit, we allow wallet creators to select independent scrypt parameters for the public and private master keys. This lets callers reduce the cost of a known public passphrase without weakening the user-supplied private passphrase. The existing Create paths still apply the same config, or the same default, to both keys. Loader options are copied before storage, changes are rejected after a wallet is loaded, and existing wallet databases remain untouched. The tests also pin separate persisted profiles when both passphrase byte strings are identical.
This was referenced Jul 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change Description
In this PR, we let wallet creators select independent scrypt parameters for
the public and private master keys. The motivating case is a wallet with a
known public passphrase and a user-supplied private passphrase: callers can
reduce the public-key setup cost without weakening private-key encryption.
Existing
Createentry points keep their old behavior by applying the sameconfig, or the same default, to both keys. The loader copies supplied configs,
rejects changes after a wallet is loaded, and does not alter existing wallet
databases. A regression test also uses identical public and private
passphrase bytes and verifies that their persisted KDF profiles remain
independent.
This supports the Wavelength browser-wallet optimization tracked in
lightninglabs/wavelength-sdk#53. With public
N=16and the private key left atthe default
N=2^18, the downstream prototype reduced create p95 from 2,735ms to 1,782 ms and unlock p95 from 1,220 ms to 662 ms.
Steps to Test
go test ./waddrmgr ./walletThe full
go test ./...run passes the changed packages. Itschain/TestBitcoindEventsintegration test fails locally because the spawnedBitcoin Core v30 process does not remain available. The same failure
reproduces on the untouched
origin/masterbase.Pull Request Checklist
Testing
Code Style and Documentation
📝 Please see our Contribution Guidelines for further guidance.