@nktkas/hyperliquid 0.19.2 → 0.20.0

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 (123) hide show
  1. package/README.md +21 -29
  2. package/esm/_dnt.polyfills.d.ts +20 -0
  3. package/esm/_dnt.polyfills.d.ts.map +1 -0
  4. package/esm/_dnt.polyfills.js +12 -0
  5. package/esm/mod.d.ts +3 -0
  6. package/esm/mod.d.ts.map +1 -1
  7. package/esm/mod.js +2 -0
  8. package/esm/src/base.d.ts +1 -47
  9. package/esm/src/base.d.ts.map +1 -1
  10. package/esm/src/base.js +1 -8
  11. package/esm/src/clients/event.d.ts +2 -3
  12. package/esm/src/clients/event.d.ts.map +1 -1
  13. package/esm/src/clients/event.js +49 -57
  14. package/esm/src/clients/public.d.ts +24 -5
  15. package/esm/src/clients/public.d.ts.map +1 -1
  16. package/esm/src/clients/public.js +23 -7
  17. package/esm/src/clients/wallet.d.ts +12 -13
  18. package/esm/src/clients/wallet.d.ts.map +1 -1
  19. package/esm/src/clients/wallet.js +55 -265
  20. package/esm/src/signing.d.ts +5 -0
  21. package/esm/src/signing.d.ts.map +1 -1
  22. package/esm/src/signing.js +24 -5
  23. package/esm/src/transports/base.d.ts +49 -0
  24. package/esm/src/transports/base.d.ts.map +1 -0
  25. package/esm/src/transports/base.js +8 -0
  26. package/esm/src/transports/http/http_transport.d.ts +8 -5
  27. package/esm/src/transports/http/http_transport.d.ts.map +1 -1
  28. package/esm/src/transports/http/http_transport.js +15 -62
  29. package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts +36 -39
  30. package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -1
  31. package/esm/src/transports/websocket/_reconnecting_websocket.d.ts +18 -25
  32. package/esm/src/transports/websocket/_reconnecting_websocket.d.ts.map +1 -1
  33. package/esm/src/transports/websocket/_reconnecting_websocket.js +80 -179
  34. package/{script/src/transports/websocket/_websocket_request_dispatcher.d.ts → esm/src/transports/websocket/_websocket_async_request.d.ts} +14 -18
  35. package/esm/src/transports/websocket/_websocket_async_request.d.ts.map +1 -0
  36. package/esm/src/transports/websocket/{_websocket_request_dispatcher.js → _websocket_async_request.js} +41 -74
  37. package/esm/src/transports/websocket/websocket_transport.d.ts +38 -28
  38. package/esm/src/transports/websocket/websocket_transport.d.ts.map +1 -1
  39. package/esm/src/transports/websocket/websocket_transport.js +61 -76
  40. package/esm/src/types/info/assets.d.ts +0 -48
  41. package/esm/src/types/info/assets.d.ts.map +1 -1
  42. package/esm/src/types/info/markets.d.ts +52 -0
  43. package/esm/src/types/info/markets.d.ts.map +1 -0
  44. package/esm/src/types/info/markets.js +1 -0
  45. package/esm/src/types/info/requests.d.ts +9 -0
  46. package/esm/src/types/info/requests.d.ts.map +1 -1
  47. package/esm/src/types/mod.d.ts +4 -0
  48. package/esm/src/types/mod.d.ts.map +1 -1
  49. package/esm/src/types/mod.js +3 -1
  50. package/package.json +12 -9
  51. package/script/_dnt.polyfills.d.ts +20 -0
  52. package/script/_dnt.polyfills.d.ts.map +1 -0
  53. package/script/_dnt.polyfills.js +23 -0
  54. package/script/mod.d.ts +3 -0
  55. package/script/mod.d.ts.map +1 -1
  56. package/script/mod.js +3 -1
  57. package/script/src/base.d.ts +1 -47
  58. package/script/src/base.d.ts.map +1 -1
  59. package/script/src/base.js +2 -10
  60. package/script/src/clients/event.d.ts +2 -3
  61. package/script/src/clients/event.d.ts.map +1 -1
  62. package/script/src/clients/event.js +49 -57
  63. package/script/src/clients/public.d.ts +24 -5
  64. package/script/src/clients/public.d.ts.map +1 -1
  65. package/script/src/clients/public.js +23 -7
  66. package/script/src/clients/wallet.d.ts +12 -13
  67. package/script/src/clients/wallet.d.ts.map +1 -1
  68. package/script/src/clients/wallet.js +55 -265
  69. package/script/src/signing.d.ts +5 -0
  70. package/script/src/signing.d.ts.map +1 -1
  71. package/script/src/signing.js +75 -56
  72. package/script/src/transports/base.d.ts +49 -0
  73. package/script/src/transports/base.d.ts.map +1 -0
  74. package/script/src/transports/base.js +22 -0
  75. package/script/src/transports/http/http_transport.d.ts +8 -5
  76. package/script/src/transports/http/http_transport.d.ts.map +1 -1
  77. package/script/src/transports/http/http_transport.js +16 -63
  78. package/script/src/transports/websocket/_hyperliquid_event_target.d.ts +36 -39
  79. package/script/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -1
  80. package/script/src/transports/websocket/_reconnecting_websocket.d.ts +18 -25
  81. package/script/src/transports/websocket/_reconnecting_websocket.d.ts.map +1 -1
  82. package/script/src/transports/websocket/_reconnecting_websocket.js +81 -180
  83. package/{esm/src/transports/websocket/_websocket_request_dispatcher.d.ts → script/src/transports/websocket/_websocket_async_request.d.ts} +14 -18
  84. package/script/src/transports/websocket/_websocket_async_request.d.ts.map +1 -0
  85. package/script/src/transports/websocket/{_websocket_request_dispatcher.js → _websocket_async_request.js} +44 -77
  86. package/script/src/transports/websocket/websocket_transport.d.ts +38 -28
  87. package/script/src/transports/websocket/websocket_transport.d.ts.map +1 -1
  88. package/script/src/transports/websocket/websocket_transport.js +63 -78
  89. package/script/src/types/info/assets.d.ts +0 -48
  90. package/script/src/types/info/assets.d.ts.map +1 -1
  91. package/script/src/types/info/markets.d.ts +52 -0
  92. package/script/src/types/info/markets.d.ts.map +1 -0
  93. package/script/{deps/jsr.io/@noble/hashes/1.8.0/src/crypto.js → src/types/info/markets.js} +0 -2
  94. package/script/src/types/info/requests.d.ts +9 -0
  95. package/script/src/types/info/requests.d.ts.map +1 -1
  96. package/script/src/types/mod.d.ts +4 -0
  97. package/script/src/types/mod.d.ts.map +1 -1
  98. package/script/src/types/mod.js +25 -22
  99. package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/_u64.d.ts +0 -55
  100. package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/_u64.d.ts.map +0 -1
  101. package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/_u64.js +0 -66
  102. package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/crypto.d.ts +0 -2
  103. package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/crypto.d.ts.map +0 -1
  104. package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/crypto.js +0 -1
  105. package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/sha3.d.ts +0 -53
  106. package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/sha3.d.ts.map +0 -1
  107. package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/sha3.js +0 -294
  108. package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/utils.d.ts +0 -161
  109. package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/utils.d.ts.map +0 -1
  110. package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/utils.js +0 -280
  111. package/esm/src/transports/websocket/_websocket_request_dispatcher.d.ts.map +0 -1
  112. package/script/deps/jsr.io/@noble/hashes/1.8.0/src/_u64.d.ts +0 -55
  113. package/script/deps/jsr.io/@noble/hashes/1.8.0/src/_u64.d.ts.map +0 -1
  114. package/script/deps/jsr.io/@noble/hashes/1.8.0/src/_u64.js +0 -99
  115. package/script/deps/jsr.io/@noble/hashes/1.8.0/src/crypto.d.ts +0 -2
  116. package/script/deps/jsr.io/@noble/hashes/1.8.0/src/crypto.d.ts.map +0 -1
  117. package/script/deps/jsr.io/@noble/hashes/1.8.0/src/sha3.d.ts +0 -53
  118. package/script/deps/jsr.io/@noble/hashes/1.8.0/src/sha3.d.ts.map +0 -1
  119. package/script/deps/jsr.io/@noble/hashes/1.8.0/src/sha3.js +0 -309
  120. package/script/deps/jsr.io/@noble/hashes/1.8.0/src/utils.d.ts +0 -161
  121. package/script/deps/jsr.io/@noble/hashes/1.8.0/src/utils.d.ts.map +0 -1
  122. package/script/deps/jsr.io/@noble/hashes/1.8.0/src/utils.js +0 -322
  123. package/script/src/transports/websocket/_websocket_request_dispatcher.d.ts.map +0 -1
