crypto: make keystore Argon2 KDF cost parameters self-describing per-key - #501
Open
ezeike wants to merge 1 commit into
Open
crypto: make keystore Argon2 KDF cost parameters self-describing per-key#501ezeike wants to merge 1 commit into
ezeike wants to merge 1 commit into
Conversation
ezeike
force-pushed
the
feat/keystore-flexible-kdf-params
branch
2 times, most recently
from
August 5, 2026 20:35
daf70ca to
3e0a38a
Compare
Store KdfTime/KdfMemoryKB/KdfThreads alongside each EncryptedPrivateKey so DecryptPrivateKey always re-derives with the exact parameters used to encrypt that key, instead of a single hardcoded global constant shared by every caller. Zero-value fields fall back to the historical defaults (3, 32MB, 4), so existing keystore.json files decrypt unmodified. Adds EncryptPrivateKeyWithParams for callers -- e.g. test suites decrypting many keys under high concurrency -- that want a cheaper KDF than the 32MB/call default. EncryptPrivateKey keeps its existing signature/behavior. kdf* fields are only written when they differ from the defaults, so the common case still marshals identically to a pre-kdf-params keystore.
ezeike
force-pushed
the
feat/keystore-flexible-kdf-params
branch
from
August 5, 2026 20:36
3e0a38a to
30bd223
Compare
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.
Summary
Stores
KdfTime/KdfMemoryKB/KdfThreadsalongside eachEncryptedPrivateKeysoDecryptPrivateKeyalways re-derives with the exact Argon2 parameters used to encrypt that key, instead of a single hardcoded global constant shared by every caller.keystore.jsonfiles decrypt unmodified — fully backward compatible.EncryptPrivateKeyWithParamsfor callers (e.g. test suites decrypting many keys under high concurrency) that want a cheaper KDF than the 32MB/call default.EncryptPrivateKeykeeps its existing signature/behavior, now implemented as a thin wrapper overEncryptPrivateKeyWithParamswith the default params.Scope
Single file:
lib/crypto/keystore.go(+37/-12).Testing
go test ./lib/crypto/... -run Keystore -v— all passing (TestKeystoreImportWithOpts,TestKeystoreImportRawWithOpts,TestKeystoreDeleteKeyWithOpts)go build ./lib/crypto/...— clean🤖 Generated with Claude Code