ecash-lib 4.13.0-rc.0 → 4.14.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 (81) hide show
  1. package/README.md +2 -1
  2. package/dist/blindSchnorr.d.ts +27 -0
  3. package/dist/blindSchnorr.d.ts.map +1 -0
  4. package/dist/blindSchnorr.js +206 -0
  5. package/dist/blindSchnorr.js.map +1 -0
  6. package/dist/ecc.d.ts +15 -0
  7. package/dist/ecc.d.ts.map +1 -1
  8. package/dist/ecc.js +36 -1
  9. package/dist/ecc.js.map +1 -1
  10. package/dist/eccScalar.d.ts +12 -0
  11. package/dist/eccScalar.d.ts.map +1 -0
  12. package/dist/eccScalar.js +42 -0
  13. package/dist/eccScalar.js.map +1 -0
  14. package/dist/ffi/ecash_lib_wasm_bg_browser.js +21400 -2628
  15. package/dist/ffi/ecash_lib_wasm_bg_browser.wasm +0 -0
  16. package/dist/ffi/ecash_lib_wasm_bg_browser.wasm.d.ts +8 -3
  17. package/dist/ffi/ecash_lib_wasm_browser.d.ts +59 -20
  18. package/dist/ffi/ecash_lib_wasm_browser.js +219 -83
  19. package/dist/index.d.ts +5 -0
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +5 -0
  22. package/dist/index.js.map +1 -1
  23. package/dist/initWasm.js +3 -4
  24. package/dist/initWasm.js.map +1 -1
  25. package/dist/io/array.d.ts +16 -0
  26. package/dist/io/array.d.ts.map +1 -0
  27. package/dist/io/array.js +71 -0
  28. package/dist/io/array.js.map +1 -0
  29. package/dist/payment/action.d.ts +7 -0
  30. package/dist/payment/action.d.ts.map +1 -1
  31. package/dist/payment/action.js.map +1 -1
  32. package/dist/pedersen.d.ts +62 -0
  33. package/dist/pedersen.d.ts.map +1 -0
  34. package/dist/pedersen.js +257 -0
  35. package/dist/pedersen.js.map +1 -0
  36. package/package.json +51 -62
  37. package/src/blindSchnorr.ts +241 -0
  38. package/src/ecc.ts +61 -1
  39. package/src/eccScalar.ts +41 -0
  40. package/src/ffi/ecash_lib_wasm_bg_browser.js +21400 -2628
  41. package/src/ffi/ecash_lib_wasm_bg_browser.wasm +0 -0
  42. package/src/ffi/ecash_lib_wasm_bg_browser.wasm.d.ts +8 -3
  43. package/src/ffi/ecash_lib_wasm_browser.d.ts +59 -20
  44. package/src/ffi/ecash_lib_wasm_browser.js +219 -83
  45. package/src/index.ts +6 -0
  46. package/src/initWasm.ts +3 -4
  47. package/src/io/array.ts +70 -0
  48. package/src/payment/action.ts +7 -0
  49. package/src/pedersen.ts +280 -0
  50. package/dist/ffi/ecash_lib_wasm_bg_nodejs.wasm +0 -0
  51. package/dist/ffi/ecash_lib_wasm_bg_nodejs.wasm.d.ts +0 -40
  52. package/dist/ffi/ecash_lib_wasm_nodejs.d.ts +0 -180
  53. package/dist/ffi/ecash_lib_wasm_nodejs.js +0 -726
  54. package/dist/indexBrowser.d.ts +0 -3
  55. package/dist/indexBrowser.d.ts.map +0 -1
  56. package/dist/indexBrowser.js +0 -22
  57. package/dist/indexBrowser.js.map +0 -1
  58. package/dist/indexNodeJs.d.ts +0 -3
  59. package/dist/indexNodeJs.d.ts.map +0 -1
  60. package/dist/indexNodeJs.js +0 -22
  61. package/dist/indexNodeJs.js.map +0 -1
  62. package/dist/initBrowser.d.ts +0 -2
  63. package/dist/initBrowser.d.ts.map +0 -1
  64. package/dist/initBrowser.js +0 -7
  65. package/dist/initBrowser.js.map +0 -1
  66. package/dist/initNodeJs.d.ts +0 -2
  67. package/dist/initNodeJs.d.ts.map +0 -1
  68. package/dist/initNodeJs.js +0 -7
  69. package/dist/initNodeJs.js.map +0 -1
  70. package/dist/payment/p2shInputData.d.ts +0 -18
  71. package/dist/payment/p2shInputData.d.ts.map +0 -1
  72. package/dist/payment/p2shInputData.js +0 -88
  73. package/dist/payment/p2shInputData.js.map +0 -1
  74. package/src/ffi/ecash_lib_wasm_bg_nodejs.wasm +0 -0
  75. package/src/ffi/ecash_lib_wasm_bg_nodejs.wasm.d.ts +0 -40
  76. package/src/ffi/ecash_lib_wasm_nodejs.d.ts +0 -180
  77. package/src/ffi/ecash_lib_wasm_nodejs.js +0 -726
  78. package/src/indexBrowser.ts +0 -6
  79. package/src/indexNodeJs.ts +0 -6
  80. package/src/initBrowser.ts +0 -5
  81. package/src/initNodeJs.ts +0 -5
