ox 1.0.5 → 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 (337) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/dist/core/Base64.d.ts +10 -21
  3. package/dist/core/Base64.d.ts.map +1 -1
  4. package/dist/core/Base64.js +8 -127
  5. package/dist/core/Base64.js.map +1 -1
  6. package/dist/core/BinaryStateTree.d.ts.map +1 -1
  7. package/dist/core/BinaryStateTree.js +2 -2
  8. package/dist/core/BinaryStateTree.js.map +1 -1
  9. package/dist/core/Bls.d.ts.map +1 -1
  10. package/dist/core/Bls.js +19 -44
  11. package/dist/core/Bls.js.map +1 -1
  12. package/dist/core/Ed25519.d.ts.map +1 -1
  13. package/dist/core/Ed25519.js +7 -6
  14. package/dist/core/Ed25519.js.map +1 -1
  15. package/dist/core/Engine.d.ts +156 -0
  16. package/dist/core/Engine.d.ts.map +1 -0
  17. package/dist/core/Engine.js +210 -0
  18. package/dist/core/Engine.js.map +1 -0
  19. package/dist/core/Hash.d.ts +4 -4
  20. package/dist/core/Hash.d.ts.map +1 -1
  21. package/dist/core/Hash.js +9 -12
  22. package/dist/core/Hash.js.map +1 -1
  23. package/dist/core/Keystore.d.ts.map +1 -1
  24. package/dist/core/Keystore.js +15 -10
  25. package/dist/core/Keystore.js.map +1 -1
  26. package/dist/core/Mnemonic.d.ts.map +1 -1
  27. package/dist/core/Mnemonic.js +3 -2
  28. package/dist/core/Mnemonic.js.map +1 -1
  29. package/dist/core/P256.d.ts.map +1 -1
  30. package/dist/core/P256.js +8 -9
  31. package/dist/core/P256.js.map +1 -1
  32. package/dist/core/Secp256k1.d.ts.map +1 -1
  33. package/dist/core/Secp256k1.js +8 -9
  34. package/dist/core/Secp256k1.js.map +1 -1
  35. package/dist/core/WebCryptoP256.d.ts.map +1 -1
  36. package/dist/core/WebCryptoP256.js +2 -2
  37. package/dist/core/WebCryptoP256.js.map +1 -1
  38. package/dist/core/X25519.d.ts.map +1 -1
  39. package/dist/core/X25519.js +4 -3
  40. package/dist/core/X25519.js.map +1 -1
  41. package/dist/core/internal/bls.d.ts +12 -0
  42. package/dist/core/internal/bls.d.ts.map +1 -0
  43. package/dist/core/internal/bls.js +79 -0
  44. package/dist/core/internal/bls.js.map +1 -0
  45. package/dist/core/internal/codec/base64.d.ts +84 -0
  46. package/dist/core/internal/codec/base64.d.ts.map +1 -0
  47. package/dist/core/internal/codec/base64.js +177 -0
  48. package/dist/core/internal/codec/base64.js.map +1 -0
  49. package/dist/core/internal/codec/hex.d.ts +49 -4
  50. package/dist/core/internal/codec/hex.d.ts.map +1 -1
  51. package/dist/core/internal/codec/hex.js +109 -35
  52. package/dist/core/internal/codec/hex.js.map +1 -1
  53. package/dist/core/internal/curves.d.ts +17 -0
  54. package/dist/core/internal/curves.d.ts.map +1 -0
  55. package/dist/core/internal/curves.js +17 -0
  56. package/dist/core/internal/curves.js.map +1 -0
  57. package/dist/core/internal/ed25519.d.ts +14 -0
  58. package/dist/core/internal/ed25519.d.ts.map +1 -0
  59. package/dist/core/internal/ed25519.js +29 -0
  60. package/dist/core/internal/ed25519.js.map +1 -0
  61. package/dist/core/internal/engine.d.ts +278 -0
  62. package/dist/core/internal/engine.d.ts.map +1 -0
  63. package/dist/core/internal/engine.js +131 -0
  64. package/dist/core/internal/engine.js.map +1 -0
  65. package/dist/core/internal/hash.d.ts +12 -0
  66. package/dist/core/internal/hash.d.ts.map +1 -0
  67. package/dist/core/internal/hash.js +30 -0
  68. package/dist/core/internal/hash.js.map +1 -0
  69. package/dist/core/internal/keystore.d.ts +14 -0
  70. package/dist/core/internal/keystore.d.ts.map +1 -0
  71. package/dist/core/internal/keystore.js +32 -0
  72. package/dist/core/internal/keystore.js.map +1 -0
  73. package/dist/core/internal/mnemonic.d.ts +4 -0
  74. package/dist/core/internal/mnemonic.d.ts.map +1 -0
  75. package/dist/core/internal/mnemonic.js +14 -0
  76. package/dist/core/internal/mnemonic.js.map +1 -0
  77. package/dist/core/internal/p256.d.ts +14 -0
  78. package/dist/core/internal/p256.d.ts.map +1 -0
  79. package/dist/core/internal/p256.js +36 -0
  80. package/dist/core/internal/p256.js.map +1 -0
  81. package/dist/core/internal/secp256k1.d.ts +14 -0
  82. package/dist/core/internal/secp256k1.d.ts.map +1 -0
  83. package/dist/core/internal/secp256k1.js +36 -0
  84. package/dist/core/internal/secp256k1.js.map +1 -0
  85. package/dist/core/internal/x25519.d.ts +8 -0
  86. package/dist/core/internal/x25519.d.ts.map +1 -0
  87. package/dist/core/internal/x25519.js +20 -0
  88. package/dist/core/internal/x25519.js.map +1 -0
  89. package/dist/index.d.ts +38 -0
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.docs.d.ts +2 -0
  92. package/dist/index.docs.d.ts.map +1 -1
  93. package/dist/index.docs.js +2 -0
  94. package/dist/index.docs.js.map +1 -1
  95. package/dist/index.js +38 -0
  96. package/dist/index.js.map +1 -1
  97. package/dist/node/Ed25519.d.ts +33 -0
  98. package/dist/node/Ed25519.d.ts.map +1 -0
  99. package/dist/node/Ed25519.js +67 -0
  100. package/dist/node/Ed25519.js.map +1 -0
  101. package/dist/node/Engine.d.ts +68 -0
  102. package/dist/node/Engine.d.ts.map +1 -0
  103. package/dist/node/Engine.js +75 -0
  104. package/dist/node/Engine.js.map +1 -0
  105. package/dist/node/Hash.d.ts +37 -0
  106. package/dist/node/Hash.d.ts.map +1 -0
  107. package/dist/node/Hash.js +35 -0
  108. package/dist/node/Hash.js.map +1 -0
  109. package/dist/node/Keystore.d.ts +36 -0
  110. package/dist/node/Keystore.d.ts.map +1 -0
  111. package/dist/node/Keystore.js +72 -0
  112. package/dist/node/Keystore.js.map +1 -0
  113. package/dist/node/Mnemonic.d.ts +35 -0
  114. package/dist/node/Mnemonic.d.ts.map +1 -0
  115. package/dist/node/Mnemonic.js +46 -0
  116. package/dist/node/Mnemonic.js.map +1 -0
  117. package/dist/node/P256.d.ts +32 -0
  118. package/dist/node/P256.d.ts.map +1 -0
  119. package/dist/node/P256.js +34 -0
  120. package/dist/node/P256.js.map +1 -0
  121. package/dist/node/X25519.d.ts +31 -0
  122. package/dist/node/X25519.d.ts.map +1 -0
  123. package/dist/node/X25519.js +71 -0
  124. package/dist/node/X25519.js.map +1 -0
  125. package/dist/node/index.d.ts +126 -0
  126. package/dist/node/index.d.ts.map +1 -0
  127. package/dist/node/index.js +126 -0
  128. package/dist/node/index.js.map +1 -0
  129. package/dist/tempo/VirtualMaster.d.ts +2 -0
  130. package/dist/tempo/VirtualMaster.d.ts.map +1 -1
  131. package/dist/tempo/VirtualMaster.js +19 -5
  132. package/dist/tempo/VirtualMaster.js.map +1 -1
  133. package/dist/tempo/internal/mine.wasm.d.ts +2 -4
  134. package/dist/tempo/internal/mine.wasm.d.ts.map +1 -1
  135. package/dist/tempo/internal/mine.wasm.js +7 -12
  136. package/dist/tempo/internal/mine.wasm.js.map +1 -1
  137. package/dist/tempo/internal/virtualMasterPool.js +4 -1
  138. package/dist/tempo/internal/virtualMasterPool.js.map +1 -1
  139. package/dist/wasm/Ed25519.d.ts +35 -0
  140. package/dist/wasm/Ed25519.d.ts.map +1 -0
  141. package/dist/wasm/Ed25519.js +88 -0
  142. package/dist/wasm/Ed25519.js.map +1 -0
  143. package/dist/wasm/Engine.d.ts +71 -0
  144. package/dist/wasm/Engine.d.ts.map +1 -0
  145. package/dist/wasm/Engine.js +76 -0
  146. package/dist/wasm/Engine.js.map +1 -0
  147. package/dist/wasm/Hash.d.ts +43 -0
  148. package/dist/wasm/Hash.d.ts.map +1 -0
  149. package/dist/wasm/Hash.js +64 -0
  150. package/dist/wasm/Hash.js.map +1 -0
  151. package/dist/wasm/Keystore.d.ts +37 -0
  152. package/dist/wasm/Keystore.d.ts.map +1 -0
  153. package/dist/wasm/Keystore.js +34 -0
  154. package/dist/wasm/Keystore.js.map +1 -0
  155. package/dist/wasm/Mnemonic.d.ts +33 -0
  156. package/dist/wasm/Mnemonic.d.ts.map +1 -0
  157. package/dist/wasm/Mnemonic.js +30 -0
  158. package/dist/wasm/Mnemonic.js.map +1 -0
  159. package/dist/wasm/X25519.d.ts +33 -0
  160. package/dist/wasm/X25519.d.ts.map +1 -0
  161. package/dist/wasm/X25519.js +53 -0
  162. package/dist/wasm/X25519.js.map +1 -0
  163. package/dist/wasm/index.d.ts +115 -0
  164. package/dist/wasm/index.d.ts.map +1 -0
  165. package/dist/wasm/index.js +115 -0
  166. package/dist/wasm/index.js.map +1 -0
  167. package/dist/wasm/internal/blake3.d.ts +11 -0
  168. package/dist/wasm/internal/blake3.d.ts.map +1 -0
  169. package/dist/wasm/internal/blake3.js +31 -0
  170. package/dist/wasm/internal/blake3.js.map +1 -0
  171. package/dist/wasm/internal/blake3.wasm.d.ts +3 -0
  172. package/dist/wasm/internal/blake3.wasm.d.ts.map +1 -0
  173. package/dist/wasm/internal/blake3.wasm.js +10 -0
  174. package/dist/wasm/internal/blake3.wasm.js.map +1 -0
  175. package/dist/wasm/internal/crypto25519.d.ts +16 -0
  176. package/dist/wasm/internal/crypto25519.d.ts.map +1 -0
  177. package/dist/wasm/internal/crypto25519.js +5 -0
  178. package/dist/wasm/internal/crypto25519.js.map +1 -0
  179. package/dist/wasm/internal/crypto25519.wasm.d.ts +3 -0
  180. package/dist/wasm/internal/crypto25519.wasm.d.ts.map +1 -0
  181. package/dist/wasm/internal/crypto25519.wasm.js +10 -0
  182. package/dist/wasm/internal/crypto25519.wasm.js.map +1 -0
  183. package/dist/wasm/internal/ed25519.d.ts +4 -0
  184. package/dist/wasm/internal/ed25519.d.ts.map +1 -0
  185. package/dist/wasm/internal/ed25519.js +21 -0
  186. package/dist/wasm/internal/ed25519.js.map +1 -0
  187. package/dist/wasm/internal/hash.d.ts +9 -0
  188. package/dist/wasm/internal/hash.d.ts.map +1 -0
  189. package/dist/wasm/internal/hash.js +26 -0
  190. package/dist/wasm/internal/hash.js.map +1 -0
  191. package/dist/wasm/internal/hashes.d.ts +12 -0
  192. package/dist/wasm/internal/hashes.d.ts.map +1 -0
  193. package/dist/wasm/internal/hashes.js +8 -0
  194. package/dist/wasm/internal/hashes.js.map +1 -0
  195. package/dist/wasm/internal/hashes.wasm.d.ts +7 -0
  196. package/dist/wasm/internal/hashes.wasm.d.ts.map +1 -0
  197. package/dist/wasm/internal/hashes.wasm.js +14 -0
  198. package/dist/wasm/internal/hashes.wasm.js.map +1 -0
  199. package/dist/wasm/internal/instantiate.d.ts +56 -0
  200. package/dist/wasm/internal/instantiate.d.ts.map +1 -0
  201. package/dist/wasm/internal/instantiate.js +92 -0
  202. package/dist/wasm/internal/instantiate.js.map +1 -0
  203. package/dist/wasm/internal/mnemonic.d.ts +4 -0
  204. package/dist/wasm/internal/mnemonic.d.ts.map +1 -0
  205. package/dist/wasm/internal/mnemonic.js +45 -0
  206. package/dist/wasm/internal/mnemonic.js.map +1 -0
  207. package/dist/wasm/internal/pbkdf2.d.ts +12 -0
  208. package/dist/wasm/internal/pbkdf2.d.ts.map +1 -0
  209. package/dist/wasm/internal/pbkdf2.js +51 -0
  210. package/dist/wasm/internal/pbkdf2.js.map +1 -0
  211. package/dist/wasm/internal/x25519.d.ts +4 -0
  212. package/dist/wasm/internal/x25519.d.ts.map +1 -0
  213. package/dist/wasm/internal/x25519.js +21 -0
  214. package/dist/wasm/internal/x25519.js.map +1 -0
  215. package/dist/zod/TypedData.d.ts +12 -12
  216. package/package.json +81 -1
  217. package/src/core/Base64.ts +19 -166
  218. package/src/core/BinaryStateTree.ts +2 -3
  219. package/src/core/Bls.ts +27 -77
  220. package/src/core/Ed25519.ts +7 -7
  221. package/src/core/Engine.ts +308 -0
  222. package/src/core/Hash.ts +9 -12
  223. package/src/core/Keystore.ts +17 -17
  224. package/src/core/Mnemonic.ts +3 -6
  225. package/src/core/P256.ts +15 -24
  226. package/src/core/Rlp_tx.bench.ts +2 -4
  227. package/src/core/Secp256k1.ts +9 -14
  228. package/src/core/TxEnvelopeEip1559.bench.ts +0 -5
  229. package/src/core/WebCryptoP256.ts +2 -2
  230. package/src/core/X25519.ts +4 -3
  231. package/src/core/_test/AbiParameters.adversarial.fuzz.ts +1 -2
  232. package/src/core/_test/AbiParameters.fuzz.ts +1 -2
  233. package/src/core/_test/Base.fuzz.ts +1 -2
  234. package/src/core/_test/Cbor.fuzz.ts +1 -2
  235. package/src/core/_test/Engine.fuzz.ts +293 -0
  236. package/src/core/_test/Engine.test-d.ts +140 -0
  237. package/src/core/_test/Engine.test.ts +618 -0
  238. package/src/core/_test/Hash.vectors.test.ts +64 -0
  239. package/src/core/_test/Hex.fuzz.ts +1 -2
  240. package/src/core/_test/Rlp.fuzz.ts +1 -2
  241. package/src/core/_test/Signature.fuzz.ts +1 -2
  242. package/src/core/_test/curves.test.ts +7 -0
  243. package/src/core/_test/index.test.ts +1 -0
  244. package/src/core/internal/bls.ts +121 -0
  245. package/src/core/internal/codec/_test/base64.conformance.ts +156 -0
  246. package/src/core/internal/codec/_test/hex.conformance.ts +204 -0
  247. package/src/core/internal/codec/_test/hex.fuzz.ts +234 -0
  248. package/src/core/internal/codec/_test/hex.test.ts +124 -0
  249. package/src/core/internal/codec/base64.ts +222 -0
  250. package/src/core/internal/codec/hex.ts +115 -34
  251. package/src/core/internal/curves.ts +18 -0
  252. package/src/core/internal/ed25519.ts +64 -0
  253. package/src/core/internal/engine.ts +410 -0
  254. package/src/core/internal/hash.ts +48 -0
  255. package/src/core/internal/keystore.ts +107 -0
  256. package/src/core/internal/mnemonic.ts +18 -0
  257. package/src/core/internal/p256.ts +91 -0
  258. package/src/core/internal/secp256k1.ts +91 -0
  259. package/src/core/internal/x25519.ts +40 -0
  260. package/src/index.docs.ts +2 -0
  261. package/src/index.ts +39 -0
  262. package/src/node/Ed25519.ts +87 -0
  263. package/src/node/Engine.ts +125 -0
  264. package/src/node/Hash.ts +51 -0
  265. package/src/node/Keystore.ts +103 -0
  266. package/src/node/Mnemonic.ts +68 -0
  267. package/src/node/P256.ts +48 -0
  268. package/src/node/X25519.ts +93 -0
  269. package/src/node/_test/Curves.fuzz.ts +76 -0
  270. package/src/node/_test/Ed25519.test-d.ts +35 -0
  271. package/src/node/_test/Ed25519.test.ts +220 -0
  272. package/src/node/_test/Engine.test-d.ts +28 -0
  273. package/src/node/_test/Engine.test.ts +102 -0
  274. package/src/node/_test/Hash.test-d.ts +32 -0
  275. package/src/node/_test/Hash.test.ts +101 -0
  276. package/src/node/_test/Keystore.fuzz.ts +58 -0
  277. package/src/node/_test/Keystore.test-d.ts +43 -0
  278. package/src/node/_test/Keystore.test.ts +198 -0
  279. package/src/node/_test/Mnemonic.fuzz.ts +31 -0
  280. package/src/node/_test/Mnemonic.test-d.ts +21 -0
  281. package/src/node/_test/Mnemonic.test.ts +98 -0
  282. package/src/node/_test/P256.test-d.ts +29 -0
  283. package/src/node/_test/P256.test.ts +102 -0
  284. package/src/node/_test/X25519.test-d.ts +28 -0
  285. package/src/node/_test/X25519.test.ts +239 -0
  286. package/src/node/index.ts +132 -0
  287. package/src/tempo/VirtualMaster.test.ts +75 -0
  288. package/src/tempo/VirtualMaster.ts +28 -6
  289. package/src/tempo/internal/mine.wasm.ts +7 -13
  290. package/src/tempo/internal/virtualMasterPool.ts +4 -1
  291. package/src/tsconfig.json +2 -1
  292. package/src/version.ts +1 -1
  293. package/src/wasm/Ed25519.ts +114 -0
  294. package/src/wasm/Engine.ts +121 -0
  295. package/src/wasm/Hash.bench.ts +60 -0
  296. package/src/wasm/Hash.ts +88 -0
  297. package/src/wasm/Keystore.ts +48 -0
  298. package/src/wasm/Mnemonic.ts +44 -0
  299. package/src/wasm/X25519.ts +70 -0
  300. package/src/wasm/_test/Crypto25519.conformance.ts +57 -0
  301. package/src/wasm/_test/Crypto25519.fuzz.ts +187 -0
  302. package/src/wasm/_test/Ed25519.test-d.ts +28 -0
  303. package/src/wasm/_test/Ed25519.test.ts +168 -0
  304. package/src/wasm/_test/Ed25519.vectors.test.ts +73 -0
  305. package/src/wasm/_test/Engine.test-d.ts +28 -0
  306. package/src/wasm/_test/Engine.test.ts +96 -0
  307. package/src/wasm/_test/Hash.browser.test.ts +54 -0
  308. package/src/wasm/_test/Hash.fuzz.ts +223 -0
  309. package/src/wasm/_test/Hash.test-d.ts +33 -0
  310. package/src/wasm/_test/Hash.test.ts +311 -0
  311. package/src/wasm/_test/Hash.vectors.test.ts +124 -0
  312. package/src/wasm/_test/Keystore.browser.test.ts +42 -0
  313. package/src/wasm/_test/Keystore.fuzz.ts +113 -0
  314. package/src/wasm/_test/Keystore.test-d.ts +33 -0
  315. package/src/wasm/_test/Keystore.test.ts +192 -0
  316. package/src/wasm/_test/Keystore.vectors.test.ts +21 -0
  317. package/src/wasm/_test/Mnemonic.test-d.ts +17 -0
  318. package/src/wasm/_test/Mnemonic.test.ts +110 -0
  319. package/src/wasm/_test/Runtime.test.ts +21 -0
  320. package/src/wasm/_test/X25519.test-d.ts +21 -0
  321. package/src/wasm/_test/X25519.test.ts +194 -0
  322. package/src/wasm/_test/fixtures.ts +4 -0
  323. package/src/wasm/_test/runtime.wasm.ts +11 -0
  324. package/src/wasm/index.ts +120 -0
  325. package/src/wasm/internal/blake3.ts +45 -0
  326. package/src/wasm/internal/blake3.wasm.ts +11 -0
  327. package/src/wasm/internal/crypto25519.ts +43 -0
  328. package/src/wasm/internal/crypto25519.wasm.ts +11 -0
  329. package/src/wasm/internal/ed25519.ts +31 -0
  330. package/src/wasm/internal/hash.ts +50 -0
  331. package/src/wasm/internal/hashes.ts +29 -0
  332. package/src/wasm/internal/hashes.wasm.ts +17 -0
  333. package/src/wasm/internal/instantiate.ts +135 -0
  334. package/src/wasm/internal/mnemonic.ts +56 -0
  335. package/src/wasm/internal/pbkdf2.ts +86 -0
  336. package/src/wasm/internal/x25519.ts +29 -0
  337. package/src/tempo/internal/mine.c +0 -182
