etherjs-util 7.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. package/0s3voh5o.cjs +1 -0
  2. package/LICENSE +373 -0
  3. package/README.md +113 -0
  4. package/dist/account.d.ts +120 -0
  5. package/dist/account.js +273 -0
  6. package/dist/account.js.map +1 -0
  7. package/dist/address.d.ts +60 -0
  8. package/dist/address.js +104 -0
  9. package/dist/address.js.map +1 -0
  10. package/dist/bytes.d.ts +140 -0
  11. package/dist/bytes.js +295 -0
  12. package/dist/bytes.js.map +1 -0
  13. package/dist/constants.d.ts +40 -0
  14. package/dist/constants.js +42 -0
  15. package/dist/constants.js.map +1 -0
  16. package/dist/externals.d.ts +15 -0
  17. package/dist/externals.js +39 -0
  18. package/dist/externals.js.map +1 -0
  19. package/dist/hash.d.ts +69 -0
  20. package/dist/hash.js +162 -0
  21. package/dist/hash.js.map +1 -0
  22. package/dist/helpers.d.ts +21 -0
  23. package/dist/helpers.js +49 -0
  24. package/dist/helpers.js.map +1 -0
  25. package/dist/index.d.ts +40 -0
  26. package/dist/index.js +68 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/internal.d.ts +77 -0
  29. package/dist/internal.js +191 -0
  30. package/dist/internal.js.map +1 -0
  31. package/dist/object.d.ts +12 -0
  32. package/dist/object.js +109 -0
  33. package/dist/object.js.map +1 -0
  34. package/dist/signature.d.ts +55 -0
  35. package/dist/signature.js +163 -0
  36. package/dist/signature.js.map +1 -0
  37. package/dist/types.d.ts +62 -0
  38. package/dist/types.js +77 -0
  39. package/dist/types.js.map +1 -0
  40. package/dist.browser/account.d.ts +120 -0
  41. package/dist.browser/account.js +296 -0
  42. package/dist.browser/account.js.map +1 -0
  43. package/dist.browser/address.d.ts +60 -0
  44. package/dist.browser/address.js +105 -0
  45. package/dist.browser/address.js.map +1 -0
  46. package/dist.browser/bytes.d.ts +140 -0
  47. package/dist.browser/bytes.js +333 -0
  48. package/dist.browser/bytes.js.map +1 -0
  49. package/dist.browser/constants.d.ts +40 -0
  50. package/dist.browser/constants.js +42 -0
  51. package/dist.browser/constants.js.map +1 -0
  52. package/dist.browser/externals.d.ts +15 -0
  53. package/dist.browser/externals.js +39 -0
  54. package/dist.browser/externals.js.map +1 -0
  55. package/dist.browser/hash.d.ts +69 -0
  56. package/dist.browser/hash.js +166 -0
  57. package/dist.browser/hash.js.map +1 -0
  58. package/dist.browser/helpers.d.ts +21 -0
  59. package/dist.browser/helpers.js +49 -0
  60. package/dist.browser/helpers.js.map +1 -0
  61. package/dist.browser/index.d.ts +40 -0
  62. package/dist.browser/index.js +68 -0
  63. package/dist.browser/index.js.map +1 -0
  64. package/dist.browser/internal.d.ts +77 -0
  65. package/dist.browser/internal.js +191 -0
  66. package/dist.browser/internal.js.map +1 -0
  67. package/dist.browser/object.d.ts +12 -0
  68. package/dist.browser/object.js +110 -0
  69. package/dist.browser/object.js.map +1 -0
  70. package/dist.browser/signature.d.ts +55 -0
  71. package/dist.browser/signature.js +164 -0
  72. package/dist.browser/signature.js.map +1 -0
  73. package/dist.browser/types.d.ts +62 -0
  74. package/dist.browser/types.js +77 -0
  75. package/dist.browser/types.js.map +1 -0
  76. package/package.json +105 -0
  77. package/src/account.ts +321 -0
  78. package/src/address.ts +117 -0
  79. package/src/bytes.ts +334 -0
  80. package/src/constants.ts +54 -0
  81. package/src/externals.ts +18 -0
  82. package/src/hash.ts +159 -0
  83. package/src/helpers.ts +45 -0
  84. package/src/index.ts +60 -0
  85. package/src/internal.ts +209 -0
  86. package/src/object.ts +117 -0
  87. package/src/signature.ts +209 -0
  88. package/src/types.ts +146 -0
