ecash-lib 1.2.2-rc9 → 1.4.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.
- package/README.md +2 -1
- package/dist/ecc.d.ts +12 -0
- package/dist/ecc.d.ts.map +1 -1
- package/dist/ecc.js +9 -47
- package/dist/ecc.js.map +1 -1
- package/dist/ffi/ecash_lib_wasm_bg_browser.wasm +0 -0
- package/dist/ffi/ecash_lib_wasm_bg_browser.wasm.d.ts +18 -4
- package/dist/ffi/ecash_lib_wasm_bg_nodejs.wasm +0 -0
- package/dist/ffi/ecash_lib_wasm_bg_nodejs.wasm.d.ts +18 -4
- package/dist/ffi/ecash_lib_wasm_browser.d.ts +95 -4
- package/dist/ffi/ecash_lib_wasm_browser.js +245 -14
- package/dist/ffi/ecash_lib_wasm_nodejs.d.ts +77 -0
- package/dist/ffi/ecash_lib_wasm_nodejs.js +247 -14
- package/dist/hash.d.ts +21 -1
- package/dist/hash.d.ts.map +1 -1
- package/dist/hash.js +16 -10
- package/dist/hash.js.map +1 -1
- package/dist/hdwallet.d.ts +33 -0
- package/dist/hdwallet.d.ts.map +1 -0
- package/dist/hdwallet.js +148 -0
- package/dist/hdwallet.js.map +1 -0
- package/dist/hmac.d.ts +13 -0
- package/dist/hmac.d.ts.map +1 -0
- package/dist/hmac.js +63 -0
- package/dist/hmac.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/initBrowser.d.ts.map +1 -1
- package/dist/initBrowser.js +3 -0
- package/dist/initBrowser.js.map +1 -1
- package/dist/initNodeJs.d.ts.map +1 -1
- package/dist/initNodeJs.js +3 -0
- package/dist/initNodeJs.js.map +1 -1
- package/dist/io/bytes.d.ts +5 -3
- package/dist/io/bytes.d.ts.map +1 -1
- package/dist/io/bytes.js +15 -7
- package/dist/io/bytes.js.map +1 -1
- package/dist/io/writer.d.ts +4 -3
- package/dist/io/writer.d.ts.map +1 -1
- package/dist/io/writerbytes.d.ts +4 -3
- package/dist/io/writerbytes.d.ts.map +1 -1
- package/dist/io/writerbytes.js +7 -6
- package/dist/io/writerbytes.js.map +1 -1
- package/dist/io/writerlength.d.ts +4 -3
- package/dist/io/writerlength.d.ts.map +1 -1
- package/dist/io/writerlength.js +3 -3
- package/dist/io/writerlength.js.map +1 -1
- package/dist/mnemonic.d.ts +14 -0
- package/dist/mnemonic.d.ts.map +1 -0
- package/dist/mnemonic.js +123 -0
- package/dist/mnemonic.js.map +1 -0
- package/dist/pbkdf2.d.ts +11 -0
- package/dist/pbkdf2.d.ts.map +1 -0
- package/dist/pbkdf2.js +36 -0
- package/dist/pbkdf2.js.map +1 -0
- package/dist/script.d.ts +4 -0
- package/dist/script.d.ts.map +1 -1
- package/dist/script.js +6 -0
- package/dist/script.js.map +1 -1
- package/package.json +1 -1
- package/src/address/address.ts +346 -0
- package/src/address/legacyaddr.ts +129 -0
- package/src/consts.ts +8 -0
- package/src/ecc.ts +61 -0
- package/src/ffi/ecash_lib_wasm_bg_browser.wasm +0 -0
- package/src/ffi/ecash_lib_wasm_bg_browser.wasm.d.ts +32 -0
- package/src/ffi/ecash_lib_wasm_bg_nodejs.wasm +0 -0
- package/src/ffi/ecash_lib_wasm_bg_nodejs.wasm.d.ts +32 -0
- package/src/ffi/ecash_lib_wasm_browser.d.ts +183 -0
- package/src/ffi/ecash_lib_wasm_browser.js +571 -0
- package/src/ffi/ecash_lib_wasm_nodejs.d.ts +127 -0
- package/src/ffi/ecash_lib_wasm_nodejs.js +498 -0
- package/src/hash.ts +46 -0
- package/src/hdwallet.ts +181 -0
- package/src/hmac.ts +74 -0
- package/src/index.ts +29 -0
- package/src/indexBrowser.ts +6 -0
- package/src/indexNodeJs.ts +6 -0
- package/src/initBrowser.ts +21 -0
- package/src/initNodeJs.ts +20 -0
- package/src/io/bytes.ts +80 -0
- package/src/io/hex.ts +69 -0
- package/src/io/int.ts +6 -0
- package/src/io/str.ts +16 -0
- package/src/io/varsize.ts +49 -0
- package/src/io/writer.ts +20 -0
- package/src/io/writerbytes.ts +87 -0
- package/src/io/writerlength.ts +44 -0
- package/src/mnemonic.ts +153 -0
- package/src/op.ts +162 -0
- package/src/opcode.ts +154 -0
- package/src/pbkdf2.ts +52 -0
- package/src/script.ts +195 -0
- package/src/sigHashType.ts +190 -0
- package/src/test/testRunner.ts +209 -0
- package/src/token/alp.ts +146 -0
- package/src/token/common.ts +32 -0
- package/src/token/empp.ts +29 -0
- package/src/token/slp.ts +212 -0
- package/src/tx.ts +180 -0
- package/src/txBuilder.ts +262 -0
- package/src/unsignedTx.ts +359 -0
- package/tsconfig.json +2 -1
- package/wordlists/english.json +2053 -0
- package/.nyc_output/0fc40ca6-d52c-45eb-b31b-2601ce70b887.json +0 -1
- package/.nyc_output/ac5be6db-4e40-41f8-8b84-7598d4747e57.json +0 -1
- package/.nyc_output/b316d46f-5ea0-4e98-884a-bfbf9cc1d0f8.json +0 -1
- package/.nyc_output/f965566b-9422-4874-b45e-9eefda9c769c.json +0 -1
- package/.nyc_output/processinfo/0fc40ca6-d52c-45eb-b31b-2601ce70b887.json +0 -1
- package/.nyc_output/processinfo/ac5be6db-4e40-41f8-8b84-7598d4747e57.json +0 -1
- package/.nyc_output/processinfo/b316d46f-5ea0-4e98-884a-bfbf9cc1d0f8.json +0 -1
- package/.nyc_output/processinfo/f965566b-9422-4874-b45e-9eefda9c769c.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
- package/dist/address/cashaddr.d.ts +0 -78
- package/dist/address/cashaddr.d.ts.map +0 -1
- package/dist/address/cashaddr.js +0 -543
- package/dist/address/cashaddr.js.map +0 -1
- package/dist/cashaddr/cashaddr.d.ts +0 -23
- package/dist/cashaddr/cashaddr.d.ts.map +0 -1
- package/dist/cashaddr/cashaddr.js +0 -325
- package/dist/cashaddr/cashaddr.js.map +0 -1
- package/global.d.ts +0 -64
- package/test.log +0 -82
package/README.md
CHANGED
|
@@ -107,4 +107,5 @@ console.log(toHex(rawTx));
|
|
|
107
107
|
- 1.1.0 - Add support for the original pre-UAHF Bitcoin signatures, so we can sign transactions for other blockchains like BTC/DOGE/... [D17255](https://reviews.bitcoinabc.org/D17255)
|
|
108
108
|
- 1.2.0 - Add `Address` class for cashaddr and legacy addresses. [D17269](https://reviews.bitcoinabc.org/D17269)
|
|
109
109
|
- 1.2.1 - Patch type check causing txBuilder txs using change to fail in NodeJS environments [D17461](https://reviews.bitcoinabc.org/D17461)
|
|
110
|
-
- 1.
|
|
110
|
+
- 1.3.0 - Add `toHex()` method to `Script` to allow simple conversion to hex string [D17527](https://reviews.bitcoinabc.org/D17527)
|
|
111
|
+
- 1.4.0 - Add `HdNode`, `entropyToMnemonic`, `mnemonicToEntropy` and `mnemonicToSeed` to complete wallet functionality [D17619](https://reviews.bitcoinabc.org/D17619)
|
package/dist/ecc.d.ts
CHANGED
|
@@ -6,6 +6,15 @@ export interface Ecc {
|
|
|
6
6
|
ecdsaSign(seckey: Uint8Array, msg: Uint8Array): Uint8Array;
|
|
7
7
|
/** Sign a Schnorr signature. msg needs to be a 32-byte hash */
|
|
8
8
|
schnorrSign(seckey: Uint8Array, msg: Uint8Array): Uint8Array;
|
|
9
|
+
/**
|
|
10
|
+
* Return whether the given secret key is valid, i.e. whether is of correct
|
|
11
|
+
* length (32 bytes) and is on the curve.
|
|
12
|
+
*/
|
|
13
|
+
isValidSeckey(seckey: Uint8Array): boolean;
|
|
14
|
+
/** Add a scalar to a secret key */
|
|
15
|
+
seckeyAdd(a: Uint8Array, b: Uint8Array): Uint8Array;
|
|
16
|
+
/** Add a scalar to a public key (adding G*b) */
|
|
17
|
+
pubkeyAdd(a: Uint8Array, b: Uint8Array): Uint8Array;
|
|
9
18
|
}
|
|
10
19
|
/** Ecc implementation using WebAssembly */
|
|
11
20
|
export declare let Ecc: {
|
|
@@ -16,6 +25,9 @@ export declare class EccDummy implements Ecc {
|
|
|
16
25
|
derivePubkey(_seckey: Uint8Array): Uint8Array;
|
|
17
26
|
ecdsaSign(_seckey: Uint8Array, _msg: Uint8Array): Uint8Array;
|
|
18
27
|
schnorrSign(_seckey: Uint8Array, _msg: Uint8Array): Uint8Array;
|
|
28
|
+
isValidSeckey(_seckey: Uint8Array): boolean;
|
|
29
|
+
seckeyAdd(_a: Uint8Array, _b: Uint8Array): Uint8Array;
|
|
30
|
+
pubkeyAdd(_a: Uint8Array, _b: Uint8Array): Uint8Array;
|
|
19
31
|
}
|
|
20
32
|
export declare function __setEcc(ecc: {
|
|
21
33
|
new (): Ecc;
|
package/dist/ecc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecc.d.ts","sourceRoot":"","sources":["../src/ecc.ts"],"names":[],"mappings":"AAIA,6DAA6D;AAC7D,MAAM,WAAW,GAAG;IAChB,2CAA2C;IAC3C,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC;IAE7C,8DAA8D;IAC9D,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,GAAG,UAAU,CAAC;IAE3D,+DAA+D;IAC/D,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,GAAG,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"ecc.d.ts","sourceRoot":"","sources":["../src/ecc.ts"],"names":[],"mappings":"AAIA,6DAA6D;AAC7D,MAAM,WAAW,GAAG;IAChB,2CAA2C;IAC3C,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC;IAE7C,8DAA8D;IAC9D,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,GAAG,UAAU,CAAC;IAE3D,+DAA+D;IAC/D,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,GAAG,UAAU,CAAC;IAE7D;;;OAGG;IACH,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC;IAE3C,mCAAmC;IACnC,SAAS,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IAEpD,gDAAgD;IAChD,SAAS,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;CACvD;AAED,2CAA2C;AAC3C,eAAO,IAAI,GAAG,EAAE;IAAE,QAAQ,GAAG,CAAA;CAAE,CAAC;AAEhC,yEAAyE;AACzE,qBAAa,QAAS,YAAW,GAAG;IAChC,YAAY,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU;IAI7C,SAAS,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,GAAG,UAAU;IAI5D,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,GAAG,UAAU;IAI9D,aAAa,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO;IAI3C,SAAS,CAAC,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,GAAG,UAAU;IAIrD,SAAS,CAAC,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,GAAG,UAAU;CAGxD;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE;IAAE,QAAQ,GAAG,CAAA;CAAE,QAE5C"}
|
package/dist/ecc.js
CHANGED
|
@@ -4,24 +4,6 @@
|
|
|
4
4
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.__setEcc = exports.EccDummy = exports.Ecc = void 0;
|
|
7
|
-
/** Ecc implementation using WebAssembly */
|
|
8
|
-
let Ecc = class {
|
|
9
|
-
constructor() {
|
|
10
|
-
if (!exports.Ecc.prototype.derivePubkey) {
|
|
11
|
-
throw new Error('Ecc not initialized. Call initWasm first.');
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
derivePubkey(_seckey) {
|
|
15
|
-
throw new Error('Ecc not initialized. Call initWasm first.');
|
|
16
|
-
}
|
|
17
|
-
ecdsaSign(_seckey, _msg) {
|
|
18
|
-
throw new Error('Ecc not initialized. Call initWasm first.');
|
|
19
|
-
}
|
|
20
|
-
schnorrSign(_seckey, _msg) {
|
|
21
|
-
throw new Error('Ecc not initialized. Call initWasm first.');
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
exports.Ecc = Ecc;
|
|
25
7
|
/** Dummy Ecc impl that always returns 0, useful for measuring tx size */
|
|
26
8
|
class EccDummy {
|
|
27
9
|
derivePubkey(_seckey) {
|
|
@@ -33,39 +15,19 @@ class EccDummy {
|
|
|
33
15
|
schnorrSign(_seckey, _msg) {
|
|
34
16
|
return new Uint8Array(64);
|
|
35
17
|
}
|
|
18
|
+
isValidSeckey(_seckey) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
seckeyAdd(_a, _b) {
|
|
22
|
+
return new Uint8Array(32);
|
|
23
|
+
}
|
|
24
|
+
pubkeyAdd(_a, _b) {
|
|
25
|
+
return new Uint8Array(32);
|
|
26
|
+
}
|
|
36
27
|
}
|
|
37
28
|
exports.EccDummy = EccDummy;
|
|
38
|
-
// Now update Ecc to use globalThis for external access (if available)
|
|
39
|
-
// We use a getter because installing libs could reference Ecc here even after
|
|
40
|
-
// initWasm() due to module caching
|
|
41
|
-
Object.defineProperty(exports, 'Ecc', {
|
|
42
|
-
get: () => {
|
|
43
|
-
return (globalThis.ecashlib?.Ecc || exports.Ecc);
|
|
44
|
-
},
|
|
45
|
-
set: value => {
|
|
46
|
-
exports.Ecc = value;
|
|
47
|
-
if (globalThis.ecashlib) {
|
|
48
|
-
globalThis.ecashlib.Ecc = value;
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
Object.assign(globalThis, {
|
|
52
|
-
ecashlib: {
|
|
53
|
-
...(globalThis.ecashlib || {}),
|
|
54
|
-
Ecc: value,
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
configurable: true, // Allows for future modification
|
|
60
|
-
});
|
|
61
29
|
function __setEcc(ecc) {
|
|
62
30
|
exports.Ecc = ecc;
|
|
63
|
-
Object.assign(globalThis, {
|
|
64
|
-
ecashlib: {
|
|
65
|
-
...(globalThis.ecashlib || {}),
|
|
66
|
-
Ecc: ecc,
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
31
|
}
|
|
70
32
|
exports.__setEcc = __setEcc;
|
|
71
33
|
//# sourceMappingURL=ecc.js.map
|
package/dist/ecc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecc.js","sourceRoot":"","sources":["../src/ecc.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,mEAAmE;AACnE,sEAAsE;;;
|
|
1
|
+
{"version":3,"file":"ecc.js","sourceRoot":"","sources":["../src/ecc.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,mEAAmE;AACnE,sEAAsE;;;AA6BtE,yEAAyE;AACzE,MAAa,QAAQ;IACjB,YAAY,CAAC,OAAmB;QAC5B,OAAO,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED,SAAS,CAAC,OAAmB,EAAE,IAAgB;QAC3C,OAAO,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED,WAAW,CAAC,OAAmB,EAAE,IAAgB;QAC7C,OAAO,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED,aAAa,CAAC,OAAmB;QAC7B,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,SAAS,CAAC,EAAc,EAAE,EAAc;QACpC,OAAO,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED,SAAS,CAAC,EAAc,EAAE,EAAc;QACpC,OAAO,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;CACJ;AAxBD,4BAwBC;AAED,SAAgB,QAAQ,CAAC,GAAoB;IACzC,WAAG,GAAG,GAAG,CAAC;AACd,CAAC;AAFD,4BAEC"}
|
|
Binary file
|
|
@@ -1,18 +1,32 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
+
export function sha512h_new(): number;
|
|
5
|
+
export function sha512h_update(a: number, b: number, c: number): void;
|
|
6
|
+
export function sha512h_finalize(a: number, b: number): void;
|
|
7
|
+
export function sha512h_clone(a: number): number;
|
|
8
|
+
export function sha256h_new(): number;
|
|
9
|
+
export function sha256h_update(a: number, b: number, c: number): void;
|
|
10
|
+
export function sha256h_finalize(a: number, b: number): void;
|
|
11
|
+
export function sha256h_clone(a: number): number;
|
|
12
|
+
export function __wbg_sha256h_free(a: number): void;
|
|
13
|
+
export function sha512(a: number, b: number, c: number): void;
|
|
14
|
+
export function sha256d(a: number, b: number, c: number): void;
|
|
15
|
+
export function sha256(a: number, b: number, c: number): void;
|
|
16
|
+
export function shaRmd160(a: number, b: number, c: number): void;
|
|
4
17
|
export function ecc_new(): number;
|
|
5
18
|
export function ecc_derivePubkey(a: number, b: number, c: number, d: number): void;
|
|
6
19
|
export function ecc_ecdsaSign(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
|
7
20
|
export function ecc_schnorrSign(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
|
21
|
+
export function ecc_isValidSeckey(a: number, b: number, c: number): number;
|
|
22
|
+
export function ecc_seckeyAdd(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
|
23
|
+
export function ecc_pubkeyAdd(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
|
8
24
|
export function __wbg_ecc_free(a: number): void;
|
|
9
|
-
export function sha256d(a: number, b: number, c: number): void;
|
|
10
|
-
export function sha256(a: number, b: number, c: number): void;
|
|
11
|
-
export function shaRmd160(a: number, b: number, c: number): void;
|
|
12
25
|
export function ecash_secp256k1_context_create(a: number): number;
|
|
13
26
|
export function ecash_secp256k1_context_destroy(a: number): void;
|
|
14
27
|
export function secp256k1_default_illegal_callback_fn(a: number, b: number): void;
|
|
15
28
|
export function secp256k1_default_error_callback_fn(a: number, b: number): void;
|
|
16
|
-
export function
|
|
29
|
+
export function __wbg_sha512h_free(a: number): void;
|
|
17
30
|
export function __wbindgen_export_0(a: number, b: number): number;
|
|
31
|
+
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
|
18
32
|
export function __wbindgen_export_1(a: number, b: number, c: number): void;
|
|
Binary file
|
|
@@ -1,18 +1,32 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
+
export function sha512h_new(): number;
|
|
5
|
+
export function sha512h_update(a: number, b: number, c: number): void;
|
|
6
|
+
export function sha512h_finalize(a: number, b: number): void;
|
|
7
|
+
export function sha512h_clone(a: number): number;
|
|
8
|
+
export function sha256h_new(): number;
|
|
9
|
+
export function sha256h_update(a: number, b: number, c: number): void;
|
|
10
|
+
export function sha256h_finalize(a: number, b: number): void;
|
|
11
|
+
export function sha256h_clone(a: number): number;
|
|
12
|
+
export function __wbg_sha256h_free(a: number): void;
|
|
13
|
+
export function sha512(a: number, b: number, c: number): void;
|
|
14
|
+
export function sha256d(a: number, b: number, c: number): void;
|
|
15
|
+
export function sha256(a: number, b: number, c: number): void;
|
|
16
|
+
export function shaRmd160(a: number, b: number, c: number): void;
|
|
4
17
|
export function ecc_new(): number;
|
|
5
18
|
export function ecc_derivePubkey(a: number, b: number, c: number, d: number): void;
|
|
6
19
|
export function ecc_ecdsaSign(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
|
7
20
|
export function ecc_schnorrSign(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
|
21
|
+
export function ecc_isValidSeckey(a: number, b: number, c: number): number;
|
|
22
|
+
export function ecc_seckeyAdd(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
|
23
|
+
export function ecc_pubkeyAdd(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
|
8
24
|
export function __wbg_ecc_free(a: number): void;
|
|
9
|
-
export function sha256d(a: number, b: number, c: number): void;
|
|
10
|
-
export function sha256(a: number, b: number, c: number): void;
|
|
11
|
-
export function shaRmd160(a: number, b: number, c: number): void;
|
|
12
25
|
export function ecash_secp256k1_context_create(a: number): number;
|
|
13
26
|
export function ecash_secp256k1_context_destroy(a: number): void;
|
|
14
27
|
export function secp256k1_default_illegal_callback_fn(a: number, b: number): void;
|
|
15
28
|
export function secp256k1_default_error_callback_fn(a: number, b: number): void;
|
|
16
|
-
export function
|
|
29
|
+
export function __wbg_sha512h_free(a: number): void;
|
|
17
30
|
export function __wbindgen_export_0(a: number, b: number): number;
|
|
31
|
+
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
|
18
32
|
export function __wbindgen_export_1(a: number, b: number, c: number): void;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
/**
|
|
4
|
+
* Calculate SHA512(data).
|
|
5
|
+
* @param {Uint8Array} data
|
|
6
|
+
* @returns {Uint8Array}
|
|
7
|
+
*/
|
|
8
|
+
export function sha512(data: Uint8Array): Uint8Array;
|
|
9
|
+
/**
|
|
4
10
|
* Calculate SHA256(SHA256(data)).
|
|
5
11
|
* @param {Uint8Array} data
|
|
6
12
|
* @returns {Uint8Array}
|
|
@@ -47,26 +53,111 @@ export class Ecc {
|
|
|
47
53
|
* @returns {Uint8Array}
|
|
48
54
|
*/
|
|
49
55
|
schnorrSign(seckey: Uint8Array, msg: Uint8Array): Uint8Array;
|
|
56
|
+
/**
|
|
57
|
+
* Return whether the given secret key is valid, i.e. whether is of correct
|
|
58
|
+
* length (32 bytes) and is on the curve.
|
|
59
|
+
* @param {Uint8Array} seckey
|
|
60
|
+
* @returns {boolean}
|
|
61
|
+
*/
|
|
62
|
+
isValidSeckey(seckey: Uint8Array): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Add a scalar to a secret key.
|
|
65
|
+
* @param {Uint8Array} a
|
|
66
|
+
* @param {Uint8Array} b
|
|
67
|
+
* @returns {Uint8Array}
|
|
68
|
+
*/
|
|
69
|
+
seckeyAdd(a: Uint8Array, b: Uint8Array): Uint8Array;
|
|
70
|
+
/**
|
|
71
|
+
* Add a scalar to a public key (adding G*b).
|
|
72
|
+
* @param {Uint8Array} a
|
|
73
|
+
* @param {Uint8Array} b
|
|
74
|
+
* @returns {Uint8Array}
|
|
75
|
+
*/
|
|
76
|
+
pubkeyAdd(a: Uint8Array, b: Uint8Array): Uint8Array;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Instance to calculate SHA256 in a streaming fashion
|
|
80
|
+
*/
|
|
81
|
+
export class Sha256H {
|
|
82
|
+
free(): void;
|
|
83
|
+
/**
|
|
84
|
+
* Create new hasher instance
|
|
85
|
+
*/
|
|
86
|
+
constructor();
|
|
87
|
+
/**
|
|
88
|
+
* Feed bytes into the hasher
|
|
89
|
+
* @param {Uint8Array} data
|
|
90
|
+
*/
|
|
91
|
+
update(data: Uint8Array): void;
|
|
92
|
+
/**
|
|
93
|
+
* Finalize the hash and return the result
|
|
94
|
+
* @returns {Uint8Array}
|
|
95
|
+
*/
|
|
96
|
+
finalize(): Uint8Array;
|
|
97
|
+
/**
|
|
98
|
+
* Clone the hasher
|
|
99
|
+
* @returns {Sha256H}
|
|
100
|
+
*/
|
|
101
|
+
clone(): Sha256H;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Instance to calculate SHA512 in a streaming fashion
|
|
105
|
+
*/
|
|
106
|
+
export class Sha512H {
|
|
107
|
+
free(): void;
|
|
108
|
+
/**
|
|
109
|
+
* Create new hasher instance
|
|
110
|
+
*/
|
|
111
|
+
constructor();
|
|
112
|
+
/**
|
|
113
|
+
* Feed bytes into the hasher
|
|
114
|
+
* @param {Uint8Array} data
|
|
115
|
+
*/
|
|
116
|
+
update(data: Uint8Array): void;
|
|
117
|
+
/**
|
|
118
|
+
* Finalize the hash and return the result
|
|
119
|
+
* @returns {Uint8Array}
|
|
120
|
+
*/
|
|
121
|
+
finalize(): Uint8Array;
|
|
122
|
+
/**
|
|
123
|
+
* Clone the hasher
|
|
124
|
+
* @returns {Sha512H}
|
|
125
|
+
*/
|
|
126
|
+
clone(): Sha512H;
|
|
50
127
|
}
|
|
51
128
|
|
|
52
129
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
53
130
|
|
|
54
131
|
export interface InitOutput {
|
|
55
132
|
readonly memory: WebAssembly.Memory;
|
|
133
|
+
readonly sha512h_new: () => number;
|
|
134
|
+
readonly sha512h_update: (a: number, b: number, c: number) => void;
|
|
135
|
+
readonly sha512h_finalize: (a: number, b: number) => void;
|
|
136
|
+
readonly sha512h_clone: (a: number) => number;
|
|
137
|
+
readonly sha256h_new: () => number;
|
|
138
|
+
readonly sha256h_update: (a: number, b: number, c: number) => void;
|
|
139
|
+
readonly sha256h_finalize: (a: number, b: number) => void;
|
|
140
|
+
readonly sha256h_clone: (a: number) => number;
|
|
141
|
+
readonly __wbg_sha256h_free: (a: number) => void;
|
|
142
|
+
readonly sha512: (a: number, b: number, c: number) => void;
|
|
143
|
+
readonly sha256d: (a: number, b: number, c: number) => void;
|
|
144
|
+
readonly sha256: (a: number, b: number, c: number) => void;
|
|
145
|
+
readonly shaRmd160: (a: number, b: number, c: number) => void;
|
|
56
146
|
readonly ecc_new: () => number;
|
|
57
147
|
readonly ecc_derivePubkey: (a: number, b: number, c: number, d: number) => void;
|
|
58
148
|
readonly ecc_ecdsaSign: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
59
149
|
readonly ecc_schnorrSign: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
150
|
+
readonly ecc_isValidSeckey: (a: number, b: number, c: number) => number;
|
|
151
|
+
readonly ecc_seckeyAdd: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
152
|
+
readonly ecc_pubkeyAdd: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
60
153
|
readonly __wbg_ecc_free: (a: number) => void;
|
|
61
|
-
readonly sha256d: (a: number, b: number, c: number) => void;
|
|
62
|
-
readonly sha256: (a: number, b: number, c: number) => void;
|
|
63
|
-
readonly shaRmd160: (a: number, b: number, c: number) => void;
|
|
64
154
|
readonly ecash_secp256k1_context_create: (a: number) => number;
|
|
65
155
|
readonly ecash_secp256k1_context_destroy: (a: number) => void;
|
|
66
156
|
readonly secp256k1_default_illegal_callback_fn: (a: number, b: number) => void;
|
|
67
157
|
readonly secp256k1_default_error_callback_fn: (a: number, b: number) => void;
|
|
68
|
-
readonly
|
|
158
|
+
readonly __wbg_sha512h_free: (a: number) => void;
|
|
69
159
|
readonly __wbindgen_export_0: (a: number, b: number) => number;
|
|
160
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
70
161
|
readonly __wbindgen_export_1: (a: number, b: number, c: number) => void;
|
|
71
162
|
}
|
|
72
163
|
|
|
@@ -51,24 +51,31 @@ function getInt32Memory0() {
|
|
|
51
51
|
return cachedInt32Memory0;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
function getObject(idx) { return heap[idx]; }
|
|
55
|
-
|
|
56
|
-
function dropObject(idx) {
|
|
57
|
-
if (idx < 132) return;
|
|
58
|
-
heap[idx] = heap_next;
|
|
59
|
-
heap_next = idx;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function takeObject(idx) {
|
|
63
|
-
const ret = getObject(idx);
|
|
64
|
-
dropObject(idx);
|
|
65
|
-
return ret;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
54
|
function getArrayU8FromWasm0(ptr, len) {
|
|
69
55
|
ptr = ptr >>> 0;
|
|
70
56
|
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
71
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Calculate SHA512(data).
|
|
60
|
+
* @param {Uint8Array} data
|
|
61
|
+
* @returns {Uint8Array}
|
|
62
|
+
*/
|
|
63
|
+
export function sha512(data) {
|
|
64
|
+
try {
|
|
65
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
66
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export_0);
|
|
67
|
+
const len0 = WASM_VECTOR_LEN;
|
|
68
|
+
wasm.sha512(retptr, ptr0, len0);
|
|
69
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
70
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
71
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
72
|
+
wasm.__wbindgen_export_1(r0, r1 * 1, 1);
|
|
73
|
+
return v2;
|
|
74
|
+
} finally {
|
|
75
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
72
79
|
/**
|
|
73
80
|
* Calculate SHA256(SHA256(data)).
|
|
74
81
|
* @param {Uint8Array} data
|
|
@@ -132,6 +139,20 @@ export function shaRmd160(data) {
|
|
|
132
139
|
}
|
|
133
140
|
}
|
|
134
141
|
|
|
142
|
+
function getObject(idx) { return heap[idx]; }
|
|
143
|
+
|
|
144
|
+
function dropObject(idx) {
|
|
145
|
+
if (idx < 132) return;
|
|
146
|
+
heap[idx] = heap_next;
|
|
147
|
+
heap_next = idx;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function takeObject(idx) {
|
|
151
|
+
const ret = getObject(idx);
|
|
152
|
+
dropObject(idx);
|
|
153
|
+
return ret;
|
|
154
|
+
}
|
|
155
|
+
|
|
135
156
|
const EccFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
136
157
|
? { register: () => {}, unregister: () => {} }
|
|
137
158
|
: new FinalizationRegistry(ptr => wasm.__wbg_ecc_free(ptr >>> 0));
|
|
@@ -240,6 +261,216 @@ export class Ecc {
|
|
|
240
261
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
241
262
|
}
|
|
242
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* Return whether the given secret key is valid, i.e. whether is of correct
|
|
266
|
+
* length (32 bytes) and is on the curve.
|
|
267
|
+
* @param {Uint8Array} seckey
|
|
268
|
+
* @returns {boolean}
|
|
269
|
+
*/
|
|
270
|
+
isValidSeckey(seckey) {
|
|
271
|
+
const ptr0 = passArray8ToWasm0(seckey, wasm.__wbindgen_export_0);
|
|
272
|
+
const len0 = WASM_VECTOR_LEN;
|
|
273
|
+
const ret = wasm.ecc_isValidSeckey(this.__wbg_ptr, ptr0, len0);
|
|
274
|
+
return ret !== 0;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Add a scalar to a secret key.
|
|
278
|
+
* @param {Uint8Array} a
|
|
279
|
+
* @param {Uint8Array} b
|
|
280
|
+
* @returns {Uint8Array}
|
|
281
|
+
*/
|
|
282
|
+
seckeyAdd(a, b) {
|
|
283
|
+
try {
|
|
284
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
285
|
+
const ptr0 = passArray8ToWasm0(a, wasm.__wbindgen_export_0);
|
|
286
|
+
const len0 = WASM_VECTOR_LEN;
|
|
287
|
+
const ptr1 = passArray8ToWasm0(b, wasm.__wbindgen_export_0);
|
|
288
|
+
const len1 = WASM_VECTOR_LEN;
|
|
289
|
+
wasm.ecc_seckeyAdd(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
290
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
291
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
292
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
293
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
294
|
+
if (r3) {
|
|
295
|
+
throw takeObject(r2);
|
|
296
|
+
}
|
|
297
|
+
var v3 = getArrayU8FromWasm0(r0, r1).slice();
|
|
298
|
+
wasm.__wbindgen_export_1(r0, r1 * 1, 1);
|
|
299
|
+
return v3;
|
|
300
|
+
} finally {
|
|
301
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Add a scalar to a public key (adding G*b).
|
|
306
|
+
* @param {Uint8Array} a
|
|
307
|
+
* @param {Uint8Array} b
|
|
308
|
+
* @returns {Uint8Array}
|
|
309
|
+
*/
|
|
310
|
+
pubkeyAdd(a, b) {
|
|
311
|
+
try {
|
|
312
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
313
|
+
const ptr0 = passArray8ToWasm0(a, wasm.__wbindgen_export_0);
|
|
314
|
+
const len0 = WASM_VECTOR_LEN;
|
|
315
|
+
const ptr1 = passArray8ToWasm0(b, wasm.__wbindgen_export_0);
|
|
316
|
+
const len1 = WASM_VECTOR_LEN;
|
|
317
|
+
wasm.ecc_pubkeyAdd(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
318
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
319
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
320
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
321
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
322
|
+
if (r3) {
|
|
323
|
+
throw takeObject(r2);
|
|
324
|
+
}
|
|
325
|
+
var v3 = getArrayU8FromWasm0(r0, r1).slice();
|
|
326
|
+
wasm.__wbindgen_export_1(r0, r1 * 1, 1);
|
|
327
|
+
return v3;
|
|
328
|
+
} finally {
|
|
329
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const Sha256HFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
335
|
+
? { register: () => {}, unregister: () => {} }
|
|
336
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_sha256h_free(ptr >>> 0));
|
|
337
|
+
/**
|
|
338
|
+
* Instance to calculate SHA256 in a streaming fashion
|
|
339
|
+
*/
|
|
340
|
+
export class Sha256H {
|
|
341
|
+
|
|
342
|
+
static __wrap(ptr) {
|
|
343
|
+
ptr = ptr >>> 0;
|
|
344
|
+
const obj = Object.create(Sha256H.prototype);
|
|
345
|
+
obj.__wbg_ptr = ptr;
|
|
346
|
+
Sha256HFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
347
|
+
return obj;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
__destroy_into_raw() {
|
|
351
|
+
const ptr = this.__wbg_ptr;
|
|
352
|
+
this.__wbg_ptr = 0;
|
|
353
|
+
Sha256HFinalization.unregister(this);
|
|
354
|
+
return ptr;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
free() {
|
|
358
|
+
const ptr = this.__destroy_into_raw();
|
|
359
|
+
wasm.__wbg_sha256h_free(ptr);
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Create new hasher instance
|
|
363
|
+
*/
|
|
364
|
+
constructor() {
|
|
365
|
+
const ret = wasm.sha256h_new();
|
|
366
|
+
this.__wbg_ptr = ret >>> 0;
|
|
367
|
+
return this;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Feed bytes into the hasher
|
|
371
|
+
* @param {Uint8Array} data
|
|
372
|
+
*/
|
|
373
|
+
update(data) {
|
|
374
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export_0);
|
|
375
|
+
const len0 = WASM_VECTOR_LEN;
|
|
376
|
+
wasm.sha256h_update(this.__wbg_ptr, ptr0, len0);
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Finalize the hash and return the result
|
|
380
|
+
* @returns {Uint8Array}
|
|
381
|
+
*/
|
|
382
|
+
finalize() {
|
|
383
|
+
try {
|
|
384
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
385
|
+
wasm.sha256h_finalize(retptr, this.__wbg_ptr);
|
|
386
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
387
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
388
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
389
|
+
wasm.__wbindgen_export_1(r0, r1 * 1, 1);
|
|
390
|
+
return v1;
|
|
391
|
+
} finally {
|
|
392
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Clone the hasher
|
|
397
|
+
* @returns {Sha256H}
|
|
398
|
+
*/
|
|
399
|
+
clone() {
|
|
400
|
+
const ret = wasm.sha256h_clone(this.__wbg_ptr);
|
|
401
|
+
return Sha256H.__wrap(ret);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
const Sha512HFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
406
|
+
? { register: () => {}, unregister: () => {} }
|
|
407
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_sha512h_free(ptr >>> 0));
|
|
408
|
+
/**
|
|
409
|
+
* Instance to calculate SHA512 in a streaming fashion
|
|
410
|
+
*/
|
|
411
|
+
export class Sha512H {
|
|
412
|
+
|
|
413
|
+
static __wrap(ptr) {
|
|
414
|
+
ptr = ptr >>> 0;
|
|
415
|
+
const obj = Object.create(Sha512H.prototype);
|
|
416
|
+
obj.__wbg_ptr = ptr;
|
|
417
|
+
Sha512HFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
418
|
+
return obj;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
__destroy_into_raw() {
|
|
422
|
+
const ptr = this.__wbg_ptr;
|
|
423
|
+
this.__wbg_ptr = 0;
|
|
424
|
+
Sha512HFinalization.unregister(this);
|
|
425
|
+
return ptr;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
free() {
|
|
429
|
+
const ptr = this.__destroy_into_raw();
|
|
430
|
+
wasm.__wbg_sha512h_free(ptr);
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Create new hasher instance
|
|
434
|
+
*/
|
|
435
|
+
constructor() {
|
|
436
|
+
const ret = wasm.sha512h_new();
|
|
437
|
+
this.__wbg_ptr = ret >>> 0;
|
|
438
|
+
return this;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Feed bytes into the hasher
|
|
442
|
+
* @param {Uint8Array} data
|
|
443
|
+
*/
|
|
444
|
+
update(data) {
|
|
445
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export_0);
|
|
446
|
+
const len0 = WASM_VECTOR_LEN;
|
|
447
|
+
wasm.sha512h_update(this.__wbg_ptr, ptr0, len0);
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Finalize the hash and return the result
|
|
451
|
+
* @returns {Uint8Array}
|
|
452
|
+
*/
|
|
453
|
+
finalize() {
|
|
454
|
+
try {
|
|
455
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
456
|
+
wasm.sha512h_finalize(retptr, this.__wbg_ptr);
|
|
457
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
458
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
459
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
460
|
+
wasm.__wbindgen_export_1(r0, r1 * 1, 1);
|
|
461
|
+
return v1;
|
|
462
|
+
} finally {
|
|
463
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Clone the hasher
|
|
468
|
+
* @returns {Sha512H}
|
|
469
|
+
*/
|
|
470
|
+
clone() {
|
|
471
|
+
const ret = wasm.sha512h_clone(this.__wbg_ptr);
|
|
472
|
+
return Sha512H.__wrap(ret);
|
|
473
|
+
}
|
|
243
474
|
}
|
|
244
475
|
|
|
245
476
|
async function __wbg_load(module, imports) {
|