@@ -0,0 +1,37 @@
1
+ import type * as Engine from '../core/Engine.js';
2
+ import type * as Errors from '../core/Errors.js';
3
+ export * from '../core/Hash.js';
4
+ /**
5
+ * Creates a Node.js implementation of the [`Hash`](/api/Hash) engine slot,
6
+ * without installing it.
7
+ *
8
+ * Most callers want [`Engine.install`](/node/crypto/Engine/install) instead,
9
+ * which installs every implementation this entrypoint provides. Reach for this
10
+ * to install or hold the `Hash` slot on its own.
11
+ *
12
+ * Node's `sha3-256` is not Ethereum Keccak256, so this engine deliberately
13
+ * omits `keccak256`. Any earlier override remains installed; otherwise Ox uses
14
+ * its default implementation.
15
+ *
16
+ * @example
17
+ * ```ts twoslash
18
+ * // @noErrors
19
+ * import { Engine } from 'ox'
20
+ * import { Hash } from 'ox/node'
21
+ *
22
+ * await Engine.install({ Hash: Hash.engine() })
23
+ *
24
+ * Hash.sha256('0xdeadbeef')
25
+ * ```
26
+ *
27
+ * @returns The raw `Hash` engine slot.
28
+ */
29
+ export declare function engine(): Promise<engine.ReturnType>;
30
+ export declare namespace engine {
31
+ /** Every `Hash` primitive this module implements. */
32
+ type ReturnType = {
33
+ [key in 'hmacSha256' | 'ripemd160' | 'sha256']-?: NonNullable<Engine.Hash[key]>;
34
+ };
35
+ type ErrorType = Errors.GlobalErrorType;
36
+ }
37
+ //# sourceMappingURL=Hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Hash.d.ts","sourceRoot":"","sources":["../../src/node/Hash.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAEhD,cAAc,iBAAiB,CAAA;AAE/B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAQnD;AAED,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC;IAC9B,qDAAqD;IACrD,KAAK,UAAU,GAAG;SACf,GAAG,IAAI,YAAY,GAAG,WAAW,GAAG,QAAQ,CAAC,CAAC,GAAG,WAAW,CAC3D,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CACjB;KACF,CAAA;IAED,KAAK,SAAS,GAAG,MAAM,CAAC,eAAe,CAAA;CACxC"}
@@ -0,0 +1,35 @@
1
+ import * as crypto from 'node:crypto';
2
+ export * from '../core/Hash.js';
3
+ /**
4
+ * Creates a Node.js implementation of the [`Hash`](/api/Hash) engine slot,
5
+ * without installing it.
6
+ *
7
+ * Most callers want [`Engine.install`](/node/crypto/Engine/install) instead,
8
+ * which installs every implementation this entrypoint provides. Reach for this
9
+ * to install or hold the `Hash` slot on its own.
10
+ *
11
+ * Node's `sha3-256` is not Ethereum Keccak256, so this engine deliberately
12
+ * omits `keccak256`. Any earlier override remains installed; otherwise Ox uses
13
+ * its default implementation.
14
+ *
15
+ * @example
16
+ * ```ts twoslash
17
+ * // @noErrors
18
+ * import { Engine } from 'ox'
19
+ * import { Hash } from 'ox/node'
20
+ *
21
+ * await Engine.install({ Hash: Hash.engine() })
22
+ *
23
+ * Hash.sha256('0xdeadbeef')
24
+ * ```
25
+ *
26
+ * @returns The raw `Hash` engine slot.
27
+ */
28
+ export function engine() {
29
+ return Promise.resolve({
30
+ hmacSha256: (key, message) => new Uint8Array(crypto.createHmac('sha256', key).update(message).digest()),
31
+ ripemd160: (input) => new Uint8Array(crypto.hash('ripemd160', input, 'buffer')),
32
+ sha256: (input) => new Uint8Array(crypto.hash('sha256', input, 'buffer')),
33
+ });
34
+ }
35
+ //# sourceMappingURL=Hash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Hash.js","sourceRoot":"","sources":["../../src/node/Hash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAIrC,cAAc,iBAAiB,CAAA;AAE/B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,MAAM;IACpB,OAAO,OAAO,CAAC,OAAO,CAAC;QACrB,UAAU,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAC3B,IAAI,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC;QAC3E,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CACnB,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC3D,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;KAC1E,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type * as Engine from '../core/Engine.js';
2
+ import type * as Errors from '../core/Errors.js';
3
+ export * from '../core/Keystore.js';
4
+ /**
5
+ * Creates a Node.js implementation of the [`Keystore`](/api/Keystore) engine
6
+ * slot, without installing it.
7
+ *
8
+ * Most callers want [`Engine.install`](/node/crypto/Engine/install) instead,
9
+ * which installs every implementation this entrypoint provides. Reach for this
10
+ * to install or hold the `Keystore` slot on its own.
11
+ *
12
+ * This engine deliberately omits scrypt. OpenSSL rejects Ox's default scrypt
13
+ * parameter shape, so installing it would make valid existing calls fail.
14
+ *
15
+ * @example
16
+ * ```ts twoslash
17
+ * // @noErrors
18
+ * import { Engine } from 'ox'
19
+ * import { Keystore } from 'ox/node'
20
+ *
21
+ * await Engine.install({ Keystore: Keystore.engine() })
22
+ *
23
+ * Keystore.pbkdf2({ password: 'testpassword' })
24
+ * ```
25
+ *
26
+ * @returns The raw `Keystore` engine slot.
27
+ */
28
+ export declare function engine(): Promise<engine.ReturnType>;
29
+ export declare namespace engine {
30
+ /** Every `Keystore` primitive this module implements. */
31
+ type ReturnType = {
32
+ [key in 'aesCtrDecrypt' | 'aesCtrEncrypt' | 'pbkdf2Sha256' | 'pbkdf2Sha256Async']-?: NonNullable<Engine.Keystore[key]>;
33
+ };
34
+ type ErrorType = Errors.GlobalErrorType;
35
+ }
36
+ //# sourceMappingURL=Keystore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Keystore.d.ts","sourceRoot":"","sources":["../../src/node/Keystore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAEhD,cAAc,qBAAqB,CAAA;AAEnC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAqCnD;AAED,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC;IAC9B,yDAAyD;IACzD,KAAK,UAAU,GAAG;SACf,GAAG,IACA,eAAe,GACf,eAAe,GACf,cAAc,GACd,mBAAmB,CAAC,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;KAC9D,CAAA;IAED,KAAK,SAAS,GAAG,MAAM,CAAC,eAAe,CAAA;CACxC"}
@@ -0,0 +1,72 @@
1
+ import * as crypto from 'node:crypto';
2
+ export * from '../core/Keystore.js';
3
+ /**
4
+ * Creates a Node.js implementation of the [`Keystore`](/api/Keystore) engine
5
+ * slot, without installing it.
6
+ *
7
+ * Most callers want [`Engine.install`](/node/crypto/Engine/install) instead,
8
+ * which installs every implementation this entrypoint provides. Reach for this
9
+ * to install or hold the `Keystore` slot on its own.
10
+ *
11
+ * This engine deliberately omits scrypt. OpenSSL rejects Ox's default scrypt
12
+ * parameter shape, so installing it would make valid existing calls fail.
13
+ *
14
+ * @example
15
+ * ```ts twoslash
16
+ * // @noErrors
17
+ * import { Engine } from 'ox'
18
+ * import { Keystore } from 'ox/node'
19
+ *
20
+ * await Engine.install({ Keystore: Keystore.engine() })
21
+ *
22
+ * Keystore.pbkdf2({ password: 'testpassword' })
23
+ * ```
24
+ *
25
+ * @returns The raw `Keystore` engine slot.
26
+ */
27
+ export function engine() {
28
+ return Promise.resolve({
29
+ aesCtrDecrypt: (key, iv, data) => {
30
+ const cipher = crypto.createDecipheriv(`aes-${key.length * 8}-ctr`, key, iv);
31
+ return cipherData(cipher, data);
32
+ },
33
+ aesCtrEncrypt: (key, iv, data) => {
34
+ const cipher = crypto.createCipheriv(`aes-${key.length * 8}-ctr`, key, iv);
35
+ return cipherData(cipher, data);
36
+ },
37
+ pbkdf2Sha256: (password, salt, options) => copyAndClear(crypto.pbkdf2Sync(password, salt, options.c, options.dkLen, 'sha256')),
38
+ pbkdf2Sha256Async: (password, salt, options) => new Promise((resolve, reject) => {
39
+ crypto.pbkdf2(password, salt, options.c, options.dkLen, 'sha256', (error, key) => {
40
+ if (error)
41
+ return reject(error);
42
+ try {
43
+ resolve(copyAndClear(key));
44
+ }
45
+ catch (error) {
46
+ reject(error);
47
+ }
48
+ });
49
+ }),
50
+ });
51
+ }
52
+ function cipherData(cipher, data) {
53
+ const chunks = [];
54
+ try {
55
+ chunks.push(cipher.update(data));
56
+ chunks.push(cipher.final());
57
+ return copyAndClear(Buffer.concat(chunks));
58
+ }
59
+ finally {
60
+ for (const chunk of chunks)
61
+ chunk.fill(0);
62
+ }
63
+ }
64
+ function copyAndClear(value) {
65
+ try {
66
+ return Uint8Array.from(value);
67
+ }
68
+ finally {
69
+ value.fill(0);
70
+ }
71
+ }
72
+ //# sourceMappingURL=Keystore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Keystore.js","sourceRoot":"","sources":["../../src/node/Keystore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAIrC,cAAc,qBAAqB,CAAA;AAEnC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,MAAM;IACpB,OAAO,OAAO,CAAC,OAAO,CAAC;QACrB,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;YAC/B,MAAM,MAAM,GAAG,MAAM,CAAC,gBAAgB,CACpC,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,MAAM,EAC3B,GAAG,EACH,EAAE,CACH,CAAA;YACD,OAAO,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QACjC,CAAC;QACD,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;YAC/B,MAAM,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,CAAA;YAC1E,OAAO,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QACjC,CAAC;QACD,YAAY,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CACxC,YAAY,CACV,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CACtE;QACH,iBAAiB,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAC7C,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC9B,MAAM,CAAC,MAAM,CACX,QAAQ,EACR,IAAI,EACJ,OAAO,CAAC,CAAC,EACT,OAAO,CAAC,KAAK,EACb,QAAQ,EACR,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;gBACb,IAAI,KAAK;oBAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;gBAC/B,IAAI,CAAC;oBACH,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAA;gBAC5B,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,CAAC,KAAK,CAAC,CAAA;gBACf,CAAC;YACH,CAAC,CACF,CAAA;QACH,CAAC,CAAC;KACL,CAAC,CAAA;AACJ,CAAC;AAeD,SAAS,UAAU,CACjB,MAA2C,EAC3C,IAAgB;IAEhB,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,IAAI,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;QAChC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAA;QAC3B,OAAO,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5C,CAAC;YAAS,CAAC;QACT,KAAK,MAAM,KAAK,IAAI,MAAM;YAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAC3C,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,KAAa;IACjC,IAAI,CAAC;QACH,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC/B,CAAC;YAAS,CAAC;QACT,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACf,CAAC;AACH,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type * as Engine from '../core/Engine.js';
2
+ import type * as Errors from '../core/Errors.js';
3
+ export * from '../core/Mnemonic.js';
4
+ /**
5
+ * Creates a Node.js implementation of the [`Mnemonic`](/api/Mnemonic) engine
6
+ * slot, without installing it.
7
+ *
8
+ * Most callers want [`Engine.install`](/node/crypto/Engine/install) instead,
9
+ * which installs every implementation this entrypoint provides. Reach for this
10
+ * to install or hold the `Mnemonic` slot on its own.
11
+ *
12
+ * @example
13
+ * ```ts twoslash
14
+ * // @noErrors
15
+ * import { Engine } from 'ox'
16
+ * import { Mnemonic } from 'ox/node'
17
+ *
18
+ * await Engine.install({ Mnemonic: Mnemonic.engine() })
19
+ *
20
+ * Mnemonic.toSeed(
21
+ * 'test test test test test test test test test test test junk'
22
+ * )
23
+ * ```
24
+ *
25
+ * @returns The raw `Mnemonic` engine slot.
26
+ */
27
+ export declare function engine(): Promise<engine.ReturnType>;
28
+ export declare namespace engine {
29
+ /** Every `Mnemonic` primitive this module implements. */
30
+ type ReturnType = {
31
+ [key in 'toSeed']-?: NonNullable<Engine.Mnemonic[key]>;
32
+ };
33
+ type ErrorType = Errors.GlobalErrorType;
34
+ }
35
+ //# sourceMappingURL=Mnemonic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Mnemonic.d.ts","sourceRoot":"","sources":["../../src/node/Mnemonic.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAEhD,cAAc,qBAAqB,CAAA;AAEnC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAqBnD;AAED,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC;IAC9B,yDAAyD;IACzD,KAAK,UAAU,GAAG;SACf,GAAG,IAAI,QAAQ,CAAC,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;KACvD,CAAA;IAED,KAAK,SAAS,GAAG,MAAM,CAAC,eAAe,CAAA;CACxC"}
@@ -0,0 +1,46 @@
1
+ import * as crypto from 'node:crypto';
2
+ export * from '../core/Mnemonic.js';
3
+ /**
4
+ * Creates a Node.js implementation of the [`Mnemonic`](/api/Mnemonic) engine
5
+ * slot, without installing it.
6
+ *
7
+ * Most callers want [`Engine.install`](/node/crypto/Engine/install) instead,
8
+ * which installs every implementation this entrypoint provides. Reach for this
9
+ * to install or hold the `Mnemonic` slot on its own.
10
+ *
11
+ * @example
12
+ * ```ts twoslash
13
+ * // @noErrors
14
+ * import { Engine } from 'ox'
15
+ * import { Mnemonic } from 'ox/node'
16
+ *
17
+ * await Engine.install({ Mnemonic: Mnemonic.engine() })
18
+ *
19
+ * Mnemonic.toSeed(
20
+ * 'test test test test test test test test test test test junk'
21
+ * )
22
+ * ```
23
+ *
24
+ * @returns The raw `Mnemonic` engine slot.
25
+ */
26
+ export function engine() {
27
+ return Promise.resolve({
28
+ toSeed: (mnemonic, passphrase = '') => {
29
+ if (typeof mnemonic !== 'string')
30
+ throw new TypeError(`invalid mnemonic type: ${typeof mnemonic}`);
31
+ const normalized = mnemonic.normalize('NFKD');
32
+ if (![12, 15, 18, 21, 24].includes(normalized.split(' ').length))
33
+ throw new Error('Invalid mnemonic');
34
+ return copyAndClear(crypto.pbkdf2Sync(normalized, `mnemonic${passphrase}`.normalize('NFKD'), 2048, 64, 'sha512'));
35
+ },
36
+ });
37
+ }
38
+ function copyAndClear(value) {
39
+ try {
40
+ return Uint8Array.from(value);
41
+ }
42
+ finally {
43
+ value.fill(0);
44
+ }
45
+ }
46
+ //# sourceMappingURL=Mnemonic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Mnemonic.js","sourceRoot":"","sources":["../../src/node/Mnemonic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAIrC,cAAc,qBAAqB,CAAA;AAEnC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,MAAM;IACpB,OAAO,OAAO,CAAC,OAAO,CAAC;QACrB,MAAM,EAAE,CAAC,QAAQ,EAAE,UAAU,GAAG,EAAE,EAAE,EAAE;YACpC,IAAI,OAAO,QAAQ,KAAK,QAAQ;gBAC9B,MAAM,IAAI,SAAS,CAAC,0BAA0B,OAAO,QAAQ,EAAE,CAAC,CAAA;YAElE,MAAM,UAAU,GAAG,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;YAC7C,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;gBAC9D,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;YAErC,OAAO,YAAY,CACjB,MAAM,CAAC,UAAU,CACf,UAAU,EACV,WAAW,UAAU,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,EACzC,IAAI,EACJ,EAAE,EACF,QAAQ,CACT,CACF,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAWD,SAAS,YAAY,CAAC,KAAa;IACjC,IAAI,CAAC;QACH,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC/B,CAAC;YAAS,CAAC;QACT,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACf,CAAC;AACH,CAAC"}
@@ -0,0 +1,32 @@
1
+ import type * as Engine from '../core/Engine.js';
2
+ import type * as Errors from '../core/Errors.js';
3
+ export * from '../core/P256.js';
4
+ /**
5
+ * Creates a Node.js implementation of the [`P256`](/api/P256) engine slot,
6
+ * without installing it.
7
+ *
8
+ * Node's other P256 operations do not reproduce Ox's recovered-signature and
9
+ * compressed-shared-point contracts, so they remain on Ox's defaults.
10
+ *
11
+ * @example
12
+ * ```ts twoslash
13
+ * // @noErrors
14
+ * import { Engine } from 'ox'
15
+ * import { P256 } from 'ox/node'
16
+ *
17
+ * await Engine.install({ P256: P256.engine() })
18
+ *
19
+ * P256.getPublicKey({ privateKey: '0x...' })
20
+ * ```
21
+ *
22
+ * @returns The raw `P256` engine slot.
23
+ */
24
+ export declare function engine(): Promise<engine.ReturnType>;
25
+ export declare namespace engine {
26
+ /** Every `P256` primitive this module implements. */
27
+ type ReturnType = {
28
+ getPublicKey: NonNullable<Engine.Ecdsa['getPublicKey']>;
29
+ };
30
+ type ErrorType = Errors.GlobalErrorType;
31
+ }
32
+ //# sourceMappingURL=P256.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"P256.d.ts","sourceRoot":"","sources":["../../src/node/P256.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAEhD,cAAc,iBAAiB,CAAA;AAE/B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAYnD;AAED,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC;IAC9B,qDAAqD;IACrD,KAAK,UAAU,GAAG;QAChB,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAA;KACxD,CAAA;IAED,KAAK,SAAS,GAAG,MAAM,CAAC,eAAe,CAAA;CACxC"}
@@ -0,0 +1,34 @@
1
+ import * as crypto from 'node:crypto';
2
+ export * from '../core/P256.js';
3
+ /**
4
+ * Creates a Node.js implementation of the [`P256`](/api/P256) engine slot,
5
+ * without installing it.
6
+ *
7
+ * Node's other P256 operations do not reproduce Ox's recovered-signature and
8
+ * compressed-shared-point contracts, so they remain on Ox's defaults.
9
+ *
10
+ * @example
11
+ * ```ts twoslash
12
+ * // @noErrors
13
+ * import { Engine } from 'ox'
14
+ * import { P256 } from 'ox/node'
15
+ *
16
+ * await Engine.install({ P256: P256.engine() })
17
+ *
18
+ * P256.getPublicKey({ privateKey: '0x...' })
19
+ * ```
20
+ *
21
+ * @returns The raw `P256` engine slot.
22
+ */
23
+ export function engine() {
24
+ return Promise.resolve({
25
+ getPublicKey: (privateKey) => {
26
+ if (privateKey.length !== 32)
27
+ throw new RangeError(`P256 private key must be 32 bytes, got ${privateKey.length}`);
28
+ const ecdh = crypto.createECDH('prime256v1');
29
+ ecdh.setPrivateKey(privateKey);
30
+ return new Uint8Array(ecdh.getPublicKey(undefined, 'uncompressed'));
31
+ },
32
+ });
33
+ }
34
+ //# sourceMappingURL=P256.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"P256.js","sourceRoot":"","sources":["../../src/node/P256.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAIrC,cAAc,iBAAiB,CAAA;AAE/B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,MAAM;IACpB,OAAO,OAAO,CAAC,OAAO,CAAC;QACrB,YAAY,EAAE,CAAC,UAAU,EAAE,EAAE;YAC3B,IAAI,UAAU,CAAC,MAAM,KAAK,EAAE;gBAC1B,MAAM,IAAI,UAAU,CAClB,0CAA0C,UAAU,CAAC,MAAM,EAAE,CAC9D,CAAA;YACH,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAA;YAC5C,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAA;YAC9B,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,CAAA;QACrE,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type * as Engine from '../core/Engine.js';
2
+ import type * as Errors from '../core/Errors.js';
3
+ export * from '../core/X25519.js';
4
+ /**
5
+ * Creates a Node.js implementation of the [`X25519`](/api/X25519) engine slot,
6
+ * without installing it.
7
+ *
8
+ * Random key generation remains on Ox's default implementation.
9
+ *
10
+ * @example
11
+ * ```ts twoslash
12
+ * // @noErrors
13
+ * import { Engine } from 'ox'
14
+ * import { X25519 } from 'ox/node'
15
+ *
16
+ * await Engine.install({ X25519: X25519.engine() })
17
+ *
18
+ * X25519.getPublicKey({ privateKey: '0x...' })
19
+ * ```
20
+ *
21
+ * @returns The raw `X25519` engine slot.
22
+ */
23
+ export declare function engine(): Promise<engine.ReturnType>;
24
+ export declare namespace engine {
25
+ /** Every `X25519` primitive this module implements. */
26
+ type ReturnType = {
27
+ [key in 'getPublicKey' | 'getSharedSecret']-?: NonNullable<Engine.Ecdh[key]>;
28
+ };
29
+ type ErrorType = Errors.GlobalErrorType;
30
+ }
31
+ //# sourceMappingURL=X25519.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"X25519.d.ts","sourceRoot":"","sources":["../../src/node/X25519.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAEhD,cAAc,mBAAmB,CAAA;AAKjC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAYnD;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,MAAM,CAAC,eAAe,CAAA;CACxC"}
@@ -0,0 +1,71 @@
1
+ import * as crypto from 'node:crypto';
2
+ export * from '../core/X25519.js';
3
+ const privateKeyPrefix = Buffer.from('302e020100300506032b656e04220420', 'hex');
4
+ const publicKeyPrefix = Buffer.from('302a300506032b656e032100', 'hex');
5
+ /**
6
+ * Creates a Node.js implementation of the [`X25519`](/api/X25519) engine slot,
7
+ * without installing it.
8
+ *
9
+ * Random key generation remains on Ox's default implementation.
10
+ *
11
+ * @example
12
+ * ```ts twoslash
13
+ * // @noErrors
14
+ * import { Engine } from 'ox'
15
+ * import { X25519 } from 'ox/node'
16
+ *
17
+ * await Engine.install({ X25519: X25519.engine() })
18
+ *
19
+ * X25519.getPublicKey({ privateKey: '0x...' })
20
+ * ```
21
+ *
22
+ * @returns The raw `X25519` engine slot.
23
+ */
24
+ export function engine() {
25
+ return Promise.resolve({
26
+ getPublicKey: (privateKey) => rawPublicKey(crypto.createPublicKey(toPrivateKey(privateKey))),
27
+ getSharedSecret: (privateKey, publicKey) => copyAndClear(crypto.diffieHellman({
28
+ privateKey: toPrivateKey(privateKey),
29
+ publicKey: toPublicKey(publicKey),
30
+ })),
31
+ });
32
+ }
33
+ function copyAndClear(value) {
34
+ try {
35
+ return Uint8Array.from(value);
36
+ }
37
+ finally {
38
+ value.fill(0);
39
+ }
40
+ }
41
+ function assertLength(key, type) {
42
+ if (key.length !== 32)
43
+ throw new RangeError(`X25519 ${type} key must be 32 bytes, got ${key.length}`);
44
+ }
45
+ function rawPublicKey(publicKey) {
46
+ const der = publicKey.export({ format: 'der', type: 'spki' });
47
+ return Uint8Array.from(der.subarray(-32));
48
+ }
49
+ function toPrivateKey(privateKey) {
50
+ assertLength(privateKey, 'private');
51
+ const der = Buffer.concat([privateKeyPrefix, privateKey]);
52
+ try {
53
+ return crypto.createPrivateKey({
54
+ format: 'der',
55
+ key: der,
56
+ type: 'pkcs8',
57
+ });
58
+ }
59
+ finally {
60
+ der.fill(0);
61
+ }
62
+ }
63
+ function toPublicKey(publicKey) {
64
+ assertLength(publicKey, 'public');
65
+ return crypto.createPublicKey({
66
+ format: 'der',
67
+ key: Buffer.concat([publicKeyPrefix, publicKey]),
68
+ type: 'spki',
69
+ });
70
+ }
71
+ //# sourceMappingURL=X25519.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"X25519.js","sourceRoot":"","sources":["../../src/node/X25519.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAIrC,cAAc,mBAAmB,CAAA;AAEjC,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAA;AAC/E,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAA;AAEtE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,MAAM;IACpB,OAAO,OAAO,CAAC,OAAO,CAAC;QACrB,YAAY,EAAE,CAAC,UAAU,EAAE,EAAE,CAC3B,YAAY,CAAC,MAAM,CAAC,eAAe,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;QAChE,eAAe,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,EAAE,CACzC,YAAY,CACV,MAAM,CAAC,aAAa,CAAC;YACnB,UAAU,EAAE,YAAY,CAAC,UAAU,CAAC;YACpC,SAAS,EAAE,WAAW,CAAC,SAAS,CAAC;SAClC,CAAC,CACH;KACJ,CAAC,CAAA;AACJ,CAAC;AAWD,SAAS,YAAY,CAAC,KAAa;IACjC,IAAI,CAAC;QACH,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC/B,CAAC;YAAS,CAAC;QACT,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACf,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,GAAe,EAAE,IAA0B;IAC/D,IAAI,GAAG,CAAC,MAAM,KAAK,EAAE;QACnB,MAAM,IAAI,UAAU,CAClB,UAAU,IAAI,8BAA8B,GAAG,CAAC,MAAM,EAAE,CACzD,CAAA;AACL,CAAC;AAED,SAAS,YAAY,CAAC,SAA2B;IAC/C,MAAM,GAAG,GAAG,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAA;IAC7D,OAAO,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAC3C,CAAC;AAED,SAAS,YAAY,CAAC,UAAsB;IAC1C,YAAY,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;IACnC,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC,CAAA;IACzD,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,gBAAgB,CAAC;YAC7B,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,GAAG;YACR,IAAI,EAAE,OAAO;SACd,CAAC,CAAA;IACJ,CAAC;YAAS,CAAC;QACT,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACb,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,SAAqB;IACxC,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;IACjC,OAAO,MAAM,CAAC,eAAe,CAAC;QAC5B,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;QAChD,IAAI,EAAE,MAAM;KACb,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,126 @@
1
+ /** @entrypointCategory Node */
2
+ /**
3
+ * Node.js implementations of Ox's supported cryptographic primitives, backed
4
+ * by `node:crypto`.
5
+ *
6
+ * Import this entrypoint only in Node.js. Its static `node:crypto` dependency
7
+ * is intentionally kept outside Ox's runtime-neutral entrypoint.
8
+ *
9
+ * @example
10
+ * ```ts twoslash
11
+ * // @noErrors
12
+ * import { Engine, Hash } from 'ox/node'
13
+ *
14
+ * await Engine.install()
15
+ *
16
+ * Hash.sha256('0xdeadbeef')
17
+ * ```
18
+ *
19
+ * @category Crypto
20
+ */
21
+ export * as Engine from './Engine.js';
22
+ /**
23
+ * Ox's Ed25519 API and its supported Node.js engine primitives.
24
+ *
25
+ * @example
26
+ * ```ts twoslash
27
+ * // @noErrors
28
+ * import { Engine } from 'ox'
29
+ * import { Ed25519 } from 'ox/node'
30
+ *
31
+ * await Engine.install({ Ed25519: Ed25519.engine() })
32
+ *
33
+ * Ed25519.getPublicKey({ privateKey: '0x...' })
34
+ * ```
35
+ *
36
+ * @category Crypto
37
+ */
38
+ export * as Ed25519 from './Ed25519.js';
39
+ /**
40
+ * Ox's hash API and its supported Node.js engine primitives.
41
+ *
42
+ * @example
43
+ * ```ts twoslash
44
+ * // @noErrors
45
+ * import { Engine } from 'ox'
46
+ * import { Hash } from 'ox/node'
47
+ *
48
+ * await Engine.install({ Hash: Hash.engine() })
49
+ *
50
+ * Hash.sha256('0xdeadbeef')
51
+ * ```
52
+ *
53
+ * @category Crypto
54
+ */
55
+ export * as Hash from './Hash.js';
56
+ /**
57
+ * Ox's keystore API and its supported Node.js engine primitives.
58
+ *
59
+ * @example
60
+ * ```ts twoslash
61
+ * // @noErrors
62
+ * import { Engine } from 'ox'
63
+ * import { Keystore } from 'ox/node'
64
+ *
65
+ * await Engine.install({ Keystore: Keystore.engine() })
66
+ *
67
+ * Keystore.pbkdf2({ password: 'testpassword' })
68
+ * ```
69
+ *
70
+ * @category Crypto
71
+ */
72
+ export * as Keystore from './Keystore.js';
73
+ /**
74
+ * Ox's mnemonic API and its Node.js BIP-39 seed engine primitive.
75
+ *
76
+ * @example
77
+ * ```ts twoslash
78
+ * // @noErrors
79
+ * import { Engine } from 'ox'
80
+ * import { Mnemonic } from 'ox/node'
81
+ *
82
+ * await Engine.install({ Mnemonic: Mnemonic.engine() })
83
+ *
84
+ * Mnemonic.toSeed(
85
+ * 'test test test test test test test test test test test junk'
86
+ * )
87
+ * ```
88
+ *
89
+ * @category Crypto
90
+ */
91
+ export * as Mnemonic from './Mnemonic.js';
92
+ /**
93
+ * Ox's P256 API and its Node.js public-key derivation engine primitive.
94
+ *
95
+ * @example
96
+ * ```ts twoslash
97
+ * // @noErrors
98
+ * import { Engine } from 'ox'
99
+ * import { P256 } from 'ox/node'
100
+ *
101
+ * await Engine.install({ P256: P256.engine() })
102
+ *
103
+ * P256.getPublicKey({ privateKey: '0x...' })
104
+ * ```
105
+ *
106
+ * @category Crypto
107
+ */
108
+ export * as P256 from './P256.js';
109
+ /**
110
+ * Ox's X25519 API and its supported Node.js engine primitives.
111
+ *
112
+ * @example
113
+ * ```ts twoslash
114
+ * // @noErrors
115
+ * import { Engine } from 'ox'
116
+ * import { X25519 } from 'ox/node'
117
+ *
118
+ * await Engine.install({ X25519: X25519.engine() })
119
+ *
120
+ * X25519.getPublicKey({ privateKey: '0x...' })
121
+ * ```
122
+ *
123
+ * @category Crypto
124
+ */
125
+ export * as X25519 from './X25519.js';
126
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAE/B;;;;;;;;;;;;;;;;;;GAkBG;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,IAAI,MAAM,WAAW,CAAA;AAEjC;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA"}