Skip to content

wallet: support independent create scrypt parameters - #1298

Draft
Roasbeef wants to merge 1 commit into
btcsuite:masterfrom
Roasbeef:wallet/separate-create-scrypt-options
Draft

wallet: support independent create scrypt parameters#1298
Roasbeef wants to merge 1 commit into
btcsuite:masterfrom
Roasbeef:wallet/separate-create-scrypt-options

Conversation

@Roasbeef

Copy link
Copy Markdown
Member

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 Create entry points keep their old behavior by applying the same
config, 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=16 and the private key left at
the default N=2^18, the downstream prototype reduced create p95 from 2,735
ms to 1,782 ms and unlock p95 from 1,220 ms to 662 ms.

Steps to Test

go test ./waddrmgr ./wallet

The full go test ./... run passes the changed packages. Its
chain/TestBitcoindEvents integration test fails locally because the spawned
Bitcoin Core v30 process does not remain available. The same failure
reproduces on the untouched origin/master base.

Pull Request Checklist

Testing

  • Your PR passes all CI checks.
  • Tests covering the positive and negative (error paths) are included.
  • Bug fixes contain tests triggering the bug to prevent regressions.

Code Style and Documentation

📝 Please see our Contribution Guidelines for further guidance.

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.
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.

1 participant