Skip to content

Add ARelaxCostRestriction parameter to Scrypt#41

Merged
Xor-el merged 1 commit into
masterfrom
enhancement/add-flag-to-relax-scrypt-cost-restriction
Mar 19, 2026
Merged

Add ARelaxCostRestriction parameter to Scrypt#41
Xor-el merged 1 commit into
masterfrom
enhancement/add-flag-to-relax-scrypt-cost-restriction

Conversation

@Xor-el
Copy link
Copy Markdown
Owner

@Xor-el Xor-el commented Mar 19, 2026

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)

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)
@Xor-el Xor-el merged commit 92cf99a into master Mar 19, 2026
4 checks passed
@Xor-el Xor-el deleted the enhancement/add-flag-to-relax-scrypt-cost-restriction branch March 19, 2026 13:44
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