@@ -0,0 +1,280 @@
1
+ // Copyright (c) 2026 The Bitcoin developers
2
+ // Distributed under the MIT software license, see the accompanying
3
+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
+
5
+ import { Ecc } from './ecc.js';
6
+ import {
7
+ CURVE_ORDER,
8
+ modCurveOrder,
9
+ randomScalarBytes,
10
+ scalarToBytes,
11
+ } from './eccScalar.js';
12
+ import { bytesToScalar, equalBytes, zeroBytes } from './io/array.js';
13
+ import { fromHex } from './io/hex.js';
14
+
15
+ const ecc = new Ecc();
16
+ const SCALAR_ONE = fromHex(
17
+ '0000000000000000000000000000000000000000000000000000000000000001',
18
+ );
19
+
20
+ export class NonceRangeError extends Error {
21
+ constructor(message = 'Invalid Pedersen nonce') {
22
+ super(message);
23
+ this.name = 'NonceRangeError';
24
+ }
25
+ }
26
+
27
+ export class InsecureHPoint extends Error {
28
+ constructor(message = 'InsecureHPoint') {
29
+ super(message);
30
+ this.name = 'InsecureHPoint';
31
+ }
32
+ }
33
+
34
+ /** Sum of commitment points is the point at infinity (cannot be serialized). */
35
+ export class ResultAtInfinity extends Error {
36
+ constructor(message = 'ResultAtInfinity') {
37
+ super(message);
38
+ this.name = 'ResultAtInfinity';
39
+ }
40
+ }
41
+
42
+ export interface PedersenCommitment {
43
+ amount: bigint;
44
+ /** 32-byte nonce scalar (may be zero for aggregate openings) */
45
+ nonce: Uint8Array;
46
+ /** Compressed (33-byte) commitment point */
47
+ point: Uint8Array;
48
+ /** Uncompressed (65-byte) commitment point */
49
+ pointUncompressed: Uint8Array;
50
+ }
51
+
52
+ /**
53
+ * Pedersen setup for commitments C = nonce*G + amount*H (same algebra as
54
+ * Electrum ABC).
55
+ *
56
+ * Rejects insecure H with a known discrete log vs G:
57
+ * - H = -G (HG at infinity), same as Electrum
58
+ * - H = G (then C = (nonce+amount)G and binding is lost)
59
+ *
60
+ * Callers supply a nothing-up-my-sleeve H (Electrum/ALP fixed domain strings).
61
+ * This API does not derive H itself.
62
+ *
63
+ * Implementation detail: we store H and H+G and evaluate the equivalent form
64
+ * C = (a - k)*H + k*(H + G)
65
+ * so the amount scalar multiply is blinded by the nonce (see Electrum
66
+ * `Commitment._calc_initial`). Expand to recover C = k*G + a*H.
67
+ *
68
+ * Fresh nonces from {@link commit} are in [1, n). A zero nonce is accepted when
69
+ * supplied explicitly (e.g. aggregate openings where nonces cancel): then
70
+ * C = amount*H. The (amount, nonce) = (0, 0) opening is the identity and cannot
71
+ * be serialized as a point — use {@link verifyCommitmentSum} for that case.
72
+ */
73
+ export class PedersenSetup {
74
+ /** Compressed H */
75
+ readonly H: Uint8Array;
76
+ /** Compressed H+G */
77
+ readonly HG: Uint8Array;
78
+
79
+ constructor(H: Uint8Array) {
80
+ // Accept compressed (33) or uncompressed (65), same as Electrum ABC.
81
+ let compressed: Uint8Array;
82
+ if (H.length === 33) {
83
+ try {
84
+ ecc.uncompressPk(H); // validate
85
+ } catch {
86
+ throw new Error('H could not be parsed');
87
+ }
88
+ compressed = H;
89
+ } else if (H.length === 65 && H[0] === 0x04) {
90
+ try {
91
+ compressed = ecc.compressPk(H);
92
+ } catch {
93
+ throw new Error('H could not be parsed');
94
+ }
95
+ } else {
96
+ throw new Error('H could not be parsed');
97
+ }
98
+ if (equalBytes(compressed, ecc.derivePubkey(SCALAR_ONE))) {
99
+ throw new InsecureHPoint('H = G');
100
+ }
101
+ try {
102
+ // HG = H + G. Fails if H = -G (result at infinity).
103
+ this.HG = ecc.pubkeyAdd(compressed, SCALAR_ONE);
104
+ } catch {
105
+ throw new InsecureHPoint();
106
+ }
107
+ this.H = new Uint8Array(compressed);
108
+ }
109
+
110
+ commit(amount: bigint, nonce?: Uint8Array): PedersenCommitment {
111
+ const amountMod = modCurveOrder(amount);
112
+ const amountBytes = scalarToBytes(amountMod);
113
+
114
+ let k: Uint8Array;
115
+ if (nonce === undefined) {
116
+ // Fresh nonce in [1, n) — never zero.
117
+ k = randomScalarBytes();
118
+ } else {
119
+ if (nonce.length !== 32) {
120
+ throw new NonceRangeError('nonce must be 32 bytes');
121
+ }
122
+ const kn = bytesToScalar(nonce);
123
+ if (kn < 0n || kn >= CURVE_ORDER) {
124
+ throw new NonceRangeError();
125
+ }
126
+ k = new Uint8Array(nonce);
127
+
128
+ // Zero nonce: C = a*H (aggregate opening when nonces cancel).
129
+ // For independent random nonces this is ~2^-256 unlikely; it is
130
+ // expected when deliberately summing complementary nonces.
131
+ // libsecp rejects 0*P, so this path is explicit.
132
+ if (kn === 0n) {
133
+ if (amountMod === 0n) {
134
+ throw new ResultAtInfinity(
135
+ 'commitment at infinity (zero amount and nonce)',
136
+ );
137
+ }
138
+ const point = ecc.pubkeyMul(this.H, amountBytes);
139
+ return {
140
+ amount,
141
+ nonce: k,
142
+ point,
143
+ pointUncompressed: ecc.uncompressPk(point),
144
+ };
145
+ }
146
+ }
147
+
148
+ // Electrum amount blinding: C = (a-k)*H + k*(H+G).
149
+ const kHG = ecc.pubkeyMul(this.HG, k);
150
+ let point = kHG;
151
+ const negK = ecc.seckeyNegate(k);
152
+ let aMinusK: Uint8Array | undefined;
153
+ try {
154
+ // seckeyAdd = secp256k1 seckey tweak add: (a + b) mod n.
155
+ // Here: (a - k) mod n. Throws when the result is 0 (invalid seckey),
156
+ // i.e. when (a - k) ≡ 0 (mod n) — Electrum's a_k == 0 fast path.
157
+ // For uniform random k that is ~2^-256 unlikely (a ≡ k mod n).
158
+ aMinusK = ecc.seckeyAdd(negK, amountBytes);
159
+ } catch {
160
+ // (a - k) ≡ 0 (mod n): C = k*(H+G) only (point already kHG).
161
+ } finally {
162
+ zeroBytes(negK);
163
+ }
164
+
165
+ if (aMinusK !== undefined) {
166
+ try {
167
+ const akH = ecc.pubkeyMul(this.H, aMinusK);
168
+ try {
169
+ point = ecc.pubkeyCombine(kHG, akH);
170
+ } catch {
171
+ // Point at infinity ⇒ discrete log of H is known.
172
+ throw new InsecureHPoint();
173
+ }
174
+ } finally {
175
+ zeroBytes(aMinusK);
176
+ }
177
+ }
178
+
179
+ return {
180
+ amount,
181
+ nonce: k,
182
+ point,
183
+ pointUncompressed: ecc.uncompressPk(point),
184
+ };
185
+ }
186
+ }
187
+
188
+ /** Compress and validate a commitment point (33-byte compressed or 65-byte). */
189
+ function normalizeCommitmentPoint(p: Uint8Array): Uint8Array {
190
+ if (p.length === 65) {
191
+ if (p[0] !== 0x04) {
192
+ throw new Error('Invalid uncompressed commitment point');
193
+ }
194
+ const compressed = ecc.compressPk(p);
195
+ // compressPk only packs bytes; require a valid curve point.
196
+ ecc.uncompressPk(compressed);
197
+ return compressed;
198
+ }
199
+ if (p.length === 33) {
200
+ if (p[0] !== 0x02 && p[0] !== 0x03) {
201
+ throw new Error('Invalid compressed commitment point');
202
+ }
203
+ ecc.uncompressPk(p);
204
+ return p;
205
+ }
206
+ throw new Error('Invalid commitment point length');
207
+ }
208
+
209
+ export function addCommitmentPoints(points: Uint8Array[]): Uint8Array {
210
+ if (points.length === 0) {
211
+ throw new Error('No points to add');
212
+ }
213
+ // Validate each point before combining so malformed input is not mistaken
214
+ // for the point at infinity.
215
+ const compressed = points.map(normalizeCommitmentPoint);
216
+ let sum: Uint8Array;
217
+ try {
218
+ sum = compressed
219
+ .slice(1)
220
+ .reduce((acc, p) => ecc.pubkeyCombine(acc, p), compressed[0]);
221
+ } catch {
222
+ throw new ResultAtInfinity();
223
+ }
224
+ return ecc.uncompressPk(sum);
225
+ }
226
+
227
+ /**
228
+ * Verify that commitments open to (totalAmount, totalNonce).
229
+ * Returns a boolean (does not throw for the identity aggregate): when the
230
+ * points sum to infinity, the only valid opening is amount ≡ 0 and nonce = 0.
231
+ * Ill-formed commitments or nonce always return false (never true).
232
+ */
233
+ export function verifyCommitmentSum(
234
+ setup: PedersenSetup,
235
+ commitments: Uint8Array[],
236
+ totalAmount: bigint,
237
+ totalNonce: Uint8Array,
238
+ ): boolean {
239
+ if (totalNonce.length !== 32) {
240
+ return false;
241
+ }
242
+ const amountMod = modCurveOrder(totalAmount);
243
+ const nonceIsZero = bytesToScalar(totalNonce) === 0n;
244
+
245
+ let sum: Uint8Array;
246
+ try {
247
+ sum = addCommitmentPoints(commitments);
248
+ } catch (e) {
249
+ // Genuine infinity only after points were validated.
250
+ if (e instanceof ResultAtInfinity) {
251
+ return nonceIsZero && amountMod === 0n;
252
+ }
253
+ return false;
254
+ }
255
+
256
+ // Claimed (0, 0) opening but the sum is a concrete point.
257
+ if (nonceIsZero && amountMod === 0n) {
258
+ return false;
259
+ }
260
+
261
+ try {
262
+ const expected = setup.commit(totalAmount, totalNonce);
263
+ return equalBytes(sum, expected.pointUncompressed);
264
+ } catch {
265
+ return false;
266
+ }
267
+ }
268
+
269
+ /**
270
+ * Sum two 32-byte seckeys/nonces mod n (wasm seckeyAdd).
271
+ * When (a + b) ≡ 0 (mod n), seckeyAdd throws — return canonical zero.
272
+ */
273
+ export function addScalars(a: Uint8Array, b: Uint8Array): Uint8Array {
274
+ try {
275
+ return ecc.seckeyAdd(a, b);
276
+ } catch {
277
+ // (a + b) ≡ 0 (mod n)
278
+ return new Uint8Array(32);
279
+ }
280
+ }
@@ -1,40 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- export const memory: WebAssembly.Memory;
4
- export function ecc_new(): number;
5
- export function ecc_derivePubkey(a: number, b: number, c: number, d: number): void;
6
- export function ecc_ecdsaSign(a: number, b: number, c: number, d: number, e: number, f: number): void;
7
- export function ecc_ecdsaVerify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void;
8
- export function ecc_schnorrSign(a: number, b: number, c: number, d: number, e: number, f: number): void;
9
- export function ecc_schnorrVerify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void;
10
- export function ecc_isValidSeckey(a: number, b: number, c: number): number;
11
- export function ecc_seckeyAdd(a: number, b: number, c: number, d: number, e: number, f: number): void;
12
- export function ecc_pubkeyAdd(a: number, b: number, c: number, d: number, e: number, f: number): void;
13
- export function ecc_signRecoverable(a: number, b: number, c: number, d: number, e: number, f: number): void;
14
- export function ecc_recoverSig(a: number, b: number, c: number, d: number, e: number, f: number): void;
15
- export function __wbg_ecc_free(a: number): void;
16
- export function sha512h_new(): number;
17
- export function sha512h_update(a: number, b: number, c: number): void;
18
- export function sha512h_finalize(a: number, b: number): void;
19
- export function sha512h_clone(a: number): number;
20
- export function sha256h_new(): number;
21
- export function sha256h_update(a: number, b: number, c: number): void;
22
- export function sha256h_finalize(a: number, b: number): void;
23
- export function sha256h_clone(a: number): number;
24
- export function __wbg_sha256h_free(a: number): void;
25
- export function sha512(a: number, b: number, c: number): void;
26
- export function sha256d(a: number, b: number, c: number): void;
27
- export function sha256(a: number, b: number, c: number): void;
28
- export function shaRmd160(a: number, b: number, c: number): void;
29
- export function publicKeyCryptoVerify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number): void;
30
- export function publicKeyCryptoAlgoSupported(a: number, b: number, c: number, d: number, e: number): void;
31
- export function ecash_secp256k1_context_create(a: number): number;
32
- export function ecash_secp256k1_context_destroy(a: number): void;
33
- export function secp256k1_default_illegal_callback_fn(a: number, b: number): void;
34
- export function secp256k1_default_error_callback_fn(a: number, b: number): void;
35
- export function ring_core_0_17_14__bn_mul_mont(a: number, b: number, c: number, d: number, e: number, f: number): void;
36
- export function __wbg_sha512h_free(a: number): void;
37
- export function __wbindgen_add_to_stack_pointer(a: number): number;
38
- export function __wbindgen_export_0(a: number, b: number): number;
39
- export function __wbindgen_export_1(a: number, b: number, c: number): void;
40
- export function __wbindgen_export_2(a: number, b: number, c: number, d: number): number;
@@ -1,180 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- /**
4
- * Calculate SHA512(data).
5
- * @param {Uint8Array} data
6
- * @returns {Uint8Array}
7
- */
8
- export function sha512(data: Uint8Array): Uint8Array;
9
- /**
10
- * Calculate SHA256(SHA256(data)).
11
- * @param {Uint8Array} data
12
- * @returns {Uint8Array}
13
- */
14
- export function sha256d(data: Uint8Array): Uint8Array;
15
- /**
16
- * Calculate SHA256(data).
17
- * @param {Uint8Array} data
18
- * @returns {Uint8Array}
19
- */
20
- export function sha256(data: Uint8Array): Uint8Array;
21
- /**
22
- * Calculate RIPEMD160(SHA256(data)), commonly used as address hash.
23
- * @param {Uint8Array} data
24
- * @returns {Uint8Array}
25
- */
26
- export function shaRmd160(data: Uint8Array): Uint8Array;
27
- /**
28
- * Verify a signature for the given cryptographic algorithm.
29
- * Intended to be used in X509 certificate verification.
30
- * Throw an exception if the algorithm is not supported.
31
- * @param {string} algo_oid
32
- * @param {string | undefined} params
33
- * @param {Uint8Array} sig
34
- * @param {Uint8Array} msg
35
- * @param {Uint8Array} pk
36
- */
37
- export function publicKeyCryptoVerify(algo_oid: string, params: string | undefined, sig: Uint8Array, msg: Uint8Array, pk: Uint8Array): void;
38
- /**
39
- * Throw an exception if the given algo is not supported, otherwise do nothing.
40
- * @param {string} algo_oid
41
- * @param {string | undefined} [params]
42
- */
43
- export function publicKeyCryptoAlgoSupported(algo_oid: string, params?: string): void;
44
- /**
45
- * ECC signatures with libsecp256k1.
46
- */
47
- export class Ecc {
48
- free(): void;
49
- /**
50
- * Create a new Ecc instance.
51
- */
52
- constructor();
53
- /**
54
- * Derive a public key from secret key.
55
- * @param {Uint8Array} seckey
56
- * @returns {Uint8Array}
57
- */
58
- derivePubkey(seckey: Uint8Array): Uint8Array;
59
- /**
60
- * Sign an ECDSA signature.
61
- * @param {Uint8Array} seckey
62
- * @param {Uint8Array} msg
63
- * @returns {Uint8Array}
64
- */
65
- ecdsaSign(seckey: Uint8Array, msg: Uint8Array): Uint8Array;
66
- /**
67
- * Verify an ECDSA signature.
68
- * @param {Uint8Array} sig
69
- * @param {Uint8Array} msg
70
- * @param {Uint8Array} pk
71
- */
72
- ecdsaVerify(sig: Uint8Array, msg: Uint8Array, pk: Uint8Array): void;
73
- /**
74
- * Sign a Schnorr signature.
75
- * @param {Uint8Array} seckey
76
- * @param {Uint8Array} msg
77
- * @returns {Uint8Array}
78
- */
79
- schnorrSign(seckey: Uint8Array, msg: Uint8Array): Uint8Array;
80
- /**
81
- * Verify a Schnorr signature.
82
- * @param {Uint8Array} sig
83
- * @param {Uint8Array} msg
84
- * @param {Uint8Array} pk
85
- */
86
- schnorrVerify(sig: Uint8Array, msg: Uint8Array, pk: Uint8Array): void;
87
- /**
88
- * Return whether the given secret key is valid, i.e. whether is of correct
89
- * length (32 bytes) and is on the curve.
90
- * @param {Uint8Array} seckey
91
- * @returns {boolean}
92
- */
93
- isValidSeckey(seckey: Uint8Array): boolean;
94
- /**
95
- * Add a scalar to a secret key.
96
- * @param {Uint8Array} a
97
- * @param {Uint8Array} b
98
- * @returns {Uint8Array}
99
- */
100
- seckeyAdd(a: Uint8Array, b: Uint8Array): Uint8Array;
101
- /**
102
- * Add a scalar to a public key (adding G*b).
103
- * @param {Uint8Array} a
104
- * @param {Uint8Array} b
105
- * @returns {Uint8Array}
106
- */
107
- pubkeyAdd(a: Uint8Array, b: Uint8Array): Uint8Array;
108
- /**
109
- * Create a compact ECDSA signature (65 bytes), which allows reconstructing
110
- * the used public key.
111
- * The format is one header byte, followed by two times 32 bytes for the
112
- * serialized r and s values.
113
- * The header byte: 0x1B = first key with even y,
114
- * 0x1C = first key with odd y,
115
- * 0x1D = second key with even y,
116
- * 0x1E = second key with odd y,
117
- * add 0x04 for compressed keys.
118
- * @param {Uint8Array} seckey
119
- * @param {Uint8Array} msg
120
- * @returns {Uint8Array}
121
- */
122
- signRecoverable(seckey: Uint8Array, msg: Uint8Array): Uint8Array;
123
- /**
124
- * Recover the public key of a signature signed by signRecoverable.
125
- * @param {Uint8Array} sig
126
- * @param {Uint8Array} msg
127
- * @returns {Uint8Array}
128
- */
129
- recoverSig(sig: Uint8Array, msg: Uint8Array): Uint8Array;
130
- }
131
- /**
132
- * Instance to calculate SHA256 in a streaming fashion
133
- */
134
- export class Sha256H {
135
- free(): void;
136
- /**
137
- * Create new hasher instance
138
- */
139
- constructor();
140
- /**
141
- * Feed bytes into the hasher
142
- * @param {Uint8Array} data
143
- */
144
- update(data: Uint8Array): void;
145
- /**
146
- * Finalize the hash and return the result
147
- * @returns {Uint8Array}
148
- */
149
- finalize(): Uint8Array;
150
- /**
151
- * Clone the hasher
152
- * @returns {Sha256H}
153
- */
154
- clone(): Sha256H;
155
- }
156
- /**
157
- * Instance to calculate SHA512 in a streaming fashion
158
- */
159
- export class Sha512H {
160
- free(): void;
161
- /**
162
- * Create new hasher instance
163
- */
164
- constructor();
165
- /**
166
- * Feed bytes into the hasher
167
- * @param {Uint8Array} data
168
- */
169
- update(data: Uint8Array): void;
170
- /**
171
- * Finalize the hash and return the result
172
- * @returns {Uint8Array}
173
- */
174
- finalize(): Uint8Array;
175
- /**
176
- * Clone the hasher
177
- * @returns {Sha512H}
178
- */
179
- clone(): Sha512H;
180
- }