ox 1.1.0 → 1.1.2

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.
Files changed (184) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/core/Engine.d.ts +43 -11
  3. package/dist/core/Engine.d.ts.map +1 -1
  4. package/dist/core/Engine.js +40 -10
  5. package/dist/core/Engine.js.map +1 -1
  6. package/dist/core/internal/engine.d.ts +8 -8
  7. package/dist/core/internal/engine.d.ts.map +1 -1
  8. package/dist/index.d.ts +5 -2
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +5 -2
  11. package/dist/index.js.map +1 -1
  12. package/dist/node/Ed25519.d.ts +33 -0
  13. package/dist/node/Ed25519.d.ts.map +1 -0
  14. package/dist/node/Ed25519.js +67 -0
  15. package/dist/node/Ed25519.js.map +1 -0
  16. package/dist/node/Engine.d.ts +29 -16
  17. package/dist/node/Engine.d.ts.map +1 -1
  18. package/dist/node/Engine.js +38 -14
  19. package/dist/node/Engine.js.map +1 -1
  20. package/dist/node/Hash.d.ts +14 -16
  21. package/dist/node/Hash.d.ts.map +1 -1
  22. package/dist/node/Hash.js +14 -16
  23. package/dist/node/Hash.js.map +1 -1
  24. package/dist/node/Keystore.d.ts +36 -0
  25. package/dist/node/Keystore.d.ts.map +1 -0
  26. package/dist/node/Keystore.js +72 -0
  27. package/dist/node/Keystore.js.map +1 -0
  28. package/dist/node/Mnemonic.d.ts +35 -0
  29. package/dist/node/Mnemonic.d.ts.map +1 -0
  30. package/dist/node/Mnemonic.js +46 -0
  31. package/dist/node/Mnemonic.js.map +1 -0
  32. package/dist/node/P256.d.ts +32 -0
  33. package/dist/node/P256.d.ts.map +1 -0
  34. package/dist/node/P256.js +34 -0
  35. package/dist/node/P256.js.map +1 -0
  36. package/dist/node/X25519.d.ts +31 -0
  37. package/dist/node/X25519.d.ts.map +1 -0
  38. package/dist/node/X25519.js +71 -0
  39. package/dist/node/X25519.js.map +1 -0
  40. package/dist/node/index.d.ts +95 -8
  41. package/dist/node/index.d.ts.map +1 -1
  42. package/dist/node/index.js +95 -8
  43. package/dist/node/index.js.map +1 -1
  44. package/dist/wasm/Ed25519.d.ts +35 -0
  45. package/dist/wasm/Ed25519.d.ts.map +1 -0
  46. package/dist/wasm/Ed25519.js +88 -0
  47. package/dist/wasm/Ed25519.js.map +1 -0
  48. package/dist/wasm/Engine.d.ts +35 -26
  49. package/dist/wasm/Engine.d.ts.map +1 -1
  50. package/dist/wasm/Engine.js +44 -25
  51. package/dist/wasm/Engine.js.map +1 -1
  52. package/dist/wasm/Hash.d.ts +13 -19
  53. package/dist/wasm/Hash.d.ts.map +1 -1
  54. package/dist/wasm/Hash.js +21 -27
  55. package/dist/wasm/Hash.js.map +1 -1
  56. package/dist/wasm/Keystore.d.ts +37 -0
  57. package/dist/wasm/Keystore.d.ts.map +1 -0
  58. package/dist/wasm/Keystore.js +34 -0
  59. package/dist/wasm/Keystore.js.map +1 -0
  60. package/dist/wasm/Mnemonic.d.ts +33 -0
  61. package/dist/wasm/Mnemonic.d.ts.map +1 -0
  62. package/dist/wasm/Mnemonic.js +30 -0
  63. package/dist/wasm/Mnemonic.js.map +1 -0
  64. package/dist/wasm/X25519.d.ts +33 -0
  65. package/dist/wasm/X25519.d.ts.map +1 -0
  66. package/dist/wasm/X25519.js +53 -0
  67. package/dist/wasm/X25519.js.map +1 -0
  68. package/dist/wasm/index.d.ts +81 -12
  69. package/dist/wasm/index.d.ts.map +1 -1
  70. package/dist/wasm/index.js +81 -12
  71. package/dist/wasm/index.js.map +1 -1
  72. package/dist/wasm/internal/blake3.d.ts +11 -0
  73. package/dist/wasm/internal/blake3.d.ts.map +1 -0
  74. package/dist/wasm/internal/blake3.js +31 -0
  75. package/dist/wasm/internal/blake3.js.map +1 -0
  76. package/dist/wasm/internal/blake3.wasm.d.ts +3 -0
  77. package/dist/wasm/internal/blake3.wasm.d.ts.map +1 -0
  78. package/dist/wasm/internal/blake3.wasm.js +10 -0
  79. package/dist/wasm/internal/blake3.wasm.js.map +1 -0
  80. package/dist/wasm/internal/crypto25519.d.ts +16 -0
  81. package/dist/wasm/internal/crypto25519.d.ts.map +1 -0
  82. package/dist/wasm/internal/crypto25519.js +5 -0
  83. package/dist/wasm/internal/crypto25519.js.map +1 -0
  84. package/dist/wasm/internal/crypto25519.wasm.d.ts +3 -0
  85. package/dist/wasm/internal/crypto25519.wasm.d.ts.map +1 -0
  86. package/dist/wasm/internal/crypto25519.wasm.js +10 -0
  87. package/dist/wasm/internal/crypto25519.wasm.js.map +1 -0
  88. package/dist/wasm/internal/ed25519.d.ts +4 -0
  89. package/dist/wasm/internal/ed25519.d.ts.map +1 -0
  90. package/dist/wasm/internal/ed25519.js +21 -0
  91. package/dist/wasm/internal/ed25519.js.map +1 -0
  92. package/dist/wasm/internal/hashes.d.ts +12 -0
  93. package/dist/wasm/internal/hashes.d.ts.map +1 -0
  94. package/dist/wasm/internal/hashes.js +8 -0
  95. package/dist/wasm/internal/hashes.js.map +1 -0
  96. package/dist/wasm/internal/hashes.wasm.d.ts +4 -2
  97. package/dist/wasm/internal/hashes.wasm.d.ts.map +1 -1
  98. package/dist/wasm/internal/hashes.wasm.js +4 -2
  99. package/dist/wasm/internal/hashes.wasm.js.map +1 -1
  100. package/dist/wasm/internal/mnemonic.d.ts +4 -0
  101. package/dist/wasm/internal/mnemonic.d.ts.map +1 -0
  102. package/dist/wasm/internal/mnemonic.js +45 -0
  103. package/dist/wasm/internal/mnemonic.js.map +1 -0
  104. package/dist/wasm/internal/pbkdf2.d.ts +12 -0
  105. package/dist/wasm/internal/pbkdf2.d.ts.map +1 -0
  106. package/dist/wasm/internal/pbkdf2.js +51 -0
  107. package/dist/wasm/internal/pbkdf2.js.map +1 -0
  108. package/dist/wasm/internal/x25519.d.ts +4 -0
  109. package/dist/wasm/internal/x25519.d.ts.map +1 -0
  110. package/dist/wasm/internal/x25519.js +21 -0
  111. package/dist/wasm/internal/x25519.js.map +1 -0
  112. package/package.json +46 -1
  113. package/src/core/Engine.ts +84 -11
  114. package/src/core/_test/Engine.test-d.ts +56 -0
  115. package/src/core/_test/Engine.test.ts +95 -0
  116. package/src/core/_test/Hash.vectors.test.ts +8 -0
  117. package/src/core/internal/engine.ts +8 -8
  118. package/src/index.ts +5 -2
  119. package/src/node/Ed25519.ts +87 -0
  120. package/src/node/Engine.ts +79 -23
  121. package/src/node/Hash.ts +22 -27
  122. package/src/node/Keystore.ts +103 -0
  123. package/src/node/Mnemonic.ts +68 -0
  124. package/src/node/P256.ts +48 -0
  125. package/src/node/X25519.ts +93 -0
  126. package/src/node/_test/Curves.fuzz.ts +76 -0
  127. package/src/node/_test/Ed25519.test-d.ts +35 -0
  128. package/src/node/_test/Ed25519.test.ts +220 -0
  129. package/src/node/_test/Engine.test-d.ts +28 -0
  130. package/src/node/_test/Engine.test.ts +62 -22
  131. package/src/node/_test/Hash.test-d.ts +15 -9
  132. package/src/node/_test/Hash.test.ts +10 -11
  133. package/src/node/_test/Keystore.fuzz.ts +58 -0
  134. package/src/node/_test/Keystore.test-d.ts +43 -0
  135. package/src/node/_test/Keystore.test.ts +198 -0
  136. package/src/node/_test/Mnemonic.fuzz.ts +31 -0
  137. package/src/node/_test/Mnemonic.test-d.ts +21 -0
  138. package/src/node/_test/Mnemonic.test.ts +98 -0
  139. package/src/node/_test/P256.test-d.ts +29 -0
  140. package/src/node/_test/P256.test.ts +102 -0
  141. package/src/node/_test/X25519.test-d.ts +28 -0
  142. package/src/node/_test/X25519.test.ts +239 -0
  143. package/src/node/index.ts +100 -8
  144. package/src/version.ts +1 -1
  145. package/src/wasm/Ed25519.ts +114 -0
  146. package/src/wasm/Engine.ts +76 -31
  147. package/src/wasm/Hash.bench.ts +2 -2
  148. package/src/wasm/Hash.ts +29 -50
  149. package/src/wasm/Keystore.ts +48 -0
  150. package/src/wasm/Mnemonic.ts +44 -0
  151. package/src/wasm/X25519.ts +70 -0
  152. package/src/wasm/_test/Crypto25519.conformance.ts +57 -0
  153. package/src/wasm/_test/Crypto25519.fuzz.ts +187 -0
  154. package/src/wasm/_test/Ed25519.test-d.ts +28 -0
  155. package/src/wasm/_test/Ed25519.test.ts +168 -0
  156. package/src/wasm/_test/Ed25519.vectors.test.ts +73 -0
  157. package/src/wasm/_test/Engine.test-d.ts +28 -0
  158. package/src/wasm/_test/Engine.test.ts +59 -25
  159. package/src/wasm/_test/Hash.browser.test.ts +11 -7
  160. package/src/wasm/_test/Hash.fuzz.ts +58 -23
  161. package/src/wasm/_test/Hash.test-d.ts +15 -10
  162. package/src/wasm/_test/Hash.test.ts +148 -48
  163. package/src/wasm/_test/Hash.vectors.test.ts +15 -8
  164. package/src/wasm/_test/Keystore.browser.test.ts +42 -0
  165. package/src/wasm/_test/Keystore.fuzz.ts +113 -0
  166. package/src/wasm/_test/Keystore.test-d.ts +33 -0
  167. package/src/wasm/_test/Keystore.test.ts +192 -0
  168. package/src/wasm/_test/Keystore.vectors.test.ts +21 -0
  169. package/src/wasm/_test/Mnemonic.test-d.ts +17 -0
  170. package/src/wasm/_test/Mnemonic.test.ts +110 -0
  171. package/src/wasm/_test/X25519.test-d.ts +21 -0
  172. package/src/wasm/_test/X25519.test.ts +194 -0
  173. package/src/wasm/_test/fixtures.ts +4 -0
  174. package/src/wasm/index.ts +85 -12
  175. package/src/wasm/internal/blake3.ts +45 -0
  176. package/src/wasm/internal/blake3.wasm.ts +11 -0
  177. package/src/wasm/internal/crypto25519.ts +43 -0
  178. package/src/wasm/internal/crypto25519.wasm.ts +11 -0
  179. package/src/wasm/internal/ed25519.ts +31 -0
  180. package/src/wasm/internal/hashes.ts +29 -0
  181. package/src/wasm/internal/hashes.wasm.ts +5 -2
  182. package/src/wasm/internal/mnemonic.ts +56 -0
  183. package/src/wasm/internal/pbkdf2.ts +86 -0
  184. package/src/wasm/internal/x25519.ts +29 -0
