ox 0.6.12 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.ts CHANGED
@@ -1559,6 +1559,54 @@ export * as Fee from './core/Fee.js'
1559
1559
  */
1560
1560
  export * as Json from './core/Json.js'
1561
1561
 
1562
+ /**
1563
+ * Utilities & types for working with [Keystores](https://ethereum.org/en/developers/docs/data-structures-and-encoding/web3-secret-storage).
1564
+ *
1565
+ * @example
1566
+ * ### Encrypting & Decrypting Private Keys
1567
+ *
1568
+ * Private keys can be encrypted into a JSON keystore using {@link ox#Keystore.(encrypt:function)} and decrypted using {@link ox#Keystore.(decrypt:function)}:
1569
+ *
1570
+ * ```ts twoslash
1571
+ * import { Keystore, Secp256k1 } from 'ox'
1572
+ *
1573
+ * // Generate a random private key.
1574
+ * const privateKey = Secp256k1.randomPrivateKey()
1575
+ *
1576
+ * // Derive a key from a password.
1577
+ * const key = Keystore.pbkdf2({ password: 'testpassword' })
1578
+ *
1579
+ * // Encrypt the private key.
1580
+ * const encrypted = await Keystore.encrypt(privateKey, key)
1581
+ * // @log: {
1582
+ * // @log: "crypto": {
1583
+ * // @log: "cipher": "aes-128-ctr",
1584
+ * // @log: "ciphertext": "...",
1585
+ * // @log: "cipherparams": {
1586
+ * // @log: "iv": "...",
1587
+ * // @log: },
1588
+ * // @log: "kdf": "pbkdf2",
1589
+ * // @log: "kdfparams": {
1590
+ * // @log: "salt": "...",
1591
+ * // @log: "dklen": 32,
1592
+ * // @log: "prf": "hmac-sha256",
1593
+ * // @log: "c": 262144,
1594
+ * // @log: },
1595
+ * // @log: "mac": "...",
1596
+ * // @log: },
1597
+ * // @log: "id": "...",
1598
+ * // @log: "version": 3,
1599
+ * // @log: }
1600
+ *
1601
+ * // Decrypt the private key.
1602
+ * const decrypted = await Keystore.decrypt(encrypted, key)
1603
+ * // @log: "0x..."
1604
+ * ```
1605
+ *
1606
+ * @category Crypto
1607
+ */
1608
+ export * as Keystore from './core/Keystore.js'
1609
+
1562
1610
  /**
1563
1611
  * Utility functions for working with KZG Commitments.
1564
1612
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ox",
3
3
  "description": "Ethereum Standard Library",
4
- "version": "0.6.12",
4
+ "version": "0.7.1",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
@@ -16,6 +16,7 @@
16
16
  ],
17
17
  "dependencies": {
18
18
  "@adraffy/ens-normalize": "^1.10.1",
19
+ "@noble/ciphers": "^1.3.0",
19
20
  "@noble/curves": "^1.6.0",
20
21
  "@noble/hashes": "^1.5.0",
21
22
  "@scure/bip39": "^1.4.0",
@@ -212,6 +213,11 @@
212
213
  "import": "./_esm/core/Json.js",
213
214
  "default": "./_cjs/core/Json.js"
214
215
  },
216
+ "./Keystore": {
217
+ "types": "./_types/core/Keystore.d.ts",
218
+ "import": "./_esm/core/Keystore.js",
219
+ "default": "./_cjs/core/Keystore.js"
220
+ },
215
221
  "./Kzg": {
216
222
  "types": "./_types/core/Kzg.d.ts",
217
223
  "import": "./_esm/core/Kzg.js",
package/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  /** @internal */
2
- export const version = '0.6.12'
2
+ export const version = '0.7.1'