@@ -1,33 +1,36 @@
1
- /**
2
- * This module contains all types related to the Hyperliquid API.
3
- * @example
4
- * ```ts
5
- * import type { OrderParams } from "@nktkas/hyperliquid/types";
6
- *
7
- * const myOrder: OrderParams = {
8
- * a: 0, // Asset index
9
- * b: true, // Buy order
10
- * p: "30000", // Price
11
- * s: "0.1", // Size
12
- * r: false, // Not reduce-only
13
- * t: {
14
- * limit: {
15
- * tif: "Gtc", // Good-til-cancelled
16
- * },
17
- * },
18
- * };
19
- * ```
20
- * @module
21
- */
22
1
  (function (factory) {
23
2
  if (typeof module === "object" && typeof module.exports === "object") {
24
3
  var v = factory(require, exports);
25
4
  if (v !== undefined) module.exports = v;
26
5
  }
27
6
  else if (typeof define === "function" && define.amd) {
28
- define(["require", "exports"], factory);
7
+ define(["require", "exports", "../../_dnt.polyfills.js"], factory);
29
8
  }
30
9
  })(function (require, exports) {
31
10
  "use strict";
32
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ /**
13
+ * This module contains all types related to the Hyperliquid API.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import type { OrderParams } from "@nktkas/hyperliquid/types";
18
+ *
19
+ * const myOrder: OrderParams = {
20
+ * a: 0, // Asset index
21
+ * b: true, // Buy order
22
+ * p: "30000", // Price
23
+ * s: "0.1", // Size
24
+ * r: false, // Not reduce-only
25
+ * t: {
26
+ * limit: {
27
+ * tif: "Gtc", // Good-til-cancelled
28
+ * },
29
+ * },
30
+ * };
31
+ * ```
32
+ *
33
+ * @module
34
+ */
35
+ require("../../_dnt.polyfills.js");
33
36
  });
