Skip to content

Commit caec9ee

Browse files
refactor: upgrade keystore to AES-256-GCM + Argon2id
- Switch cipher from AES-128-CTR to AES-256-GCM authenticated encryption - Eliminates separate MAC field; GCM auth tag handles both integrity and password verification - Uses full 32-byte derived key (256-bit) instead of 16-byte (128-bit) - 12-byte GCM nonce + 16-byte auth tag stored in cipherparams - Add Argon2id as the default KDF (via hash-wasm, WASM-based) - Defaults: iterations=3, parallelism=4, memorySize=65536 KiB (64 MiB) - Winner of the Password Hashing Competition, OWASP recommended - Superior GPU/ASIC resistance compared to scrypt - Retain scrypt and PBKDF2 as alternative KDFs for compatibility - Update all 26 tests for new cipher and KDF parameters Co-authored-by: Greg Nazario <greg@gnazar.io>
1 parent a6eb427 commit caec9ee

File tree

5 files changed

+261
-153
lines changed

5 files changed

+261
-153
lines changed

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ All notable changes to the Aptos TypeScript SDK will be captured in this file. T
66

77
## Added
88

9-
- Add Aptos Keystore: encrypted private key storage standard based on Ethereum's Web3 Secret Storage Definition (keystore v3)
9+
- Add Aptos Keystore: encrypted private key storage standard based on Ethereum's Web3 Secret Storage Definition
1010
- Supports all Aptos key types: Ed25519, Secp256k1, Secp256r1
11-
- Password-based or key-file-based encryption using scrypt (default) or PBKDF2-HMAC-SHA256 KDFs
12-
- AES-128-CTR cipher with SHA-256 MAC for password verification
11+
- AES-256-GCM authenticated encryption (no separate MAC needed)
12+
- Argon2id KDF by default (via `hash-wasm`), with scrypt and PBKDF2-HMAC-SHA256 as alternatives
13+
- Password-based or key-file-based encryption
1314
- Portable JSON format designed for cross-SDK compatibility (TypeScript, Rust, Python, Go, etc.)
1415
- New exports: `encryptKeystore`, `decryptKeystore`, `AptosKeyStore`, `KeystorePrivateKey`, `KeystoreEncryptOptions`
1516

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"@scure/bip32": "^1.4.0",
5959
"@scure/bip39": "^1.3.0",
6060
"eventemitter3": "^5.0.4",
61+
"hash-wasm": "^4.12.0",
6162
"js-base64": "^3.7.7",
6263
"jwt-decode": "^4.0.0",
6364
"poseidon-lite": "^0.2.0"

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)