Background
crates/perry-stdlib/src/crypto.rs (4997 lines) and crates/perry-stdlib/src/webcrypto.rs (2809 lines) grew past the 2000-line limit while #1419 expanded the node:crypto parity surface. Both are currently allowlisted in scripts/check_file_size.sh so CI passes.
crates/perry-hir/src/ir/expr.rs (2009 lines) also crossed the boundary; this is the Expr enum + the walker trait implementations, and the PR added the WebCrypto variants.
Goal
Move these out of the allowlist by following the chore/split-large-files pattern (v0.5.1019/v0.5.1020 commits).
perry-stdlib/src/crypto.rs
Split into per-algorithm-family submodules:
crypto/hash.rs — Hash / Hmac (already partly factored as HashState / HmacState).
crypto/cipher.rs — CipherHandle, AES-CBC / GCM / KW.
crypto/sign.rs — SignHandle, RSA-PKCS#1 v1.5 / RSA-PSS.
crypto/ecdh.rs — EcdhHandle, ECDH P-256, X25519.
crypto/dh.rs — DiffieHellmanHandle.
crypto/kdf.rs — PBKDF2, scrypt, HKDF.
crypto/random.rs — randomBytes, randomInt, randomUUID, randomFill.
crypto/keys.rs — createSecretKey, generateKeySync, generateKeyPairSync, KeyObject helpers.
crypto/prime.rs — generatePrime, checkPrime.
crypto/util.rs — bytes_from_ptr, alloc_buffer_from_slice, encoding helpers.
perry-stdlib/src/webcrypto.rs
Same shape but for subtle.*:
webcrypto/digest.rs, webcrypto/hmac.rs, webcrypto/aes.rs, webcrypto/ec.rs, webcrypto/rsa.rs, webcrypto/kdf.rs, webcrypto/wrap.rs, webcrypto/jwk.rs, webcrypto/util.rs.
perry-hir/src/ir/expr.rs
Variants are alphabetized today. Could split by surface family: expr/cryptographic.rs, expr/string.rs, etc. Higher risk because the walker traits need symmetric updates; consider doing this last.
Validation
After each split:
cargo build --release --workspace clean.
cargo test --release --workspace --exclude perry-ui-* passes.
./run_parity_tests.sh 100% on the touched module.
- Remove the corresponding line from
scripts/check_file_size.sh ALLOWLIST.
Tracked under #793. Pattern reference: commits on chore/split-large-files for compile.rs and entries.rs.
Background
crates/perry-stdlib/src/crypto.rs(4997 lines) andcrates/perry-stdlib/src/webcrypto.rs(2809 lines) grew past the 2000-line limit while #1419 expanded thenode:cryptoparity surface. Both are currently allowlisted inscripts/check_file_size.shso CI passes.crates/perry-hir/src/ir/expr.rs(2009 lines) also crossed the boundary; this is theExprenum + the walker trait implementations, and the PR added the WebCrypto variants.Goal
Move these out of the allowlist by following the chore/split-large-files pattern (v0.5.1019/v0.5.1020 commits).
perry-stdlib/src/crypto.rsSplit into per-algorithm-family submodules:
crypto/hash.rs—Hash/Hmac(already partly factored asHashState/HmacState).crypto/cipher.rs—CipherHandle, AES-CBC / GCM / KW.crypto/sign.rs—SignHandle, RSA-PKCS#1 v1.5 / RSA-PSS.crypto/ecdh.rs—EcdhHandle, ECDH P-256, X25519.crypto/dh.rs—DiffieHellmanHandle.crypto/kdf.rs— PBKDF2, scrypt, HKDF.crypto/random.rs— randomBytes, randomInt, randomUUID, randomFill.crypto/keys.rs— createSecretKey, generateKeySync, generateKeyPairSync, KeyObject helpers.crypto/prime.rs— generatePrime, checkPrime.crypto/util.rs—bytes_from_ptr,alloc_buffer_from_slice, encoding helpers.perry-stdlib/src/webcrypto.rsSame shape but for
subtle.*:webcrypto/digest.rs,webcrypto/hmac.rs,webcrypto/aes.rs,webcrypto/ec.rs,webcrypto/rsa.rs,webcrypto/kdf.rs,webcrypto/wrap.rs,webcrypto/jwk.rs,webcrypto/util.rs.perry-hir/src/ir/expr.rsVariants are alphabetized today. Could split by surface family:
expr/cryptographic.rs,expr/string.rs, etc. Higher risk because the walker traits need symmetric updates; consider doing this last.Validation
After each split:
cargo build --release --workspaceclean.cargo test --release --workspace --exclude perry-ui-*passes../run_parity_tests.sh100% on the touched module.scripts/check_file_size.shALLOWLIST.Tracked under #793. Pattern reference: commits on
chore/split-large-filesforcompile.rsandentries.rs.