@@ -1,55 +0,0 @@
1
- declare function fromBig(n: bigint, le?: boolean): {
2
- h: number;
3
- l: number;
4
- };
5
- declare function split(lst: bigint[], le?: boolean): Uint32Array[];
6
- declare const toBig: (h: number, l: number) => bigint;
7
- declare const shrSH: (h: number, _l: number, s: number) => number;
8
- declare const shrSL: (h: number, l: number, s: number) => number;
9
- declare const rotrSH: (h: number, l: number, s: number) => number;
10
- declare const rotrSL: (h: number, l: number, s: number) => number;
11
- declare const rotrBH: (h: number, l: number, s: number) => number;
12
- declare const rotrBL: (h: number, l: number, s: number) => number;
13
- declare const rotr32H: (_h: number, l: number) => number;
14
- declare const rotr32L: (h: number, _l: number) => number;
15
- declare const rotlSH: (h: number, l: number, s: number) => number;
16
- declare const rotlSL: (h: number, l: number, s: number) => number;
17
- declare const rotlBH: (h: number, l: number, s: number) => number;
18
- declare const rotlBL: (h: number, l: number, s: number) => number;
19
- declare function add(Ah: number, Al: number, Bh: number, Bl: number): {
20
- h: number;
21
- l: number;
22
- };
23
- declare const add3L: (Al: number, Bl: number, Cl: number) => number;
24
- declare const add3H: (low: number, Ah: number, Bh: number, Ch: number) => number;
25
- declare const add4L: (Al: number, Bl: number, Cl: number, Dl: number) => number;
26
- declare const add4H: (low: number, Ah: number, Bh: number, Ch: number, Dh: number) => number;
27
- declare const add5L: (Al: number, Bl: number, Cl: number, Dl: number, El: number) => number;
28
- declare const add5H: (low: number, Ah: number, Bh: number, Ch: number, Dh: number, Eh: number) => number;
29
- export { add, add3H, add3L, add4H, add4L, add5H, add5L, fromBig, rotlBH, rotlBL, rotlSH, rotlSL, rotr32H, rotr32L, rotrBH, rotrBL, rotrSH, rotrSL, shrSH, shrSL, split, toBig };
30
- declare const u64: {
31
- fromBig: typeof fromBig;
32
- split: typeof split;
33
- toBig: (h: number, l: number) => bigint;
34
- shrSH: (h: number, _l: number, s: number) => number;
35
- shrSL: (h: number, l: number, s: number) => number;
36
- rotrSH: (h: number, l: number, s: number) => number;
37
- rotrSL: (h: number, l: number, s: number) => number;
38
- rotrBH: (h: number, l: number, s: number) => number;
39
- rotrBL: (h: number, l: number, s: number) => number;
40
- rotr32H: (_h: number, l: number) => number;
41
- rotr32L: (h: number, _l: number) => number;
42
- rotlSH: (h: number, l: number, s: number) => number;
43
- rotlSL: (h: number, l: number, s: number) => number;
44
- rotlBH: (h: number, l: number, s: number) => number;
45
- rotlBL: (h: number, l: number, s: number) => number;
46
- add: typeof add;
47
- add3L: (Al: number, Bl: number, Cl: number) => number;
48
- add3H: (low: number, Ah: number, Bh: number, Ch: number) => number;
49
- add4L: (Al: number, Bl: number, Cl: number, Dl: number) => number;
50
- add4H: (low: number, Ah: number, Bh: number, Ch: number, Dh: number) => number;
51
- add5H: (low: number, Ah: number, Bh: number, Ch: number, Dh: number, Eh: number) => number;
52
- add5L: (Al: number, Bl: number, Cl: number, Dl: number, El: number) => number;
53
- };
54
- export default u64;
55
- //# sourceMappingURL=_u64.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_u64.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@noble/hashes/1.8.0/src/_u64.ts"],"names":[],"mappings":"AAQA,iBAAS,OAAO,CACd,CAAC,EAAE,MAAM,EACT,EAAE,UAAQ,GACT;IACD,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAGA;AAED,iBAAS,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,UAAQ,GAAG,WAAW,EAAE,CASvD;AAED,QAAA,MAAM,KAAK,MAAO,MAAM,KAAK,MAAM,KAAG,MAAqD,CAAC;AAE5F,QAAA,MAAM,KAAK,MAAO,MAAM,MAAM,MAAM,KAAK,MAAM,KAAG,MAAiB,CAAC;AACpE,QAAA,MAAM,KAAK,MAAO,MAAM,KAAK,MAAM,KAAK,MAAM,KAAG,MAAqC,CAAC;AAEvF,QAAA,MAAM,MAAM,MAAO,MAAM,KAAK,MAAM,KAAK,MAAM,KAAG,MAAqC,CAAC;AACxF,QAAA,MAAM,MAAM,MAAO,MAAM,KAAK,MAAM,KAAK,MAAM,KAAG,MAAqC,CAAC;AAExF,QAAA,MAAM,MAAM,MAAO,MAAM,KAAK,MAAM,KAAK,MAAM,KAAG,MAA4C,CAAC;AAC/F,QAAA,MAAM,MAAM,MAAO,MAAM,KAAK,MAAM,KAAK,MAAM,KAAG,MAA4C,CAAC;AAE/F,QAAA,MAAM,OAAO,OAAQ,MAAM,KAAK,MAAM,KAAG,MAAW,CAAC;AACrD,QAAA,MAAM,OAAO,MAA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AE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;CAOrpC,CAAC;AACF,eAAe,GAAG,CAAC"}
@@ -1,66 +0,0 @@
1
- /**
2
- * Internal helpers for u64. BigUint64Array is too slow as per 2025, so we implement it using Uint32Array.
3
- * @todo re-check https://issues.chromium.org/issues/42212588
4
- * @module
5
- */
6
- const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
7
- const _32n = /* @__PURE__ */ BigInt(32);
8
- function fromBig(n, le = false) {
9
- if (le)
10
- return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
11
- return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
12
- }
13
- function split(lst, le = false) {
14
- const len = lst.length;
15
- let Ah = new Uint32Array(len);
16
- let Al = new Uint32Array(len);
17
- for (let i = 0; i < len; i++) {
18
- const { h, l } = fromBig(lst[i], le);
19
- [Ah[i], Al[i]] = [h, l];
20
- }
21
- return [Ah, Al];
22
- }
23
- const toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);
24
- // for Shift in [0, 32)
25
- const shrSH = (h, _l, s) => h >>> s;
26
- const shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
27
- // Right rotate for Shift in [1, 32)
28
- const rotrSH = (h, l, s) => (h >>> s) | (l << (32 - s));
29
- const rotrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
30
- // Right rotate for Shift in (32, 64), NOTE: 32 is special case.
31
- const rotrBH = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32));
32
- const rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));
33
- // Right rotate for shift===32 (just swaps l&h)
34
- const rotr32H = (_h, l) => l;
35
- const rotr32L = (h, _l) => h;
36
- // Left rotate for Shift in [1, 32)
37
- const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));
38
- const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));
39
- // Left rotate for Shift in (32, 64), NOTE: 32 is special case.
40
- const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
41
- const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
42
- // JS uses 32-bit signed integers for bitwise operations which means we cannot
43
- // simple take carry out of low bit sum by shift, we need to use division.
44
- function add(Ah, Al, Bh, Bl) {
45
- const l = (Al >>> 0) + (Bl >>> 0);
46
- return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 };
47
- }
48
- // Addition with more than 2 elements
49
- const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
50
- const add3H = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;
51
- const add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
52
- const add4H = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0;
53
- const add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
54
- const add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;
55
- // prettier-ignore
56
- export { add, add3H, add3L, add4H, add4L, add5H, add5L, fromBig, rotlBH, rotlBL, rotlSH, rotlSL, rotr32H, rotr32L, rotrBH, rotrBL, rotrSH, rotrSL, shrSH, shrSL, split, toBig };
57
- // prettier-ignore
58
- const u64 = {
59
- fromBig, split, toBig,
60
- shrSH, shrSL,
61
- rotrSH, rotrSL, rotrBH, rotrBL,
62
- rotr32H, rotr32L,
63
- rotlSH, rotlSL, rotlBH, rotlBL,
64
- add, add3L, add3H, add4L, add4H, add5H, add5L,
65
- };
66
- export default u64;
@@ -1,2 +0,0 @@
1
- export declare const crypto: any;
2
- //# sourceMappingURL=crypto.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@noble/hashes/1.8.0/src/crypto.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,MAAM,EAAE,GACqE,CAAC"}
@@ -1 +0,0 @@
1
- export const crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;
@@ -1,53 +0,0 @@
1
- import { Hash, type CHash, type CHashXO, type HashXOF, type Input } from './utils.js';
2
- /** `keccakf1600` internal function, additionally allows to adjust round count. */
3
- export declare function keccakP(s: Uint32Array, rounds?: number): void;
4
- /** Keccak sponge function. */
5
- export declare class Keccak extends Hash<Keccak> implements HashXOF<Keccak> {
6
- protected state: Uint8Array;
7
- protected pos: number;
8
- protected posOut: number;
9
- protected finished: boolean;
10
- protected state32: Uint32Array;
11
- protected destroyed: boolean;
12
- blockLen: number;
13
- suffix: number;
14
- outputLen: number;
15
- protected enableXOF: boolean;
16
- protected rounds: number;
17
- constructor(blockLen: number, suffix: number, outputLen: number, enableXOF?: boolean, rounds?: number);
18
- clone(): Keccak;
19
- protected keccak(): void;
20
- update(data: Input): this;
21
- protected finish(): void;
22
- protected writeInto(out: Uint8Array): Uint8Array;
23
- xofInto(out: Uint8Array): Uint8Array;
24
- xof(bytes: number): Uint8Array;
25
- digestInto(out: Uint8Array): Uint8Array;
26
- digest(): Uint8Array;
27
- destroy(): void;
28
- _cloneInto(to?: Keccak): Keccak;
29
- }
30
- /** SHA3-224 hash function. */
31
- export declare const sha3_224: CHash;
32
- /** SHA3-256 hash function. Different from keccak-256. */
33
- export declare const sha3_256: CHash;
34
- /** SHA3-384 hash function. */
35
- export declare const sha3_384: CHash;
36
- /** SHA3-512 hash function. */
37
- export declare const sha3_512: CHash;
38
- /** keccak-224 hash function. */
39
- export declare const keccak_224: CHash;
40
- /** keccak-256 hash function. Different from SHA3-256. */
41
- export declare const keccak_256: CHash;
42
- /** keccak-384 hash function. */
43
- export declare const keccak_384: CHash;
44
- /** keccak-512 hash function. */
45
- export declare const keccak_512: CHash;
46
- export type ShakeOpts = {
47
- dkLen?: number;
48
- };
49
- /** SHAKE128 XOF with 128-bit security. */
50
- export declare const shake128: CHashXO;
51
- /** SHAKE256 XOF with 256-bit security. */
52
- export declare const shake256: CHashXO;
53
- //# sourceMappingURL=sha3.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sha3.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@noble/hashes/1.8.0/src/sha3.ts"],"names":[],"mappings":"AAaA,OAAO,EAE6B,IAAI,EAGtC,KAAK,KAAK,EAAE,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EACnD,MAAM,YAAY,CAAC;AAoCpB,kFAAkF;AAClF,wBAAgB,OAAO,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,GAAE,MAAW,GAAG,IAAI,CAyCjE;AAED,8BAA8B;AAC9B,qBAAa,MAAO,SAAQ,IAAI,CAAC,MAAM,CAAE,YAAW,OAAO,CAAC,MAAM,CAAC;IACjE,SAAS,CAAC,KAAK,EAAE,UAAU,CAAC;IAC5B,SAAS,CAAC,GAAG,SAAK;IAClB,SAAS,CAAC,MAAM,SAAK;IACrB,SAAS,CAAC,QAAQ,UAAS;IAC3B,SAAS,CAAC,OAAO,EAAE,WAAW,CAAC;IAC/B,SAAS,CAAC,SAAS,UAAS;IAErB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,SAAS,UAAS;IAC5B,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;gBAIvB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,SAAS,UAAQ,EACjB,MAAM,GAAE,MAAW;IAiBrB,KAAK,IAAI,MAAM;IAGf,SAAS,CAAC,MAAM,IAAI,IAAI;IAOxB,MAAM,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI;IAazB,SAAS,CAAC,MAAM,IAAI,IAAI;IAUxB,SAAS,CAAC,SAAS,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU;IAehD,OAAO,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU;IAKpC,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU;IAI9B,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU;IAOvC,MAAM,IAAI,UAAU;IAGpB,OAAO,IAAI,IAAI;IAIf,UAAU,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;CAehC;AAKD,8BAA8B;AAC9B,eAAO,MAAM,QAAQ,EAAE,KAAyD,CAAC;AACjF,yDAAyD;AACzD,eAAO,MAAM,QAAQ,EAAE,KAAyD,CAAC;AACjF,8BAA8B;AAC9B,eAAO,MAAM,QAAQ,EAAE,KAAyD,CAAC;AACjF,8BAA8B;AAC9B,eAAO,MAAM,QAAQ,EAAE,KAAwD,CAAC;AAEhF,gCAAgC;AAChC,eAAO,MAAM,UAAU,EAAE,KAAyD,CAAC;AACnF,yDAAyD;AACzD,eAAO,MAAM,UAAU,EAAE,KAAyD,CAAC;AACnF,gCAAgC;AAChC,eAAO,MAAM,UAAU,EAAE,KAAyD,CAAC;AACnF,gCAAgC;AAChC,eAAO,MAAM,UAAU,EAAE,KAAwD,CAAC;AAElF,MAAM,MAAM,SAAS,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAQ3C,0CAA0C;AAC1C,eAAO,MAAM,QAAQ,EAAE,OAAgE,CAAC;AACxF,0CAA0C;AAC1C,eAAO,MAAM,QAAQ,EAAE,OAAgE,CAAC"}
@@ -1,294 +0,0 @@
1
- /**
2
- * SHA3 (keccak) hash function, based on a new "Sponge function" design.
3
- * Different from older hashes, the internal state is bigger than output size.
4
- *
5
- * Check out [FIPS-202](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf),
6
- * [Website](https://keccak.team/keccak.html),
7
- * [the differences between SHA-3 and Keccak](https://crypto.stackexchange.com/questions/15727/what-are-the-key-differences-between-the-draft-sha-3-standard-and-the-keccak-sub).
8
- *
9
- * Check out `sha3-addons` module for cSHAKE, k12, and others.
10
- * @module
11
- */
12
- import { rotlBH, rotlBL, rotlSH, rotlSL, split } from './_u64.js';
13
- // prettier-ignore
14
- import { abytes, aexists, anumber, aoutput, clean, createHasher, createXOFer, Hash, swap32IfBE, toBytes, u32 } from './utils.js';
15
- // No __PURE__ annotations in sha3 header:
16
- // EVERYTHING is in fact used on every export.
17
- // Various per round constants calculations
18
- const _0n = BigInt(0);
19
- const _1n = BigInt(1);
20
- const _2n = BigInt(2);
21
- const _7n = BigInt(7);
22
- const _256n = BigInt(256);
23
- const _0x71n = BigInt(0x71);
24
- const SHA3_PI = [];
25
- const SHA3_ROTL = [];
26
- const _SHA3_IOTA = [];
27
- for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {
28
- // Pi
29
- [x, y] = [y, (2 * x + 3 * y) % 5];
30
- SHA3_PI.push(2 * (5 * y + x));
31
- // Rotational
32
- SHA3_ROTL.push((((round + 1) * (round + 2)) / 2) % 64);
33
- // Iota
34
- let t = _0n;
35
- for (let j = 0; j < 7; j++) {
36
- R = ((R << _1n) ^ ((R >> _7n) * _0x71n)) % _256n;
37
- if (R & _2n)
38
- t ^= _1n << ((_1n << /* @__PURE__ */ BigInt(j)) - _1n);
39
- }
40
- _SHA3_IOTA.push(t);
41
- }
42
- const IOTAS = split(_SHA3_IOTA, true);
43
- const SHA3_IOTA_H = IOTAS[0];
44
- const SHA3_IOTA_L = IOTAS[1];
45
- // Left rotation (without 0, 32, 64)
46
- const rotlH = (h, l, s) => (s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s));
47
- const rotlL = (h, l, s) => (s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s));
48
- /** `keccakf1600` internal function, additionally allows to adjust round count. */
49
- export function keccakP(s, rounds = 24) {
50
- const B = new Uint32Array(5 * 2);
51
- // NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js)
52
- for (let round = 24 - rounds; round < 24; round++) {
53
- // Theta θ
54
- for (let x = 0; x < 10; x++)
55
- B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
56
- for (let x = 0; x < 10; x += 2) {
57
- const idx1 = (x + 8) % 10;
58
- const idx0 = (x + 2) % 10;
59
- const B0 = B[idx0];
60
- const B1 = B[idx0 + 1];
61
- const Th = rotlH(B0, B1, 1) ^ B[idx1];
62
- const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];
63
- for (let y = 0; y < 50; y += 10) {
64
- s[x + y] ^= Th;
65
- s[x + y + 1] ^= Tl;
66
- }
67
- }
68
- // Rho (ρ) and Pi (π)
69
- let curH = s[2];
70
- let curL = s[3];
71
- for (let t = 0; t < 24; t++) {
72
- const shift = SHA3_ROTL[t];
73
- const Th = rotlH(curH, curL, shift);
74
- const Tl = rotlL(curH, curL, shift);
75
- const PI = SHA3_PI[t];
76
- curH = s[PI];
77
- curL = s[PI + 1];
78
- s[PI] = Th;
79
- s[PI + 1] = Tl;
80
- }
81
- // Chi (χ)
82
- for (let y = 0; y < 50; y += 10) {
83
- for (let x = 0; x < 10; x++)
84
- B[x] = s[y + x];
85
- for (let x = 0; x < 10; x++)
86
- s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];
87
- }
88
- // Iota (ι)
89
- s[0] ^= SHA3_IOTA_H[round];
90
- s[1] ^= SHA3_IOTA_L[round];
91
- }
92
- clean(B);
93
- }
94
- /** Keccak sponge function. */
95
- export class Keccak extends Hash {
96
- // NOTE: we accept arguments in bytes instead of bits here.
97
- constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
98
- super();
99
- Object.defineProperty(this, "state", {
100
- enumerable: true,
101
- configurable: true,
102
- writable: true,
103
- value: void 0
104
- });
105
- Object.defineProperty(this, "pos", {
106
- enumerable: true,
107
- configurable: true,
108
- writable: true,
109
- value: 0
110
- });
111
- Object.defineProperty(this, "posOut", {
112
- enumerable: true,
113
- configurable: true,
114
- writable: true,
115
- value: 0
116
- });
117
- Object.defineProperty(this, "finished", {
118
- enumerable: true,
119
- configurable: true,
120
- writable: true,
121
- value: false
122
- });
123
- Object.defineProperty(this, "state32", {
124
- enumerable: true,
125
- configurable: true,
126
- writable: true,
127
- value: void 0
128
- });
129
- Object.defineProperty(this, "destroyed", {
130
- enumerable: true,
131
- configurable: true,
132
- writable: true,
133
- value: false
134
- });
135
- Object.defineProperty(this, "blockLen", {
136
- enumerable: true,
137
- configurable: true,
138
- writable: true,
139
- value: void 0
140
- });
141
- Object.defineProperty(this, "suffix", {
142
- enumerable: true,
143
- configurable: true,
144
- writable: true,
145
- value: void 0
146
- });
147
- Object.defineProperty(this, "outputLen", {
148
- enumerable: true,
149
- configurable: true,
150
- writable: true,
151
- value: void 0
152
- });
153
- Object.defineProperty(this, "enableXOF", {
154
- enumerable: true,
155
- configurable: true,
156
- writable: true,
157
- value: false
158
- });
159
- Object.defineProperty(this, "rounds", {
160
- enumerable: true,
161
- configurable: true,
162
- writable: true,
163
- value: void 0
164
- });
165
- this.blockLen = blockLen;
166
- this.suffix = suffix;
167
- this.outputLen = outputLen;
168
- this.enableXOF = enableXOF;
169
- this.rounds = rounds;
170
- // Can be passed from user as dkLen
171
- anumber(outputLen);
172
- // 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes
173
- // 0 < blockLen < 200
174
- if (!(0 < blockLen && blockLen < 200))
175
- throw new Error('only keccak-f1600 function is supported');
176
- this.state = new Uint8Array(200);
177
- this.state32 = u32(this.state);
178
- }
179
- clone() {
180
- return this._cloneInto();
181
- }
182
- keccak() {
183
- swap32IfBE(this.state32);
184
- keccakP(this.state32, this.rounds);
185
- swap32IfBE(this.state32);
186
- this.posOut = 0;
187
- this.pos = 0;
188
- }
189
- update(data) {
190
- aexists(this);
191
- data = toBytes(data);
192
- abytes(data);
193
- const { blockLen, state } = this;
194
- const len = data.length;
195
- for (let pos = 0; pos < len;) {
196
- const take = Math.min(blockLen - this.pos, len - pos);
197
- for (let i = 0; i < take; i++)
198
- state[this.pos++] ^= data[pos++];
199
- if (this.pos === blockLen)
200
- this.keccak();
201
- }
202
- return this;
203
- }
204
- finish() {
205
- if (this.finished)
206
- return;
207
- this.finished = true;
208
- const { state, suffix, pos, blockLen } = this;
209
- // Do the padding
210
- state[pos] ^= suffix;
211
- if ((suffix & 0x80) !== 0 && pos === blockLen - 1)
212
- this.keccak();
213
- state[blockLen - 1] ^= 0x80;
214
- this.keccak();
215
- }
216
- writeInto(out) {
217
- aexists(this, false);
218
- abytes(out);
219
- this.finish();
220
- const bufferOut = this.state;
221
- const { blockLen } = this;
222
- for (let pos = 0, len = out.length; pos < len;) {
223
- if (this.posOut >= blockLen)
224
- this.keccak();
225
- const take = Math.min(blockLen - this.posOut, len - pos);
226
- out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
227
- this.posOut += take;
228
- pos += take;
229
- }
230
- return out;
231
- }
232
- xofInto(out) {
233
- // Sha3/Keccak usage with XOF is probably mistake, only SHAKE instances can do XOF
234
- if (!this.enableXOF)
235
- throw new Error('XOF is not possible for this instance');
236
- return this.writeInto(out);
237
- }
238
- xof(bytes) {
239
- anumber(bytes);
240
- return this.xofInto(new Uint8Array(bytes));
241
- }
242
- digestInto(out) {
243
- aoutput(out, this);
244
- if (this.finished)
245
- throw new Error('digest() was already called');
246
- this.writeInto(out);
247
- this.destroy();
248
- return out;
249
- }
250
- digest() {
251
- return this.digestInto(new Uint8Array(this.outputLen));
252
- }
253
- destroy() {
254
- this.destroyed = true;
255
- clean(this.state);
256
- }
257
- _cloneInto(to) {
258
- const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
259
- to ||= new Keccak(blockLen, suffix, outputLen, enableXOF, rounds);
260
- to.state32.set(this.state32);
261
- to.pos = this.pos;
262
- to.posOut = this.posOut;
263
- to.finished = this.finished;
264
- to.rounds = rounds;
265
- // Suffix can change in cSHAKE
266
- to.suffix = suffix;
267
- to.outputLen = outputLen;
268
- to.enableXOF = enableXOF;
269
- to.destroyed = this.destroyed;
270
- return to;
271
- }
272
- }
273
- const gen = (suffix, blockLen, outputLen) => createHasher(() => new Keccak(blockLen, suffix, outputLen));
274
- /** SHA3-224 hash function. */
275
- export const sha3_224 = /* @__PURE__ */ (() => gen(0x06, 144, 224 / 8))();
276
- /** SHA3-256 hash function. Different from keccak-256. */
277
- export const sha3_256 = /* @__PURE__ */ (() => gen(0x06, 136, 256 / 8))();
278
- /** SHA3-384 hash function. */
279
- export const sha3_384 = /* @__PURE__ */ (() => gen(0x06, 104, 384 / 8))();
280
- /** SHA3-512 hash function. */
281
- export const sha3_512 = /* @__PURE__ */ (() => gen(0x06, 72, 512 / 8))();
282
- /** keccak-224 hash function. */
283
- export const keccak_224 = /* @__PURE__ */ (() => gen(0x01, 144, 224 / 8))();
284
- /** keccak-256 hash function. Different from SHA3-256. */
285
- export const keccak_256 = /* @__PURE__ */ (() => gen(0x01, 136, 256 / 8))();
286
- /** keccak-384 hash function. */
287
- export const keccak_384 = /* @__PURE__ */ (() => gen(0x01, 104, 384 / 8))();
288
- /** keccak-512 hash function. */
289
- export const keccak_512 = /* @__PURE__ */ (() => gen(0x01, 72, 512 / 8))();
290
- const genShake = (suffix, blockLen, outputLen) => createXOFer((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true));
291
- /** SHAKE128 XOF with 128-bit security. */
292
- export const shake128 = /* @__PURE__ */ (() => genShake(0x1f, 168, 128 / 8))();
293
- /** SHAKE256 XOF with 256-bit security. */
294
- export const shake256 = /* @__PURE__ */ (() => genShake(0x1f, 136, 256 / 8))();