@@ -1,12 +1,14 @@
1
1
  import type * as Engine from '../core/Engine.js';
2
2
  import type * as Errors from '../core/Errors.js';
3
3
  import * as internal from './internal/instantiate.js';
4
+ export * from '../core/Hash.js';
4
5
  export { MemoryError } from './internal/instantiate.js';
5
6
  /**
6
- * Compiles the WASM implementation of the [`Hash`](/api/Hash) primitives, without
7
- * installing it.
7
+ * Compiles the WASM implementation of the [`Hash`](/api/Hash) primitives,
8
+ * without installing it.
8
9
  *
9
- * Most callers want {@link ox#Engine.load} instead, which compiles every
10
+ * Most callers want
11
+ * [`Engine.install`](/wasm/crypto/Engine/install) instead, which compiles every
10
12
  * implementation this entrypoint provides and installs them in one call. Reach
11
13
  * for this to take the `Hash` slot on its own, or to hold the implementation
12
14
  * without touching the installed engine.
@@ -20,29 +22,21 @@ export { MemoryError } from './internal/instantiate.js';
20
22
  * @example
21
23
  * ```ts twoslash
22
24
  * // @noErrors
23
- * import { Engine, Hash } from 'ox'
24
- * import * as WasmHash from 'ox/wasm/Hash'
25
+ * import { Engine } from 'ox'
26
+ * import { Hash } from 'ox/wasm'
25
27
  *
26
- * Engine.set(await WasmHash.create())
28
+ * await Engine.install({ Hash: Hash.engine() })
27
29
  *
28
30
  * Hash.keccak256('0xdeadbeef')
29
31
  * ```
30
32
  *
31
- * @returns An engine supplying the `Hash` slot.
33
+ * @returns The WASM implementation of the `Hash` slot.
32
34
  */