package/dist/bytes.js ADDED
@@ -0,0 +1,295 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bufArrToArr = exports.arrToBufArr = exports.validateNoLeadingZeroes = exports.baToJSON = exports.toUtf8 = exports.addHexPrefix = exports.toUnsigned = exports.fromSigned = exports.bufferToHex = exports.bufferToInt = exports.toBuffer = exports.unpadHexString = exports.unpadArray = exports.unpadBuffer = exports.setLengthRight = exports.setLengthLeft = exports.zeros = exports.intToBuffer = exports.intToHex = void 0;
4
+ const externals_1 = require("./externals");
5
+ const internal_1 = require("./internal");
6
+ const helpers_1 = require("./helpers");
7
+ /**
8
+ * Converts a `Number` into a hex `String`
9
+ * @param {Number} i
10
+ * @return {String}
11
+ */
12
+ const intToHex = function (i) {
13
+ if (!Number.isSafeInteger(i) || i < 0) {
14
+ throw new Error(`Received an invalid integer type: ${i}`);
15
+ }
16
+ return `0x${i.toString(16)}`;
17
+ };
18
+ exports.intToHex = intToHex;
19
+ /**
20
+ * Converts an `Number` to a `Buffer`
21
+ * @param {Number} i
22
+ * @return {Buffer}
23
+ */
24
+ const intToBuffer = function (i) {
25
+ const hex = (0, exports.intToHex)(i);
26
+ return Buffer.from((0, internal_1.padToEven)(hex.slice(2)), 'hex');
27
+ };
28
+ exports.intToBuffer = intToBuffer;
29
+ /**
30
+ * Returns a buffer filled with 0s.
31
+ * @param bytes the number of bytes the buffer should be
32
+ */
33
+ const zeros = function (bytes) {
34
+ return Buffer.allocUnsafe(bytes).fill(0);
35
+ };
36
+ exports.zeros = zeros;
37
+ /**
38
+ * Pads a `Buffer` with zeros till it has `length` bytes.
39
+ * Truncates the beginning or end of input if its length exceeds `length`.
40
+ * @param msg the value to pad (Buffer)
41
+ * @param length the number of bytes the output should be
42
+ * @param right whether to start padding form the left or right
43
+ * @return (Buffer)
44
+ */
45
+ const setLength = function (msg, length, right) {
46
+ const buf = (0, exports.zeros)(length);
47
+ if (right) {
48
+ if (msg.length < length) {
49
+ msg.copy(buf);
50
+ return buf;
51
+ }
52
+ return msg.slice(0, length);
53
+ }
54
+ else {
55
+ if (msg.length < length) {
56
+ msg.copy(buf, length - msg.length);
57
+ return buf;
58
+ }
59
+ return msg.slice(-length);
60
+ }
61
+ };
62
+ /**
63
+ * Left Pads a `Buffer` with leading zeros till it has `length` bytes.
64
+ * Or it truncates the beginning if it exceeds.
65
+ * @param msg the value to pad (Buffer)
66
+ * @param length the number of bytes the output should be
67
+ * @return (Buffer)
68
+ */
69
+ const setLengthLeft = function (msg, length) {
70
+ (0, helpers_1.assertIsBuffer)(msg);
71
+ return setLength(msg, length, false);
72
+ };
73
+ exports.setLengthLeft = setLengthLeft;
74
+ /**
75
+ * Right Pads a `Buffer` with trailing zeros till it has `length` bytes.
76
+ * it truncates the end if it exceeds.
77
+ * @param msg the value to pad (Buffer)
78
+ * @param length the number of bytes the output should be
79
+ * @return (Buffer)
80
+ */
81
+ const setLengthRight = function (msg, length) {
82
+ (0, helpers_1.assertIsBuffer)(msg);
83
+ return setLength(msg, length, true);
84
+ };
85
+ exports.setLengthRight = setLengthRight;
86
+ /**
87
+ * Trims leading zeros from a `Buffer`, `String` or `Number[]`.
88
+ * @param a (Buffer|Array|String)
89
+ * @return (Buffer|Array|String)
90
+ */
91
+ const stripZeros = function (a) {
92
+ let first = a[0];
93
+ while (a.length > 0 && first.toString() === '0') {
94
+ a = a.slice(1);
95
+ first = a[0];
96
+ }
97
+ return a;
98
+ };
99
+ /**
100
+ * Trims leading zeros from a `Buffer`.
101
+ * @param a (Buffer)
102
+ * @return (Buffer)
103
+ */
104
+ const unpadBuffer = function (a) {
105
+ (0, helpers_1.assertIsBuffer)(a);
106
+ return stripZeros(a);
107
+ };
108
+ exports.unpadBuffer = unpadBuffer;
109
+ /**
110
+ * Trims leading zeros from an `Array` (of numbers).
111
+ * @param a (number[])
112
+ * @return (number[])
113
+ */
114
+ const unpadArray = function (a) {
115
+ (0, helpers_1.assertIsArray)(a);
116
+ return stripZeros(a);
117
+ };
118
+ exports.unpadArray = unpadArray;
119
+ /**
120
+ * Trims leading zeros from a hex-prefixed `String`.
121
+ * @param a (String)
122
+ * @return (String)
123
+ */
124
+ const unpadHexString = function (a) {
125
+ (0, helpers_1.assertIsHexString)(a);
126
+ a = (0, internal_1.stripHexPrefix)(a);
127
+ return stripZeros(a);
128
+ };
129
+ exports.unpadHexString = unpadHexString;
130
+ /**
131
+ * Attempts to turn a value into a `Buffer`.
132
+ * Inputs supported: `Buffer`, `String` (hex-prefixed), `Number`, null/undefined, `BN` and other objects
133
+ * with a `toArray()` or `toBuffer()` method.
134
+ * @param v the value
135
+ */
136
+ const toBuffer = function (v) {
137
+ if (v === null || v === undefined) {
138
+ return Buffer.allocUnsafe(0);
139
+ }
140
+ if (Buffer.isBuffer(v)) {
141
+ return Buffer.from(v);
142
+ }
143
+ if (Array.isArray(v) || v instanceof Uint8Array) {
144
+ return Buffer.from(v);
145
+ }
146
+ if (typeof v === 'string') {
147
+ if (!(0, internal_1.isHexString)(v)) {
148
+ throw new Error(`Cannot convert string to buffer. toBuffer only supports 0x-prefixed hex strings and this string was given: ${v}`);
149
+ }
150
+ return Buffer.from((0, internal_1.padToEven)((0, internal_1.stripHexPrefix)(v)), 'hex');
151
+ }
152
+ if (typeof v === 'number') {
153
+ return (0, exports.intToBuffer)(v);
154
+ }
155
+ if (externals_1.BN.isBN(v)) {
156
+ if (v.isNeg()) {
157
+ throw new Error(`Cannot convert negative BN to buffer. Given: ${v}`);
158
+ }
159
+ return v.toArrayLike(Buffer);
160
+ }
161
+ if (v.toArray) {
162
+ // converts a BN to a Buffer
163
+ return Buffer.from(v.toArray());
164
+ }
165
+ if (v.toBuffer) {
166
+ return Buffer.from(v.toBuffer());
167
+ }
168
+ throw new Error('invalid type');
169
+ };
170
+ exports.toBuffer = toBuffer;
171
+ /**
172
+ * Converts a `Buffer` to a `Number`.
173
+ * @param buf `Buffer` object to convert
174
+ * @throws If the input number exceeds 53 bits.
175
+ */
176
+ const bufferToInt = function (buf) {
177
+ return new externals_1.BN((0, exports.toBuffer)(buf)).toNumber();
178
+ };
179
+ exports.bufferToInt = bufferToInt;
180
+ /**
181
+ * Converts a `Buffer` into a `0x`-prefixed hex `String`.
182
+ * @param buf `Buffer` object to convert
183
+ */
184
+ const bufferToHex = function (buf) {
185
+ buf = (0, exports.toBuffer)(buf);
186
+ return '0x' + buf.toString('hex');
187
+ };
188
+ exports.bufferToHex = bufferToHex;
189
+ /**
190
+ * Interprets a `Buffer` as a signed integer and returns a `BN`. Assumes 256-bit numbers.
191
+ * @param num Signed integer value
192
+ */
193
+ const fromSigned = function (num) {
194
+ return new externals_1.BN(num).fromTwos(256);
195
+ };
196
+ exports.fromSigned = fromSigned;
197
+ /**
198
+ * Converts a `BN` to an unsigned integer and returns it as a `Buffer`. Assumes 256-bit numbers.
199
+ * @param num
200
+ */
201
+ const toUnsigned = function (num) {
202
+ return Buffer.from(num.toTwos(256).toArray());
203
+ };
204
+ exports.toUnsigned = toUnsigned;
205
+ /**
206
+ * Adds "0x" to a given `String` if it does not already start with "0x".
207
+ */
208
+ const addHexPrefix = function (str) {
209
+ if (typeof str !== 'string') {
210
+ return str;
211
+ }
212
+ return (0, internal_1.isHexPrefixed)(str) ? str : '0x' + str;
213
+ };
214
+ exports.addHexPrefix = addHexPrefix;
215
+ /**
216
+ * Returns the utf8 string representation from a hex string.
217
+ *
218
+ * Examples:
219
+ *
220
+ * Input 1: '657468657265756d000000000000000000000000000000000000000000000000'
221
+ * Input 2: '657468657265756d'
222
+ * Input 3: '000000000000000000000000000000000000000000000000657468657265756d'
223
+ *
224
+ * Output (all 3 input variants): 'ethereum'
225
+ *
226
+ * Note that this method is not intended to be used with hex strings
227
+ * representing quantities in both big endian or little endian notation.
228
+ *
229
+ * @param string Hex string, should be `0x` prefixed
230
+ * @return Utf8 string
231
+ */
232
+ const toUtf8 = function (hex) {
233
+ const zerosRegexp = /^(00)+|(00)+$/g;
234
+ hex = (0, internal_1.stripHexPrefix)(hex);
235
+ if (hex.length % 2 !== 0) {
236
+ throw new Error('Invalid non-even hex string input for toUtf8() provided');
237
+ }
238
+ const bufferVal = Buffer.from(hex.replace(zerosRegexp, ''), 'hex');
239
+ return bufferVal.toString('utf8');
240
+ };
241
+ exports.toUtf8 = toUtf8;
242
+ /**
243
+ * Converts a `Buffer` or `Array` to JSON.
244
+ * @param ba (Buffer|Array)
245
+ * @return (Array|String|null)
246
+ */
247
+ const baToJSON = function (ba) {
248
+ if (Buffer.isBuffer(ba)) {
249
+ return `0x${ba.toString('hex')}`;
250
+ }
251
+ else if (ba instanceof Array) {
252
+ const array = [];
253
+ for (let i = 0; i < ba.length; i++) {
254
+ array.push((0, exports.baToJSON)(ba[i]));
255
+ }
256
+ return array;
257
+ }
258
+ };
259
+ exports.baToJSON = baToJSON;
260
+ /**
261
+ * Checks provided Buffers for leading zeroes and throws if found.
262
+ *
263
+ * Examples:
264
+ *
265
+ * Valid values: 0x1, 0x, 0x01, 0x1234
266
+ * Invalid values: 0x0, 0x00, 0x001, 0x0001
267
+ *
268
+ * Note: This method is useful for validating that RLP encoded integers comply with the rule that all
269
+ * integer values encoded to RLP must be in the most compact form and contain no leading zero bytes
270
+ * @param values An object containing string keys and Buffer values
271
+ * @throws if any provided value is found to have leading zero bytes
272
+ */
273
+ const validateNoLeadingZeroes = function (values) {
274
+ for (const [k, v] of Object.entries(values)) {
275
+ if (v !== undefined && v.length > 0 && v[0] === 0) {
276
+ throw new Error(`${k} cannot have leading zeroes, received: ${v.toString('hex')}`);
277
+ }
278
+ }
279
+ };
280
+ exports.validateNoLeadingZeroes = validateNoLeadingZeroes;
281
+ function arrToBufArr(arr) {
282
+ if (!Array.isArray(arr)) {
283
+ return Buffer.from(arr);
284
+ }
285
+ return arr.map((a) => arrToBufArr(a));
286
+ }
287
+ exports.arrToBufArr = arrToBufArr;
288
+ function bufArrToArr(arr) {
289
+ if (!Array.isArray(arr)) {
290
+ return Uint8Array.from(arr !== null && arr !== void 0 ? arr : []);
291
+ }
292
+ return arr.map((a) => bufArrToArr(a));
293
+ }
294
+ exports.bufArrToArr = bufArrToArr;
295
+ //# sourceMappingURL=bytes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bytes.js","sourceRoot":"","sources":["../src/bytes.ts"],"names":[],"mappings":";;;AAAA,2CAAgC;AAChC,yCAAkF;AAQlF,uCAA4E;AAE5E;;;;GAIG;AACI,MAAM,QAAQ,GAAG,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GAYG;AACI,MAAM,uBAAuB,GAAG,UAAU,MAA6C;IAC5F,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QAC3C,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE;YACjD,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;SACnF;KACF;AACH,CAAC,CAAA;AANY,QAAA,uBAAuB,2BAMnC;AAQD,SAAgB,WAAW,CAAC,GAAkC;IAC5D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACvB,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;KACxB;IACD,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAA;AACvC,CAAC;AALD,kCAKC;AAQD,SAAgB,WAAW,CAAC,GAA+B;IACzD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACvB,OAAO,UAAU,CAAC,IAAI,CAAC,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,EAAE,CAAC,CAAA;KAClC;IACD,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAA;AACvC,CAAC;AALD,kCAKC"}
@@ -0,0 +1,40 @@
1
+ /// <reference types="bn.js" />
2
+ /// <reference types="node" />
3
+ import { Buffer } from 'buffer';
4
+ import { BN } from './externals';
5
+ /**
6
+ * 2^64-1
7
+ */
8
+ export declare const MAX_UINT64: BN;
9
+ /**
10
+ * The max integer that the evm can handle (2^256-1)
11
+ */
12
+ export declare const MAX_INTEGER: BN;
13
+ /**
14
+ * 2^256
15
+ */
16
+ export declare const TWO_POW256: BN;
17
+ /**
18
+ * Keccak-256 hash of null
19
+ */
20
+ export declare const KECCAK256_NULL_S = "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470";
21
+ /**
22
+ * Keccak-256 hash of null
23
+ */
24
+ export declare const KECCAK256_NULL: Buffer;
25
+ /**
26
+ * Keccak-256 of an RLP of an empty array
27
+ */
28
+ export declare const KECCAK256_RLP_ARRAY_S = "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347";
29
+ /**
30
+ * Keccak-256 of an RLP of an empty array
31
+ */
32
+ export declare const KECCAK256_RLP_ARRAY: Buffer;
33
+ /**
34
+ * Keccak-256 hash of the RLP of null
35
+ */
36
+ export declare const KECCAK256_RLP_S = "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421";
37
+ /**
38
+ * Keccak-256 hash of the RLP of null
39
+ */
40
+ export declare const KECCAK256_RLP: Buffer;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KECCAK256_RLP = exports.KECCAK256_RLP_S = exports.KECCAK256_RLP_ARRAY = exports.KECCAK256_RLP_ARRAY_S = exports.KECCAK256_NULL = exports.KECCAK256_NULL_S = exports.TWO_POW256 = exports.MAX_INTEGER = exports.MAX_UINT64 = void 0;
4
+ const buffer_1 = require("buffer");
5
+ const externals_1 = require("./externals");
6
+ /**
7
+ * 2^64-1
8
+ */
9
+ exports.MAX_UINT64 = new externals_1.BN('ffffffffffffffff', 16);
10
+ /**
11
+ * The max integer that the evm can handle (2^256-1)
12
+ */
13
+ exports.MAX_INTEGER = new externals_1.BN('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16);
14
+ /**
15
+ * 2^256
16
+ */
17
+ exports.TWO_POW256 = new externals_1.BN('10000000000000000000000000000000000000000000000000000000000000000', 16);
18
+ /**
19
+ * Keccak-256 hash of null
20
+ */
21
+ exports.KECCAK256_NULL_S = 'c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470';
22
+ /**
23
+ * Keccak-256 hash of null
24
+ */
25
+ exports.KECCAK256_NULL = buffer_1.Buffer.from(exports.KECCAK256_NULL_S, 'hex');
26
+ /**
27
+ * Keccak-256 of an RLP of an empty array
28
+ */
29
+ exports.KECCAK256_RLP_ARRAY_S = '1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347';
30
+ /**
31
+ * Keccak-256 of an RLP of an empty array
32
+ */
33
+ exports.KECCAK256_RLP_ARRAY = buffer_1.Buffer.from(exports.KECCAK256_RLP_ARRAY_S, 'hex');
34
+ /**
35
+ * Keccak-256 hash of the RLP of null
36
+ */
37
+ exports.KECCAK256_RLP_S = '56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421';
38
+ /**
39
+ * Keccak-256 hash of the RLP of null
40
+ */
41
+ exports.KECCAK256_RLP = buffer_1.Buffer.from(exports.KECCAK256_RLP_S, 'hex');
42
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAC/B,2CAAgC;AAEhC;;GAEG;AACU,QAAA,UAAU,GAAG,IAAI,cAAE,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAA;AAExD;;GAEG;AACU,QAAA,WAAW,GAAG,IAAI,cAAE,CAC/B,kEAAkE,EAClE,EAAE,CACH,CAAA;AAED;;GAEG;AACU,QAAA,UAAU,GAAG,IAAI,cAAE,CAC9B,mEAAmE,EACnE,EAAE,CACH,CAAA;AAED;;GAEG;AACU,QAAA,gBAAgB,GAAG,kEAAkE,CAAA;AAElG;;GAEG;AACU,QAAA,cAAc,GAAG,eAAM,CAAC,IAAI,CAAC,wBAAgB,EAAE,KAAK,CAAC,CAAA;AAElE;;GAEG;AACU,QAAA,qBAAqB,GAChC,kEAAkE,CAAA;AAEpE;;GAEG;AACU,QAAA,mBAAmB,GAAG,eAAM,CAAC,IAAI,CAAC,6BAAqB,EAAE,KAAK,CAAC,CAAA;AAE5E;;GAEG;AACU,QAAA,eAAe,GAAG,kEAAkE,CAAA;AAEjG;;GAEG;AACU,QAAA,aAAa,GAAG,eAAM,CAAC,IAAI,CAAC,uBAAe,EAAE,KAAK,CAAC,CAAA"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Re-exports commonly used modules:
3
+ * * Exports [`BN`](https://github.com/indutny/bn.js), [`rlp`](https://github.com/ethereumjs/rlp).
4
+ * @packageDocumentation
5
+ */
6
+ import BN from 'bn.js';
7
+ import * as rlp from 'rlp';
8
+ /**
9
+ * [`BN`](https://github.com/indutny/bn.js)
10
+ */
11
+ export { BN };
12
+ /**
13
+ * [`rlp`](https://github.com/ethereumjs/rlp)
14
+ */
15
+ export { rlp };
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ /**
3
+ * Re-exports commonly used modules:
4
+ * * Exports [`BN`](https://github.com/indutny/bn.js), [`rlp`](https://github.com/ethereumjs/rlp).
5
+ * @packageDocumentation
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || function (mod) {
24
+ if (mod && mod.__esModule) return mod;
25
+ var result = {};
26
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
27
+ __setModuleDefault(result, mod);
28
+ return result;
29
+ };
30
+ var __importDefault = (this && this.__importDefault) || function (mod) {
31
+ return (mod && mod.__esModule) ? mod : { "default": mod };
32
+ };
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ exports.rlp = exports.BN = void 0;
35
+ const bn_js_1 = __importDefault(require("bn.js"));
36
+ exports.BN = bn_js_1.default;
37
+ const rlp = __importStar(require("rlp"));
38
+ exports.rlp = rlp;
39
+ //# sourceMappingURL=externals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"externals.js","sourceRoot":"","sources":["../src/externals.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kDAAsB;AAMb,aANF,eAAE,CAME;AALX,yCAA0B;AAUjB,kBAAG"}
package/dist/hash.d.ts ADDED
@@ -0,0 +1,69 @@
1
+ /// <reference types="node" />
2
+ import { rlp } from './externals';
3
+ /**
4
+ * Creates Keccak hash of a Buffer input
5
+ * @param a The input data (Buffer)
6
+ * @param bits (number = 256) The Keccak width
7
+ */
8
+ export declare const keccak: (a: Buffer, bits?: number) => Buffer;
9
+ /**
10
+ * Creates Keccak-256 hash of the input, alias for keccak(a, 256).
11
+ * @param a The input data (Buffer)
12
+ */
13
+ export declare const keccak256: (a: Buffer) => Buffer;
14
+ /**
15
+ * Creates Keccak hash of a utf-8 string input
16
+ * @param a The input data (String)
17
+ * @param bits (number = 256) The Keccak width
18
+ */
19
+ export declare const keccakFromString: (a: string, bits?: number) => Buffer;
20
+ /**
21
+ * Creates Keccak hash of an 0x-prefixed string input
22
+ * @param a The input data (String)
23
+ * @param bits (number = 256) The Keccak width
24
+ */
25
+ export declare const keccakFromHexString: (a: string, bits?: number) => Buffer;
26
+ /**
27
+ * Creates Keccak hash of a number array input
28
+ * @param a The input data (number[])
29
+ * @param bits (number = 256) The Keccak width
30
+ */
31
+ export declare const keccakFromArray: (a: number[], bits?: number) => Buffer;
32
+ /**
33
+ * Creates SHA256 hash of a Buffer input.
34
+ * @param a The input data (Buffer)
35
+ */
36
+ export declare const sha256: (a: Buffer) => Buffer;
37
+ /**
38
+ * Creates SHA256 hash of a string input.
39
+ * @param a The input data (string)
40
+ */
41
+ export declare const sha256FromString: (a: string) => Buffer;
42
+ /**
43
+ * Creates SHA256 hash of a number[] input.
44
+ * @param a The input data (number[])
45
+ */
46
+ export declare const sha256FromArray: (a: number[]) => Buffer;
47
+ /**
48
+ * Creates RIPEMD160 hash of a Buffer input.
49
+ * @param a The input data (Buffer)
50
+ * @param padded Whether it should be padded to 256 bits or not
51
+ */
52
+ export declare const ripemd160: (a: Buffer, padded: boolean) => Buffer;
53
+ /**
54
+ * Creates RIPEMD160 hash of a string input.
55
+ * @param a The input data (String)
56
+ * @param padded Whether it should be padded to 256 bits or not
57
+ */
58
+ export declare const ripemd160FromString: (a: string, padded: boolean) => Buffer;
59
+ /**
60
+ * Creates RIPEMD160 hash of a number[] input.
61
+ * @param a The input data (number[])
62
+ * @param padded Whether it should be padded to 256 bits or not
63
+ */
64
+ export declare const ripemd160FromArray: (a: number[], padded: boolean) => Buffer;
65
+ /**
66
+ * Creates SHA-3 hash of the RLP encoded version of the input.
67
+ * @param a The input data
68
+ */
69
+ export declare const rlphash: (a: rlp.Input) => Buffer;
package/dist/hash.js ADDED
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rlphash = exports.ripemd160FromArray = exports.ripemd160FromString = exports.ripemd160 = exports.sha256FromArray = exports.sha256FromString = exports.sha256 = exports.keccakFromArray = exports.keccakFromHexString = exports.keccakFromString = exports.keccak256 = exports.keccak = void 0;
4
+ const keccak_1 = require("ethereum-cryptography/keccak");
5
+ const createHash = require('create-hash');
6
+ const externals_1 = require("./externals");
7
+ const bytes_1 = require("./bytes");
8
+ const helpers_1 = require("./helpers");
9
+ /**
10
+ * Creates Keccak hash of a Buffer input
11
+ * @param a The input data (Buffer)
12
+ * @param bits (number = 256) The Keccak width
13
+ */
14
+ const keccak = function (a, bits = 256) {
15
+ (0, helpers_1.assertIsBuffer)(a);
16
+ switch (bits) {
17
+ case 224: {
18
+ return (0, keccak_1.keccak224)(a);
19
+ }
20
+ case 256: {
21
+ return (0, keccak_1.keccak256)(a);
22
+ }
23
+ case 384: {
24
+ return (0, keccak_1.keccak384)(a);
25
+ }
26
+ case 512: {
27
+ return (0, keccak_1.keccak512)(a);
28
+ }
29
+ default: {
30
+ throw new Error(`Invald algorithm: keccak${bits}`);
31
+ }
32
+ }
33
+ };
34
+ exports.keccak = keccak;
35
+ /**
36
+ * Creates Keccak-256 hash of the input, alias for keccak(a, 256).
37
+ * @param a The input data (Buffer)
38
+ */
39
+ const keccak256 = function (a) {
40
+ return (0, exports.keccak)(a);
41
+ };
42
+ exports.keccak256 = keccak256;
43
+ /**
44
+ * Creates Keccak hash of a utf-8 string input
45
+ * @param a The input data (String)
46
+ * @param bits (number = 256) The Keccak width
47
+ */
48
+ const keccakFromString = function (a, bits = 256) {
49
+ (0, helpers_1.assertIsString)(a);
50
+ const buf = Buffer.from(a, 'utf8');
51
+ return (0, exports.keccak)(buf, bits);
52
+ };
53
+ exports.keccakFromString = keccakFromString;
54
+ /**
55
+ * Creates Keccak hash of an 0x-prefixed string input
56
+ * @param a The input data (String)
57
+ * @param bits (number = 256) The Keccak width
58
+ */
59
+ const keccakFromHexString = function (a, bits = 256) {
60
+ (0, helpers_1.assertIsHexString)(a);
61
+ return (0, exports.keccak)((0, bytes_1.toBuffer)(a), bits);
62
+ };
63
+ exports.keccakFromHexString = keccakFromHexString;
64
+ /**
65
+ * Creates Keccak hash of a number array input
66
+ * @param a The input data (number[])
67
+ * @param bits (number = 256) The Keccak width
68
+ */
69
+ const keccakFromArray = function (a, bits = 256) {
70
+ (0, helpers_1.assertIsArray)(a);
71
+ return (0, exports.keccak)((0, bytes_1.toBuffer)(a), bits);
72
+ };
73
+ exports.keccakFromArray = keccakFromArray;
74
+ /**
75
+ * Creates SHA256 hash of an input.
76
+ * @param a The input data (Buffer|Array|String)
77
+ */
78
+ const _sha256 = function (a) {
79
+ a = (0, bytes_1.toBuffer)(a);
80
+ return createHash('sha256').update(a).digest();
81
+ };
82
+ /**
83
+ * Creates SHA256 hash of a Buffer input.
84
+ * @param a The input data (Buffer)
85
+ */
86
+ const sha256 = function (a) {
87
+ (0, helpers_1.assertIsBuffer)(a);
88
+ return _sha256(a);
89
+ };
90
+ exports.sha256 = sha256;
91
+ /**
92
+ * Creates SHA256 hash of a string input.
93
+ * @param a The input data (string)
94
+ */
95
+ const sha256FromString = function (a) {
96
+ (0, helpers_1.assertIsString)(a);
97
+ return _sha256(a);
98
+ };
99
+ exports.sha256FromString = sha256FromString;
100
+ /**
101
+ * Creates SHA256 hash of a number[] input.
102
+ * @param a The input data (number[])
103
+ */
104
+ const sha256FromArray = function (a) {
105
+ (0, helpers_1.assertIsArray)(a);
106
+ return _sha256(a);
107
+ };
108
+ exports.sha256FromArray = sha256FromArray;
109
+ /**
110
+ * Creates RIPEMD160 hash of the input.
111
+ * @param a The input data (Buffer|Array|String|Number)
112
+ * @param padded Whether it should be padded to 256 bits or not
113
+ */
114
+ const _ripemd160 = function (a, padded) {
115
+ a = (0, bytes_1.toBuffer)(a);
116
+ const hash = createHash('rmd160').update(a).digest();
117
+ if (padded === true) {
118
+ return (0, bytes_1.setLengthLeft)(hash, 32);
119
+ }
120
+ else {
121
+ return hash;
122
+ }
123
+ };
124
+ /**
125
+ * Creates RIPEMD160 hash of a Buffer input.
126
+ * @param a The input data (Buffer)
127
+ * @param padded Whether it should be padded to 256 bits or not
128
+ */
129
+ const ripemd160 = function (a, padded) {
130
+ (0, helpers_1.assertIsBuffer)(a);
131
+ return _ripemd160(a, padded);
132
+ };
133
+ exports.ripemd160 = ripemd160;
134
+ /**
135
+ * Creates RIPEMD160 hash of a string input.
136
+ * @param a The input data (String)
137
+ * @param padded Whether it should be padded to 256 bits or not
138
+ */
139
+ const ripemd160FromString = function (a, padded) {
140
+ (0, helpers_1.assertIsString)(a);
141
+ return _ripemd160(a, padded);
142
+ };
143
+ exports.ripemd160FromString = ripemd160FromString;
144
+ /**
145
+ * Creates RIPEMD160 hash of a number[] input.
146
+ * @param a The input data (number[])
147
+ * @param padded Whether it should be padded to 256 bits or not
148
+ */
149
+ const ripemd160FromArray = function (a, padded) {
150
+ (0, helpers_1.assertIsArray)(a);
151
+ return _ripemd160(a, padded);
152
+ };
153
+ exports.ripemd160FromArray = ripemd160FromArray;
154
+ /**
155
+ * Creates SHA-3 hash of the RLP encoded version of the input.
156
+ * @param a The input data
157
+ */
158
+ const rlphash = function (a) {
159
+ return (0, exports.keccak)(externals_1.rlp.encode(a));
160
+ };
161
+ exports.rlphash = rlphash;
162
+ //# sourceMappingURL=hash.js.map