Commit d698df8
feat: add Aptos Keystore encrypted private key storage standard
Implement an encrypted credential management system based on Ethereum's
Web3 Secret Storage Definition (keystore v3), adapted for all Aptos key
types. The format is designed to be portable across Aptos SDKs.
Key features:
- Support for Ed25519, Secp256k1, and Secp256r1 private keys
- Password-based or key-file-based encryption
- scrypt (default) and PBKDF2-HMAC-SHA256 key derivation functions
- AES-128-CTR symmetric cipher via Web Crypto API
- SHA-256 MAC for password verification
- Portable JSON format for cross-SDK interoperability
New exports:
- encryptKeystore(args): Encrypt a private key to keystore JSON
- decryptKeystore(args): Decrypt keystore JSON to recover private key
- AptosKeyStore: TypeScript interface for the keystore format
- KeystorePrivateKey, KeystoreEncryptOptions: Supporting types
Includes 23 unit tests covering all key types, both KDFs, round-trip
encryption/decryption, error handling, and cryptographic verification.
Co-authored-by: Greg Nazario <greg@gnazar.io>1 parent e896d78 commit d698df8
File tree
4 files changed
+781
-0
lines changed- src/core/crypto
- tests/unit
4 files changed
+781
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
7 | 16 | | |
8 | 17 | | |
9 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
0 commit comments