Add ARelaxCostRestriction parameter to Scrypt#41
Merged
Xor-el merged 1 commit intoMar 19, 2026
Conversation
Add ARelaxCostRestriction parameter to Scrypt to allow N >= 65536 when r = 1 The RFC 7914 constraint N < 2^(128*r/8) was confirmed by Colin Percival (Scrypt creator and RFC co-author) to be an accidental error in the RFC. The intended bound was N < 2^(128*r*8), which is trivially satisfied. RFC errata 5971, 5972, 5973 have been filed. The Ethereum Web3 Secret Storage standard uses N=262144, r=1, p=8 as its default Scrypt parameters. These are widely used in practice (geth, web3.py, web3.js, etc.) and accepted by the Scrypt reference implementation (Tarsnap) and Go's x/crypto/scrypt, but were rejected by the existing validation. A new ARelaxCostRestriction default parameter (False) is added to ValidatePBKDF_ScryptInputs, the constructor, and CreatePBKDF_Scrypt. When True, the erroneous cost/blocksize check is skipped. Existing callers are unaffected. See: golang/go#33703 (comment)
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.
Add ARelaxCostRestriction parameter to Scrypt to allow N >= 65536 when r = 1
The RFC 7914 constraint N < 2^(128r/8) was confirmed by Colin Percival (Scrypt creator and RFC co-author) to be an accidental error in the RFC. The intended bound was N < 2^(128r*8), which is trivially satisfied. RFC errata 5971, 5972, 5973 have been filed.
The Ethereum Web3 Secret Storage standard uses N=262144, r=1, p=8 as its default Scrypt parameters. These are widely used in practice (geth, web3.py, web3.js, etc.) and accepted by the Scrypt reference implementation (Tarsnap) and Go's x/crypto/scrypt, but were rejected by the existing validation.
A new ARelaxCostRestriction default parameter (False) is added to ValidatePBKDF_ScryptInputs, the constructor, and CreatePBKDF_Scrypt. When True, the erroneous cost/blocksize check is skipped. Existing callers are unaffected.
See: golang/go#33703 (comment)