ecash-lib 1.2.2-rc15 → 1.2.2-rc16
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/dist/ecc.d.ts +25 -9
- package/dist/ecc.d.ts.map +1 -1
- package/dist/ecc.js +34 -2
- package/dist/ecc.js.map +1 -1
- package/package.json +1 -1
package/dist/ecc.d.ts
CHANGED
|
@@ -13,16 +13,32 @@ export declare class EccDummy implements Ecc {
|
|
|
13
13
|
ecdsaSign(_seckey: Uint8Array, _msg: Uint8Array): Uint8Array;
|
|
14
14
|
schnorrSign(_seckey: Uint8Array, _msg: Uint8Array): Uint8Array;
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
/**
|
|
17
|
+
* We define Ecc as a proxy
|
|
18
|
+
* This is done to solve a specific problem
|
|
19
|
+
* If we have this kind of app structure:
|
|
20
|
+
* - AppOne has ecash-lib as a dependency
|
|
21
|
+
* - AppTwo has ecash-lib as a dependency
|
|
22
|
+
* - AppOne has AppTwo as a dependency
|
|
23
|
+
*
|
|
24
|
+
* So, we expect AppOne to use AppTwo methods that need initWasm()
|
|
25
|
+
* However, if we initWasm() in AppOne, these methods are not available in AppTwo
|
|
26
|
+
*
|
|
27
|
+
* We can get them into the globalThis with initWasm, but we still need Ecc to dynamically
|
|
28
|
+
* check the globalThis and realize it is there --- to preserve lib syntax
|
|
29
|
+
*
|
|
30
|
+
* In this way, users can still call "new Ecc()"
|
|
31
|
+
*
|
|
32
|
+
* With just globalThis, users must call "new (globalThis as unknown as GlobalThis).ecashlib.Ecc()"
|
|
33
|
+
*/
|
|
34
|
+
export declare const Ecc: {
|
|
35
|
+
new (): {
|
|
36
|
+
derivePubkey(_seckey: Uint8Array): Uint8Array;
|
|
37
|
+
ecdsaSign(_seckey: Uint8Array, _msg: Uint8Array): Uint8Array;
|
|
38
|
+
schnorrSign(_seckey: Uint8Array, _msg: Uint8Array): Uint8Array;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
24
41
|
export declare function __setEcc(ecc: {
|
|
25
42
|
new (): Ecc;
|
|
26
43
|
}): void;
|
|
27
|
-
export {};
|
|
28
44
|
//# sourceMappingURL=ecc.d.ts.map
|
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;CAChE;AAED,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;CAGjE;
|
|
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;CAChE;AAED,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;CAGjE;AAuBD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,GAAG;;8BAQc,UAAU,GAAG,UAAU;2BAI1B,UAAU,QAAQ,UAAU,GAAG,UAAU;6BAIvC,UAAU,QAAQ,UAAU,GAAG,UAAU;;CAcrE,CAAC;AAEF,wBAAgB,QAAQ,CAAC,GAAG,EAAE;IAAE,QAAQ,GAAG,CAAA;CAAE,QAO5C"}
|
package/dist/ecc.js
CHANGED
|
@@ -34,8 +34,40 @@ class EccUninitialized {
|
|
|
34
34
|
throw new Error('Ecc not initialized. Call initWasm first.');
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
/**
|
|
38
|
+
* We define Ecc as a proxy
|
|
39
|
+
* This is done to solve a specific problem
|
|
40
|
+
* If we have this kind of app structure:
|
|
41
|
+
* - AppOne has ecash-lib as a dependency
|
|
42
|
+
* - AppTwo has ecash-lib as a dependency
|
|
43
|
+
* - AppOne has AppTwo as a dependency
|
|
44
|
+
*
|
|
45
|
+
* So, we expect AppOne to use AppTwo methods that need initWasm()
|
|
46
|
+
* However, if we initWasm() in AppOne, these methods are not available in AppTwo
|
|
47
|
+
*
|
|
48
|
+
* We can get them into the globalThis with initWasm, but we still need Ecc to dynamically
|
|
49
|
+
* check the globalThis and realize it is there --- to preserve lib syntax
|
|
50
|
+
*
|
|
51
|
+
* In this way, users can still call "new Ecc()"
|
|
52
|
+
*
|
|
53
|
+
* With just globalThis, users must call "new (globalThis as unknown as GlobalThis).ecashlib.Ecc()"
|
|
54
|
+
*/
|
|
55
|
+
exports.Ecc = new Proxy(class EccProxy {
|
|
56
|
+
constructor() {
|
|
57
|
+
if (!exports.Ecc.prototype.derivePubkey) {
|
|
58
|
+
throw new Error('Ecc not initialized. Call initWasm first.');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
derivePubkey(_seckey) {
|
|
62
|
+
throw new Error('Ecc not initialized. Call initWasm first.');
|
|
63
|
+
}
|
|
64
|
+
ecdsaSign(_seckey, _msg) {
|
|
65
|
+
throw new Error('Ecc not initialized. Call initWasm first.');
|
|
66
|
+
}
|
|
67
|
+
schnorrSign(_seckey, _msg) {
|
|
68
|
+
throw new Error('Ecc not initialized. Call initWasm first.');
|
|
69
|
+
}
|
|
70
|
+
}, {
|
|
39
71
|
construct: () => {
|
|
40
72
|
const currentEcc = 'ecashlib' in globalThis &&
|
|
41
73
|
'Ecc' in globalThis.ecashlib
|
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;;;AActE,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;CACJ;AAZD,4BAYC;AAED,qCAAqC;AACrC,MAAM,gBAAgB;IAClB;QACI,IAAI,CAAC,WAAG,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QACjE,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