33
- export declare function create(): Promise<create.ReturnType>;
34
- export declare namespace create {
35
- /**
36
- * The `Hash` slot, carrying every primitive this module implements.
37
- *
38
- * {@link ox#Engine.Engine} is optional all the way down so that an engine can
39
- * fill in as little as it likes. This one always fills the same four, and
40
- * saying so is what spares callers a non-null assertion per primitive.
41
- */
35
+ export declare function engine(): Promise<engine.ReturnType>;
36
+ export declare namespace engine {
37
+ /** Every `Hash` primitive this module implements. */
42
38
  type ReturnType = {
43
- Hash: {
44
- [key in 'hmacSha256' | 'keccak256' | 'ripemd160' | 'sha256']-?: NonNullable<Engine.Hash[key]>;
45
- };
39
+ [key in 'blake3' | 'hmacSha256' | 'keccak256' | 'ripemd160' | 'sha256']-?: NonNullable<Engine.Hash[key]>;
46
40
  };
47
41
  type ErrorType = internal.MemoryError | Errors.GlobalErrorType;
48
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Hash.d.ts","sourceRoot":"","sources":["../../src/wasm/Hash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAGhD,OAAO,KAAK,QAAQ,MAAM,2BAA2B,CAAA;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAwBvD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CA6BzD;AAED,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC;IAC9B;;;;;;OAMG;IACH,KAAK,UAAU,GAAG;QAChB,IAAI,EAAE;aACH,GAAG,IACA,YAAY,GACZ,WAAW,GACX,WAAW,GACX,QAAQ,CAAC,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAC/C,CAAA;KACF,CAAA;IAED,KAAK,SAAS,GAAG,QAAQ,CAAC,WAAW,GAAG,MAAM,CAAC,eAAe,CAAA;CAC/D"}
1
+ {"version":3,"file":"Hash.d.ts","sourceRoot":"","sources":["../../src/wasm/Hash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAIhD,OAAO,KAAK,QAAQ,MAAM,2BAA2B,CAAA;AAErD,cAAc,iBAAiB,CAAA;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAKvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CA+BzD;AAED,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC;IAC9B,qDAAqD;IACrD,KAAK,UAAU,GAAG;SACf,GAAG,IACA,QAAQ,GACR,YAAY,GACZ,WAAW,GACX,WAAW,GACX,QAAQ,CAAC,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAC/C,CAAA;IAED,KAAK,SAAS,GAAG,QAAQ,CAAC,WAAW,GAAG,MAAM,CAAC,eAAe,CAAA;CAC/D"}
package/dist/wasm/Hash.js CHANGED
@@ -1,24 +1,16 @@
1
+ import * as blake3 from './internal/blake3.js';
1
2
  import * as hash from './internal/hash.js';
2
- import { wasmBase64 } from './internal/hashes.wasm.js';
3
- import * as internal from './internal/instantiate.js';
3
+ import * as hashes from './internal/hashes.js';
4
+ export * from '../core/Hash.js';
4
5
  export { MemoryError } from './internal/instantiate.js';
5
6
  /** Digest sizes, in bytes. */
6
7
  const digestSize = { keccak256: 32, ripemd160: 20, sha256: 32 };
7
8
  /**
8
- * Compilation is memoized; the engine object deliberately is not.
9
+ * Compiles the WASM implementation of the [`Hash`](/api/Hash) primitives,
10
+ * without installing it.
9
11
  *
10
- * Handing every caller the same object means one of them customising a slot
11
- * for composition silently changes what a later `create` -- or `Engine.load`
12
- * -- installs.
13
- *
14
- * @internal
15
- */
16
- const instantiate = /*#__PURE__*/ internal.memoize(() => internal.instantiate(wasmBase64));
17
- /**
18
- * Compiles the WASM implementation of the [`Hash`](/api/Hash) primitives, without
19
- * installing it.
20
- *
21
- * Most callers want {@link ox#Engine.load} instead, which compiles every
12
+ * Most callers want
13
+ * [`Engine.install`](/wasm/crypto/Engine/install) instead, which compiles every
22
14
  * implementation this entrypoint provides and installs them in one call. Reach
23
15
  * for this to take the `Hash` slot on its own, or to hold the implementation
24
16
  * without touching the installed engine.
@@ -32,19 +24,22 @@ const instantiate = /*#__PURE__*/ internal.memoize(() => internal.instantiate(wa
32
24
  * @example
33
25
  * ```ts twoslash
34
26
  * // @noErrors
35
- * import { Engine, Hash } from 'ox'
36
- * import * as WasmHash from 'ox/wasm/Hash'
27
+ * import { Engine } from 'ox'
28
+ * import { Hash } from 'ox/wasm'
37
29
  *
38
- * Engine.set(await WasmHash.create())
30
+ * await Engine.install({ Hash: Hash.engine() })
39
31
  *
40
32
  * Hash.keccak256('0xdeadbeef')
41
33
  * ```
42
34
  *
43
- * @returns An engine supplying the `Hash` slot.
35
+ * @returns The WASM implementation of the `Hash` slot.
44
36
  */
45
- export async function create() {
37
+ export async function engine() {
46
38
  {
47
- const module = await instantiate();
39
+ const [blake3Module, module] = await Promise.all([
40
+ blake3.load(),
41
+ hashes.load(),
42
+ ]);
48
43
  // Copies `input` in, runs `hash`, and copies the digest back out.
49
44
  function call(hash, input) {
50
45
  const out = digestSize[hash];
@@ -58,12 +53,11 @@ export async function create() {
58
53
  return module.view().slice(outPtr, outPtr + out);
59
54
  }
60
55
  return {
61
- Hash: {
62
- hmacSha256: (key, message) => hash.hmacSha256(module, key, message),
63
- keccak256: (input) => call('keccak256', input),
64
- ripemd160: (input) => call('ripemd160', input),
65
- sha256: (input) => call('sha256', input),
66
- },
56
+ blake3: (input) => blake3.hash(blake3Module, input),
57
+ hmacSha256: (key, message) => hash.hmacSha256(module, key, message),
58
+ keccak256: (input) => call('keccak256', input),
59
+ ripemd160: (input) => call('ripemd160', input),
60
+ sha256: (input) => call('sha256', input),
67
61
  };
68
62
  }
69
63
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Hash.js","sourceRoot":"","sources":["../../src/wasm/Hash.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,KAAK,QAAQ,MAAM,2BAA2B,CAAA;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAQvD,8BAA8B;AAC9B,MAAM,UAAU,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAA;AAE/D;;;;;;;;GAQG;AACH,MAAM,WAAW,GAAG,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,CACtD,QAAQ,CAAC,WAAW,CAAU,UAAU,CAAC,CAC1C,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM;IAC1B,CAAC;QACC,MAAM,MAAM,GAAG,MAAM,WAAW,EAAE,CAAA;QAElC,kEAAkE;QAClE,SAAS,IAAI,CACX,IAA0C,EAC1C,KAAiB;YAEjB,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,CAAA;YAC5B,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC,CAAA;YAClC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAA;YAChC,MAAM,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAA;YACtC,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;YAClC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;YACpD,4EAA4E;YAC5E,uDAAuD;YACvD,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,CAAA;QAClD,CAAC;QAED,OAAO;YACL,IAAI,EAAE;gBACJ,UAAU,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC;gBACnE,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC;gBAC9C,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC;gBAC9C,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC;aACzC;SACF,CAAA;IACH,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"Hash.js","sourceRoot":"","sources":["../../src/wasm/Hash.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAA;AAC9C,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAC1C,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAA;AAG9C,cAAc,iBAAiB,CAAA;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAEvD,8BAA8B;AAC9B,MAAM,UAAU,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAA;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM;IAC1B,CAAC;QACC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YAC/C,MAAM,CAAC,IAAI,EAAE;YACb,MAAM,CAAC,IAAI,EAAE;SACd,CAAC,CAAA;QAEF,kEAAkE;QAClE,SAAS,IAAI,CACX,IAA0C,EAC1C,KAAiB;YAEjB,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,CAAA;YAC5B,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC,CAAA;YAClC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAA;YAChC,MAAM,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAA;YACtC,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;YAClC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;YACpD,4EAA4E;YAC5E,uDAAuD;YACvD,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,CAAA;QAClD,CAAC;QAED,OAAO;YACL,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC;YACnD,UAAU,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC;YACnE,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC;YAC9C,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC;YAC9C,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC;SACzC,CAAA;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type * as Engine from '../core/Engine.js';
2
+ import type * as Errors from '../core/Errors.js';
3
+ import * as internal from './internal/instantiate.js';
4
+ export * from '../core/Keystore.js';
5
+ export { MemoryError } from './internal/instantiate.js';
6
+ /**
7
+ * Compiles the WASM implementation of the [`Keystore`](/api/Keystore) PBKDF2
8
+ * primitive, without installing it.
9
+ *
10
+ * Most callers want
11
+ * [`Engine.install`](/wasm/crypto/Engine/install) instead, which compiles every
12
+ * implementation this entrypoint provides and installs them in one call. This
13
+ * provider deliberately stays synchronous and leaves AES, asynchronous PBKDF2,
14
+ * and scrypt on Ox's default implementation.
15
+ *
16
+ * @example
17
+ * ```ts twoslash
18
+ * // @noErrors
19
+ * import { Engine } from 'ox'
20
+ * import { Keystore } from 'ox/wasm'
21
+ *
22
+ * await Engine.install({ Keystore: Keystore.engine() })
23
+ *
24
+ * Keystore.pbkdf2({ password: 'testpassword' })
25
+ * ```
26
+ *
27
+ * @returns The WASM implementation of synchronous PBKDF2-HMAC-SHA256.
28
+ */
29
+ export declare function engine(): Promise<engine.ReturnType>;
30
+ export declare namespace engine {
31
+ /** The WASM `Keystore` primitives this module implements. */
32
+ type ReturnType = {
33
+ pbkdf2Sha256: NonNullable<Engine.Keystore['pbkdf2Sha256']>;
34
+ };
35
+ type ErrorType = internal.MemoryError | Errors.GlobalErrorType;
36
+ }
37
+ //# sourceMappingURL=Keystore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Keystore.d.ts","sourceRoot":"","sources":["../../src/wasm/Keystore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAEhD,OAAO,KAAK,QAAQ,MAAM,2BAA2B,CAAA;AAGrD,cAAc,qBAAqB,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAEvD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAMzD;AAED,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC;IAC9B,6DAA6D;IAC7D,KAAK,UAAU,GAAG;QAChB,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAA;KAC3D,CAAA;IAED,KAAK,SAAS,GAAG,QAAQ,CAAC,WAAW,GAAG,MAAM,CAAC,eAAe,CAAA;CAC/D"}
@@ -0,0 +1,34 @@
1
+ import * as hashes from './internal/hashes.js';
2
+ import * as pbkdf2 from './internal/pbkdf2.js';
3
+ export * from '../core/Keystore.js';
4
+ export { MemoryError } from './internal/instantiate.js';
5
+ /**
6
+ * Compiles the WASM implementation of the [`Keystore`](/api/Keystore) PBKDF2
7
+ * primitive, without installing it.
8
+ *
9
+ * Most callers want
10
+ * [`Engine.install`](/wasm/crypto/Engine/install) instead, which compiles every
11
+ * implementation this entrypoint provides and installs them in one call. This
12
+ * provider deliberately stays synchronous and leaves AES, asynchronous PBKDF2,
13
+ * and scrypt on Ox's default implementation.
14
+ *
15
+ * @example
16
+ * ```ts twoslash
17
+ * // @noErrors
18
+ * import { Engine } from 'ox'
19
+ * import { Keystore } from 'ox/wasm'
20
+ *
21
+ * await Engine.install({ Keystore: Keystore.engine() })
22
+ *
23
+ * Keystore.pbkdf2({ password: 'testpassword' })
24
+ * ```
25
+ *
26
+ * @returns The WASM implementation of synchronous PBKDF2-HMAC-SHA256.
27
+ */
28
+ export async function engine() {
29
+ const module = await hashes.load();
30
+ return {
31
+ pbkdf2Sha256: (password, salt, options) => pbkdf2.pbkdf2Sha256(module, password, salt, options),
32
+ };
33
+ }
34
+ //# sourceMappingURL=Keystore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Keystore.js","sourceRoot":"","sources":["../../src/wasm/Keystore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAA;AAE9C,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAA;AAE9C,cAAc,qBAAqB,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAEvD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM;IAC1B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAA;IAClC,OAAO;QACL,YAAY,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CACxC,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC;KACvD,CAAA;AACH,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type * as Engine from '../core/Engine.js';
2
+ import type * as Errors from '../core/Errors.js';
3
+ import * as internal from './internal/instantiate.js';
4
+ export * from '../core/Mnemonic.js';
5
+ export { MemoryError } from './internal/instantiate.js';
6
+ /**
7
+ * Compiles the WASM implementation of [`Mnemonic.toSeed`](/api/Mnemonic/toSeed),
8
+ * without installing it.
9
+ *
10
+ * @example
11
+ * ```ts twoslash
12
+ * // @noErrors
13
+ * import { Engine } from 'ox'
14
+ * import { Mnemonic } from 'ox/wasm'
15
+ *
16
+ * await Engine.install({ Mnemonic: Mnemonic.engine() })
17
+ *
18
+ * Mnemonic.toSeed(
19
+ * 'test test test test test test test test test test test junk'
20
+ * )
21
+ * ```
22
+ *
23
+ * @returns The WASM implementation of the `Mnemonic` slot.
24
+ */
25
+ export declare function engine(): Promise<engine.ReturnType>;
26
+ export declare namespace engine {
27
+ /** Every `Mnemonic` primitive this module implements. */
28
+ type ReturnType = {
29
+ toSeed: NonNullable<Engine.Mnemonic['toSeed']>;
30
+ };
31
+ type ErrorType = internal.MemoryError | Errors.GlobalErrorType;
32
+ }
33
+ //# sourceMappingURL=Mnemonic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Mnemonic.d.ts","sourceRoot":"","sources":["../../src/wasm/Mnemonic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAEhD,OAAO,KAAK,QAAQ,MAAM,2BAA2B,CAAA;AAGrD,cAAc,qBAAqB,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAEvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAMzD;AAED,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC;IAC9B,yDAAyD;IACzD,KAAK,UAAU,GAAG;QAChB,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAA;KAC/C,CAAA;IAED,KAAK,SAAS,GAAG,QAAQ,CAAC,WAAW,GAAG,MAAM,CAAC,eAAe,CAAA;CAC/D"}
@@ -0,0 +1,30 @@
1
+ import * as crypto25519 from './internal/crypto25519.js';
2
+ import * as mnemonic from './internal/mnemonic.js';
3
+ export * from '../core/Mnemonic.js';
4
+ export { MemoryError } from './internal/instantiate.js';
5
+ /**
6
+ * Compiles the WASM implementation of [`Mnemonic.toSeed`](/api/Mnemonic/toSeed),
7
+ * without installing it.
8
+ *
9
+ * @example
10
+ * ```ts twoslash
11
+ * // @noErrors
12
+ * import { Engine } from 'ox'
13
+ * import { Mnemonic } from 'ox/wasm'
14
+ *
15
+ * await Engine.install({ Mnemonic: Mnemonic.engine() })
16
+ *
17
+ * Mnemonic.toSeed(
18
+ * 'test test test test test test test test test test test junk'
19
+ * )
20
+ * ```
21
+ *
22
+ * @returns The WASM implementation of the `Mnemonic` slot.
23
+ */
24
+ export async function engine() {
25
+ const module = await crypto25519.load();
26
+ return {
27
+ toSeed: (value, passphrase) => mnemonic.toSeed(module, value, passphrase),
28
+ };
29
+ }
30
+ //# sourceMappingURL=Mnemonic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Mnemonic.js","sourceRoot":"","sources":["../../src/wasm/Mnemonic.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,WAAW,MAAM,2BAA2B,CAAA;AAExD,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAA;AAElD,cAAc,qBAAqB,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAEvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM;IAC1B,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,IAAI,EAAE,CAAA;IAEvC,OAAO;QACL,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC;KAC1E,CAAA;AACH,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type * as Engine from '../core/Engine.js';
2
+ import type * as Errors from '../core/Errors.js';
3
+ import * as internal from './internal/instantiate.js';
4
+ export * from '../core/X25519.js';
5
+ export { MemoryError } from './internal/instantiate.js';
6
+ /**
7
+ * Compiles WASM implementations of selected [`X25519`](/api/X25519)
8
+ * primitives, without installing them.
9
+ *
10
+ * Random key generation remains on Ox's default implementation.
11
+ *
12
+ * @example
13
+ * ```ts twoslash
14
+ * // @noErrors
15
+ * import { Engine } from 'ox'
16
+ * import { X25519 } from 'ox/wasm'
17
+ *
18
+ * await Engine.install({ X25519: X25519.engine() })
19
+ *
20
+ * X25519.getPublicKey({ privateKey: '0x...' })
21
+ * ```
22
+ *
23
+ * @returns The WASM implementation of part of the `X25519` slot.
24
+ */
25
+ export declare function engine(): Promise<engine.ReturnType>;
26
+ export declare namespace engine {
27
+ /** Every `X25519` primitive this module implements. */
28
+ type ReturnType = {
29
+ [key in 'getPublicKey' | 'getSharedSecret']-?: NonNullable<Engine.Ecdh[key]>;
30
+ };
31
+ type ErrorType = internal.MemoryError | Errors.GlobalErrorType;
32
+ }
33
+ //# sourceMappingURL=X25519.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"X25519.d.ts","sourceRoot":"","sources":["../../src/wasm/X25519.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAEhD,OAAO,KAAK,QAAQ,MAAM,2BAA2B,CAAA;AAGrD,cAAc,mBAAmB,CAAA;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAIvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAuBzD;AAED,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC;IAC9B,uDAAuD;IACvD,KAAK,UAAU,GAAG;SACf,GAAG,IAAI,cAAc,GAAG,iBAAiB,CAAC,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAC7E,CAAA;IAED,KAAK,SAAS,GAAG,QAAQ,CAAC,WAAW,GAAG,MAAM,CAAC,eAAe,CAAA;CAC/D"}
@@ -0,0 +1,53 @@
1
+ import * as crypto25519 from './internal/crypto25519.js';
2
+ import * as x25519 from './internal/x25519.js';
3
+ export * from '../core/X25519.js';
4
+ export { MemoryError } from './internal/instantiate.js';
5
+ const keySize = 32;
6
+ /**
7
+ * Compiles WASM implementations of selected [`X25519`](/api/X25519)
8
+ * primitives, without installing them.
9
+ *
10
+ * Random key generation remains on Ox's default implementation.
11
+ *
12
+ * @example
13
+ * ```ts twoslash
14
+ * // @noErrors
15
+ * import { Engine } from 'ox'
16
+ * import { X25519 } from 'ox/wasm'
17
+ *
18
+ * await Engine.install({ X25519: X25519.engine() })
19
+ *
20
+ * X25519.getPublicKey({ privateKey: '0x...' })
21
+ * ```
22
+ *
23
+ * @returns The WASM implementation of part of the `X25519` slot.
24
+ */
25
+ export async function engine() {
26
+ const module = await crypto25519.load();
27
+ return {
28
+ getPublicKey(privateKey) {
29
+ assertLength(privateKey, 'private');
30
+ module.reserve(keySize * 2);
31
+ const privateKeyPtr = module.heapBase;
32
+ const publicKeyPtr = privateKeyPtr + keySize;
33
+ try {
34
+ module.view().set(privateKey, privateKeyPtr);
35
+ module.exports.x25519_get_public_key(privateKeyPtr, publicKeyPtr);
36
+ return module.view().slice(publicKeyPtr, publicKeyPtr + keySize);
37
+ }
38
+ finally {
39
+ module.exports.zero(privateKeyPtr, keySize * 2);
40
+ }
41
+ },
42
+ getSharedSecret(privateKey, publicKey) {
43
+ assertLength(privateKey, 'private');
44
+ assertLength(publicKey, 'public');
45
+ return x25519.getSharedSecret(module, privateKey, publicKey);
46
+ },
47
+ };
48
+ }
49
+ function assertLength(key, type) {
50
+ if (key.length !== keySize)
51
+ throw new RangeError(`X25519 ${type} key must be ${keySize} bytes, got ${key.length}`);
52
+ }
53
+ //# sourceMappingURL=X25519.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"X25519.js","sourceRoot":"","sources":["../../src/wasm/X25519.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,WAAW,MAAM,2BAA2B,CAAA;AAExD,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAA;AAE9C,cAAc,mBAAmB,CAAA;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAEvD,MAAM,OAAO,GAAG,EAAE,CAAA;AAElB;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM;IAC1B,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,IAAI,EAAE,CAAA;IAEvC,OAAO;QACL,YAAY,CAAC,UAAU;YACrB,YAAY,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;YACnC,MAAM,CAAC,OAAO,CAAC,OAAO,GAAG,CAAC,CAAC,CAAA;YAC3B,MAAM,aAAa,GAAG,MAAM,CAAC,QAAQ,CAAA;YACrC,MAAM,YAAY,GAAG,aAAa,GAAG,OAAO,CAAA;YAC5C,IAAI,CAAC;gBACH,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,aAAa,CAAC,CAAA;gBAC5C,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC,aAAa,EAAE,YAAY,CAAC,CAAA;gBACjE,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,CAAA;YAClE,CAAC;oBAAS,CAAC;gBACT,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,GAAG,CAAC,CAAC,CAAA;YACjD,CAAC;QACH,CAAC;QACD,eAAe,CAAC,UAAU,EAAE,SAAS;YACnC,YAAY,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;YACnC,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;YACjC,OAAO,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,CAAC,CAAA;QAC9D,CAAC;KACF,CAAA;AACH,CAAC;AAWD,SAAS,YAAY,CAAC,GAAe,EAAE,IAA0B;IAC/D,IAAI,GAAG,CAAC,MAAM,KAAK,OAAO;QACxB,MAAM,IAAI,UAAU,CAClB,UAAU,IAAI,gBAAgB,OAAO,eAAe,GAAG,CAAC,MAAM,EAAE,CACjE,CAAA;AACL,CAAC"}
@@ -1,10 +1,10 @@
1
1
  /** @entrypointCategory WASM */
2
2
  /**
3
- * WASM implementations of ox's hash primitives, compiled from C.
3
+ * WASM implementations of Ox's supported cryptographic primitives, compiled
4
+ * from C.
4
5
  *
5
- * Load it and hand the result to {@link ox#Engine.set}. WASM must be compiled
6
- * asynchronously, so the `await` lives here -- every call afterwards is
7
- * synchronous.
6
+ * Install it during startup. WASM must be compiled asynchronously, so the
7
+ * `await` lives there. Every cryptographic call afterwards is synchronous.
8
8
  *
9
9
  * :::note
10
10
  * Performance varies by primitive, input size, runtime, and processor. Run
@@ -15,32 +15,101 @@
15
15
  * @example
16
16
  * ```ts twoslash
17
17
  * // @noErrors
18
- * import { Hash } from 'ox'
19
- * import { Engine } from 'ox/wasm'
18
+ * import { Engine, Hash } from 'ox/wasm'
20
19
  *
21
- * await Engine.load()
20
+ * await Engine.install()
22
21
  *
23
- * Hash.keccak256('0xdeadbeef')
22
+ * Hash.sha256('0xdeadbeef')
24
23
  * ```
25
24
  *
26
25
  * @category Crypto
27
26
  */
28
27
  export * as Engine from './Engine.js';
28
+ /**
29
+ * WASM implementations of Ox's supported Ed25519 primitives.
30
+ *
31
+ * @example
32
+ * ```ts twoslash
33
+ * // @noErrors
34
+ * import { Engine } from 'ox'
35
+ * import { Ed25519 } from 'ox/wasm'
36
+ *
37
+ * await Engine.install({ Ed25519: Ed25519.engine() })
38
+ *
39
+ * Ed25519.getPublicKey({ privateKey: '0x...' })
40
+ * ```
41
+ *
42
+ * @category Crypto
43
+ */
44
+ export * as Ed25519 from './Ed25519.js';
29
45
  /**
30
46
  * WASM implementations of Ox's supported hash primitives.
31
47
  *
32
48
  * @example
33
49
  * ```ts twoslash
34
50
  * // @noErrors
35
- * import { Engine, Hash } from 'ox'
36
- * import * as WasmHash from 'ox/wasm/Hash'
51
+ * import { Engine } from 'ox'
52
+ * import { Hash } from 'ox/wasm'
37
53
  *
38
- * Engine.set(await WasmHash.create())
54
+ * await Engine.install({ Hash: Hash.engine() })
39
55
  *
40
- * Hash.keccak256('0xdeadbeef')
56
+ * Hash.sha256('0xdeadbeef')
41
57
  * ```
42
58
  *
43
59
  * @category Crypto
44
60
  */
45
61
  export * as Hash from './Hash.js';
62
+ /**
63
+ * WASM implementation of Ox's synchronous PBKDF2-HMAC-SHA256 primitive.
64
+ *
65
+ * @example
66
+ * ```ts twoslash
67
+ * // @noErrors
68
+ * import { Engine } from 'ox'
69
+ * import { Keystore } from 'ox/wasm'
70
+ *
71
+ * await Engine.install({ Keystore: Keystore.engine() })
72
+ *
73
+ * Keystore.pbkdf2({ password: 'testpassword' })
74
+ * ```
75
+ *
76
+ * @category Crypto
77
+ */
78
+ export * as Keystore from './Keystore.js';
79
+ /**
80
+ * WASM implementation of Ox's BIP-39 seed derivation.
81
+ *
82
+ * @example
83
+ * ```ts twoslash
84
+ * // @noErrors
85
+ * import { Engine } from 'ox'
86
+ * import { Mnemonic } from 'ox/wasm'
87
+ *
88
+ * await Engine.install({ Mnemonic: Mnemonic.engine() })
89
+ *
90
+ * Mnemonic.toSeed(
91
+ * 'test test test test test test test test test test test junk'
92
+ * )
93
+ * ```
94
+ *
95
+ * @category Crypto
96
+ */
97
+ export * as Mnemonic from './Mnemonic.js';
98
+ /**
99
+ * WASM implementations of Ox's supported X25519 primitives.
100
+ *
101
+ * @example
102
+ * ```ts twoslash
103
+ * // @noErrors
104
+ * import { Engine } from 'ox'
105
+ * import { X25519 } from 'ox/wasm'
106
+ *
107
+ * await Engine.install({ X25519: X25519.engine() })
108
+ *
109
+ * X25519.getPublicKey({ privateKey: '0x...' })
110
+ * ```
111
+ *
112
+ * @category Crypto
113
+ */
114
+ export * as X25519 from './X25519.js';
46
115
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wasm/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAE/B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wasm/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAE/B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA"}
@@ -1,10 +1,10 @@
1
1
  /** @entrypointCategory WASM */
2
2
  /**
3
- * WASM implementations of ox's hash primitives, compiled from C.
3
+ * WASM implementations of Ox's supported cryptographic primitives, compiled
4
+ * from C.
4
5
  *
5
- * Load it and hand the result to {@link ox#Engine.set}. WASM must be compiled
6
- * asynchronously, so the `await` lives here -- every call afterwards is
7
- * synchronous.
6
+ * Install it during startup. WASM must be compiled asynchronously, so the
7
+ * `await` lives there. Every cryptographic call afterwards is synchronous.
8
8
  *
9
9
  * :::note
10
10
  * Performance varies by primitive, input size, runtime, and processor. Run
@@ -15,32 +15,101 @@
15
15
  * @example
16
16
  * ```ts twoslash
17
17
  * // @noErrors
18
- * import { Hash } from 'ox'
19
- * import { Engine } from 'ox/wasm'
18
+ * import { Engine, Hash } from 'ox/wasm'
20
19
  *
21
- * await Engine.load()
20
+ * await Engine.install()
22
21
  *
23
- * Hash.keccak256('0xdeadbeef')
22
+ * Hash.sha256('0xdeadbeef')
24
23
  * ```
25
24
  *
26
25
  * @category Crypto
27
26
  */
28
27
  export * as Engine from './Engine.js';
28
+ /**
29
+ * WASM implementations of Ox's supported Ed25519 primitives.
30
+ *
31
+ * @example
32
+ * ```ts twoslash
33
+ * // @noErrors
34
+ * import { Engine } from 'ox'
35
+ * import { Ed25519 } from 'ox/wasm'
36
+ *
37
+ * await Engine.install({ Ed25519: Ed25519.engine() })
38
+ *
39
+ * Ed25519.getPublicKey({ privateKey: '0x...' })
40
+ * ```
41
+ *
42
+ * @category Crypto
43
+ */
44
+ export * as Ed25519 from './Ed25519.js';
29
45
  /**
30
46
  * WASM implementations of Ox's supported hash primitives.
31
47
  *
32
48
  * @example
33
49
  * ```ts twoslash
34
50
  * // @noErrors
35
- * import { Engine, Hash } from 'ox'
36
- * import * as WasmHash from 'ox/wasm/Hash'
51
+ * import { Engine } from 'ox'
52
+ * import { Hash } from 'ox/wasm'
37
53
  *
38
- * Engine.set(await WasmHash.create())
54
+ * await Engine.install({ Hash: Hash.engine() })
39
55
  *
40
- * Hash.keccak256('0xdeadbeef')
56
+ * Hash.sha256('0xdeadbeef')
41
57
  * ```
42
58
  *
43
59
  * @category Crypto
44
60
  */
45
61
  export * as Hash from './Hash.js';
62
+ /**
63
+ * WASM implementation of Ox's synchronous PBKDF2-HMAC-SHA256 primitive.
64
+ *
65
+ * @example
66
+ * ```ts twoslash
67
+ * // @noErrors
68
+ * import { Engine } from 'ox'
69
+ * import { Keystore } from 'ox/wasm'
70
+ *
71
+ * await Engine.install({ Keystore: Keystore.engine() })
72
+ *
73
+ * Keystore.pbkdf2({ password: 'testpassword' })
74
+ * ```
75
+ *
76
+ * @category Crypto
77
+ */
78
+ export * as Keystore from './Keystore.js';
79
+ /**
80
+ * WASM implementation of Ox's BIP-39 seed derivation.
81
+ *
82
+ * @example
83
+ * ```ts twoslash
84
+ * // @noErrors
85
+ * import { Engine } from 'ox'
86
+ * import { Mnemonic } from 'ox/wasm'
87
+ *
88
+ * await Engine.install({ Mnemonic: Mnemonic.engine() })
89
+ *
90
+ * Mnemonic.toSeed(
91
+ * 'test test test test test test test test test test test junk'
92
+ * )
93
+ * ```
94
+ *
95
+ * @category Crypto
96
+ */
97
+ export * as Mnemonic from './Mnemonic.js';
98
+ /**
99
+ * WASM implementations of Ox's supported X25519 primitives.
100
+ *
101
+ * @example
102
+ * ```ts twoslash
103
+ * // @noErrors
104
+ * import { Engine } from 'ox'
105
+ * import { X25519 } from 'ox/wasm'
106
+ *
107
+ * await Engine.install({ X25519: X25519.engine() })
108
+ *
109
+ * X25519.getPublicKey({ privateKey: '0x...' })
110
+ * ```
111
+ *
112
+ * @category Crypto
113
+ */
114
+ export * as X25519 from './X25519.js';
46
115
  //# sourceMappingURL=index.js.map