@pezkuwi/wasm-crypto 7.5.13 → 7.5.15

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 (122) hide show
  1. package/Cargo.toml +50 -0
  2. package/Xargo.toml +2 -0
  3. package/build/README.md +29 -0
  4. package/build/bundle-pezkuwi-wasm-crypto.js +2092 -0
  5. package/build/bundle.d.ts +40 -0
  6. package/build/bundle.js +505 -0
  7. package/build/cjs/bundle.d.ts +40 -0
  8. package/build/cjs/bundle.js +544 -0
  9. package/{index.d.ts → build/cjs/index.d.ts} +0 -1
  10. package/build/cjs/index.js +4 -0
  11. package/build/cjs/init.js +21 -0
  12. package/build/cjs/initNone.js +20 -0
  13. package/build/cjs/initOnlyAsm.js +20 -0
  14. package/build/cjs/initOnlyWasm.js +20 -0
  15. package/build/cjs/initWasmAsm.js +20 -0
  16. package/build/cjs/packageInfo.js +4 -0
  17. package/build/index.d.ts +1 -0
  18. package/build/index.js +1 -0
  19. package/build/init.d.ts +16 -0
  20. package/build/init.js +17 -0
  21. package/build/initNone.d.ts +10 -0
  22. package/build/initNone.js +17 -0
  23. package/build/initOnlyAsm.d.ts +10 -0
  24. package/build/initOnlyAsm.js +17 -0
  25. package/build/initOnlyWasm.d.ts +10 -0
  26. package/build/initOnlyWasm.js +17 -0
  27. package/build/initWasmAsm.d.ts +10 -0
  28. package/build/initWasmAsm.js +17 -0
  29. package/build/package.json +208 -0
  30. package/build/packageDetect.d.ts +1 -0
  31. package/build/packageDetect.js +8 -0
  32. package/build/packageInfo.d.ts +6 -0
  33. package/build/packageInfo.js +1 -0
  34. package/build-deno/README.md +25 -0
  35. package/build-deno/bundle.ts +597 -0
  36. package/build-deno/index.ts +2 -0
  37. package/build-deno/init.ts +23 -0
  38. package/build-deno/initNone.ts +21 -0
  39. package/build-deno/initOnlyAsm.ts +21 -0
  40. package/build-deno/initOnlyWasm.ts +21 -0
  41. package/build-deno/initWasmAsm.ts +21 -0
  42. package/build-deno/mod.ts +2 -0
  43. package/build-deno/packageDetect.ts +12 -0
  44. package/build-deno/packageInfo.ts +3 -0
  45. package/build-deno/rs/.editorconfig +10 -0
  46. package/build-tsc/bundle.d.ts +40 -0
  47. package/{cjs → build-tsc}/index.d.ts +0 -1
  48. package/build-tsc-cjs/bundle.js +544 -0
  49. package/{cjs → build-tsc-cjs}/index.js +0 -1
  50. package/build-tsc-cjs/packageDetect.js +10 -0
  51. package/{cjs → build-tsc-cjs}/packageInfo.js +1 -1
  52. package/build-tsc-esm/bundle.js +505 -0
  53. package/{index.js → build-tsc-esm/index.js} +0 -1
  54. package/{packageInfo.js → build-tsc-esm/packageInfo.js} +1 -1
  55. package/package.json +89 -87
  56. package/src/bundle.ts +613 -0
  57. package/src/index.ts +5 -0
  58. package/src/init.ts +25 -0
  59. package/src/initNone.ts +23 -0
  60. package/src/initOnlyAsm.ts +23 -0
  61. package/src/initOnlyWasm.ts +23 -0
  62. package/src/initWasmAsm.ts +23 -0
  63. package/src/lib.rs +24 -0
  64. package/src/mod.ts +4 -0
  65. package/src/packageDetect.ts +16 -0
  66. package/src/packageInfo.ts +6 -0
  67. package/src/rs/.editorconfig +10 -0
  68. package/src/rs/bip39.rs +139 -0
  69. package/src/rs/ed25519.rs +142 -0
  70. package/src/rs/hashing.rs +322 -0
  71. package/src/rs/secp256k1.rs +150 -0
  72. package/src/rs/sr25519.rs +331 -0
  73. package/src/rs/vrf.rs +144 -0
  74. package/test/all/bip39.js +86 -0
  75. package/test/all/ed25519.js +84 -0
  76. package/test/all/hashing.js +138 -0
  77. package/test/all/index.js +126 -0
  78. package/test/all/secp256k1.js +105 -0
  79. package/test/all/sr25519.js +211 -0
  80. package/test/all/vrf.js +74 -0
  81. package/test/asm.js +10 -0
  82. package/test/deno.ts +38 -0
  83. package/test/jest.spec.ts +25 -0
  84. package/test/loader-build.js +39 -0
  85. package/test/wasm.js +8 -0
  86. package/tsconfig.build.json +19 -0
  87. package/tsconfig.build.tsbuildinfo +1 -0
  88. package/tsconfig.spec.json +16 -0
  89. package/tsconfig.spec.tsbuildinfo +1 -0
  90. package/bundle-pezkuwi-wasm-crypto.js +0 -825
  91. package/bundle.d.ts +0 -37
  92. package/bundle.js +0 -165
  93. package/cjs/bundle.d.ts +0 -37
  94. package/cjs/bundle.js +0 -171
  95. /package/{LICENSE → build/LICENSE} +0 -0
  96. /package/{init.d.ts → build/cjs/init.d.ts} +0 -0
  97. /package/{initNone.d.ts → build/cjs/initNone.d.ts} +0 -0
  98. /package/{initOnlyAsm.d.ts → build/cjs/initOnlyAsm.d.ts} +0 -0
  99. /package/{initOnlyWasm.d.ts → build/cjs/initOnlyWasm.d.ts} +0 -0
  100. /package/{initWasmAsm.d.ts → build/cjs/initWasmAsm.d.ts} +0 -0
  101. /package/{cjs → build/cjs}/package.json +0 -0
  102. /package/{packageDetect.d.ts → build/cjs/packageDetect.d.ts} +0 -0
  103. /package/{cjs → build/cjs}/packageDetect.js +0 -0
  104. /package/{packageInfo.d.ts → build/cjs/packageInfo.d.ts} +0 -0
  105. /package/{cjs → build-tsc}/init.d.ts +0 -0
  106. /package/{cjs → build-tsc}/initNone.d.ts +0 -0
  107. /package/{cjs → build-tsc}/initOnlyAsm.d.ts +0 -0
  108. /package/{cjs → build-tsc}/initOnlyWasm.d.ts +0 -0
  109. /package/{cjs → build-tsc}/initWasmAsm.d.ts +0 -0
  110. /package/{cjs → build-tsc}/packageDetect.d.ts +0 -0
  111. /package/{cjs → build-tsc}/packageInfo.d.ts +0 -0
  112. /package/{cjs → build-tsc-cjs}/init.js +0 -0
  113. /package/{cjs → build-tsc-cjs}/initNone.js +0 -0
  114. /package/{cjs → build-tsc-cjs}/initOnlyAsm.js +0 -0
  115. /package/{cjs → build-tsc-cjs}/initOnlyWasm.js +0 -0
  116. /package/{cjs → build-tsc-cjs}/initWasmAsm.js +0 -0
  117. /package/{init.js → build-tsc-esm/init.js} +0 -0
  118. /package/{initNone.js → build-tsc-esm/initNone.js} +0 -0
  119. /package/{initOnlyAsm.js → build-tsc-esm/initOnlyAsm.js} +0 -0
  120. /package/{initOnlyWasm.js → build-tsc-esm/initOnlyWasm.js} +0 -0
  121. /package/{initWasmAsm.js → build-tsc-esm/initWasmAsm.js} +0 -0
  122. /package/{packageDetect.js → build-tsc-esm/packageDetect.js} +0 -0
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.packageInfo = void 0;
4
+ exports.packageInfo = { name: '@pezkuwi/wasm-crypto', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '7.5.15' };
@@ -0,0 +1 @@
1
+ export * from './bundle.js';
package/build/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from './bundle.js';
@@ -0,0 +1,16 @@
1
+ import type { InitFn } from '@pezkuwi/wasm-bridge/types';
2
+ import type { WasmCryptoInstance } from '@pezkuwi/wasm-crypto-init/types';
3
+ import { Bridge } from '@pezkuwi/wasm-bridge';
4
+ /**
5
+ * @name bridge
6
+ * @description
7
+ * The JS <-> WASM bridge that is in operation. For the specific package
8
+ * it is a global, i.e. all operations happens on this specific bridge
9
+ */
10
+ export declare const bridge: Bridge<WasmCryptoInstance>;
11
+ /**
12
+ * @name initBridge
13
+ * @description
14
+ * Creates a new bridge interface with the (optional) initialization function
15
+ */
16
+ export declare function initBridge(createWasm?: InitFn<WasmCryptoInstance>): Promise<WasmCryptoInstance | null>;
package/build/init.js ADDED
@@ -0,0 +1,17 @@
1
+ import { Bridge } from '@pezkuwi/wasm-bridge';
2
+ import { createWasm } from '@pezkuwi/wasm-crypto-init';
3
+ /**
4
+ * @name bridge
5
+ * @description
6
+ * The JS <-> WASM bridge that is in operation. For the specific package
7
+ * it is a global, i.e. all operations happens on this specific bridge
8
+ */
9
+ export const bridge = new Bridge(createWasm);
10
+ /**
11
+ * @name initBridge
12
+ * @description
13
+ * Creates a new bridge interface with the (optional) initialization function
14
+ */
15
+ export async function initBridge(createWasm) {
16
+ return bridge.init(createWasm);
17
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @name initWasm
3
+ * @description
4
+ * For historic purposes and for tighter control on init, specifically performing
5
+ * a WASM initialization with no interface whatsoever (no WASM, no ASM.js)
6
+ *
7
+ * Generally should not be used unless you want explicit control over which
8
+ * interfaces are initialized.
9
+ */
10
+ export declare function initWasm(): Promise<void>;
@@ -0,0 +1,17 @@
1
+ import { createWasm } from '@pezkuwi/wasm-crypto-init/none';
2
+ import { initBridge } from './init.js';
3
+ /**
4
+ * @name initWasm
5
+ * @description
6
+ * For historic purposes and for tighter control on init, specifically performing
7
+ * a WASM initialization with no interface whatsoever (no WASM, no ASM.js)
8
+ *
9
+ * Generally should not be used unless you want explicit control over which
10
+ * interfaces are initialized.
11
+ */
12
+ export async function initWasm() {
13
+ await initBridge(createWasm);
14
+ }
15
+ initWasm().catch(() => {
16
+ // cannot happen, initWasm doesn't throw
17
+ });
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @name initWasm
3
+ * @description
4
+ * For historic purposes and for tighter control on init, specifically performing
5
+ * a WASM initialization with only ASM.js
6
+ *
7
+ * Generally should not be used unless you want explicit control over which
8
+ * interfaces are initialized.
9
+ */
10
+ export declare function initWasm(): Promise<void>;
@@ -0,0 +1,17 @@
1
+ import { createWasm } from '@pezkuwi/wasm-crypto-init/asm';
2
+ import { initBridge } from './init.js';
3
+ /**
4
+ * @name initWasm
5
+ * @description
6
+ * For historic purposes and for tighter control on init, specifically performing
7
+ * a WASM initialization with only ASM.js
8
+ *
9
+ * Generally should not be used unless you want explicit control over which
10
+ * interfaces are initialized.
11
+ */
12
+ export async function initWasm() {
13
+ await initBridge(createWasm);
14
+ }
15
+ initWasm().catch(() => {
16
+ // cannot happen, initWasm doesn't throw
17
+ });
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @name initWasm
3
+ * @description
4
+ * For historic purposes and for tighter control on init, specifically performing
5
+ * a WASM initialization with only WASM (generally the default for most platforms)
6
+ *
7
+ * Generally should not be used unless you want explicit control over which
8
+ * interfaces are initialized.
9
+ */
10
+ export declare function initWasm(): Promise<void>;
@@ -0,0 +1,17 @@
1
+ import { createWasm } from '@pezkuwi/wasm-crypto-init/wasm';
2
+ import { initBridge } from './init.js';
3
+ /**
4
+ * @name initWasm
5
+ * @description
6
+ * For historic purposes and for tighter control on init, specifically performing
7
+ * a WASM initialization with only WASM (generally the default for most platforms)
8
+ *
9
+ * Generally should not be used unless you want explicit control over which
10
+ * interfaces are initialized.
11
+ */
12
+ export async function initWasm() {
13
+ await initBridge(createWasm);
14
+ }
15
+ initWasm().catch(() => {
16
+ // cannot happen, initWasm doesn't throw
17
+ });
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @name initWasm
3
+ * @description
4
+ * For historic purposes and for tighter control on init, specifically performing
5
+ * a WASM initialization with ASM and an ASM.js fallback
6
+ *
7
+ * Generally should not be used unless you want explicit control over which
8
+ * interfaces are initialized.
9
+ */
10
+ export declare function initWasm(): Promise<void>;
@@ -0,0 +1,17 @@
1
+ import { createWasm } from '@pezkuwi/wasm-crypto-init/both';
2
+ import { initBridge } from './init.js';
3
+ /**
4
+ * @name initWasm
5
+ * @description
6
+ * For historic purposes and for tighter control on init, specifically performing
7
+ * a WASM initialization with ASM and an ASM.js fallback
8
+ *
9
+ * Generally should not be used unless you want explicit control over which
10
+ * interfaces are initialized.
11
+ */
12
+ export async function initWasm() {
13
+ await initBridge(createWasm);
14
+ }
15
+ initWasm().catch(() => {
16
+ // cannot happen, initWasm doesn't throw
17
+ });
@@ -0,0 +1,208 @@
1
+ {
2
+ "author": "PezkuwiChain <dev@pezkuwichain.io>",
3
+ "bugs": "https://github.com/pezkuwichain/pezkuwi-wasm/issues",
4
+ "description": "A wasm interface layer for use by @pezkuwi/util-crypto",
5
+ "engines": {
6
+ "node": ">=18"
7
+ },
8
+ "homepage": "https://github.com/pezkuwichain/pezkuwi-wasm/tree/master/packages/wasm-crypto#readme",
9
+ "license": "Apache-2.0",
10
+ "name": "@pezkuwi/wasm-crypto",
11
+ "repository": {
12
+ "directory": "packages/wasm-crypto",
13
+ "type": "git",
14
+ "url": "https://github.com/pezkuwichain/pezkuwi-wasm.git"
15
+ },
16
+ "sideEffects": [
17
+ "./build/initNone.js",
18
+ "./build/cjs/initNone.js",
19
+ "./build/initOnlyAsm.js",
20
+ "./build/cjs/initOnlyAsm.js",
21
+ "./build/initOnlyWasm.js",
22
+ "./build/cjs/initOnlyWasm.js",
23
+ "./build/initWasmAsm.js",
24
+ "./build/cjs/initWasmAsm.js",
25
+ "./build/packageDetect.js",
26
+ "./build/cjs/packageDetect.js"
27
+ ],
28
+ "type": "module",
29
+ "version": "7.5.15",
30
+ "main": "./cjs/index.js",
31
+ "module": "./cjs/index.js",
32
+ "types": "./cjs/index.d.ts",
33
+ "exports": {
34
+ "./cjs/package.json": "./cjs/package.json",
35
+ "./cjs/*": "./cjs/*.js",
36
+ ".": {
37
+ "module": {
38
+ "types": "./index.d.ts",
39
+ "default": "./index.js"
40
+ },
41
+ "require": {
42
+ "types": "./cjs/index.d.ts",
43
+ "default": "./cjs/index.js"
44
+ },
45
+ "default": {
46
+ "types": "./index.d.ts",
47
+ "default": "./index.js"
48
+ }
49
+ },
50
+ "./bundle": {
51
+ "module": {
52
+ "types": "./bundle.d.ts",
53
+ "default": "./bundle.js"
54
+ },
55
+ "require": {
56
+ "types": "./cjs/bundle.d.ts",
57
+ "default": "./cjs/bundle.js"
58
+ },
59
+ "default": {
60
+ "types": "./bundle.d.ts",
61
+ "default": "./bundle.js"
62
+ }
63
+ },
64
+ "./init": {
65
+ "module": {
66
+ "types": "./init.d.ts",
67
+ "default": "./init.js"
68
+ },
69
+ "require": {
70
+ "types": "./cjs/init.d.ts",
71
+ "default": "./cjs/init.js"
72
+ },
73
+ "default": {
74
+ "types": "./init.d.ts",
75
+ "default": "./init.js"
76
+ }
77
+ },
78
+ "./initNone": {
79
+ "module": {
80
+ "types": "./initNone.d.ts",
81
+ "default": "./initNone.js"
82
+ },
83
+ "require": {
84
+ "types": "./cjs/initNone.d.ts",
85
+ "default": "./cjs/initNone.js"
86
+ },
87
+ "default": {
88
+ "types": "./initNone.d.ts",
89
+ "default": "./initNone.js"
90
+ }
91
+ },
92
+ "./initOnlyAsm": {
93
+ "module": {
94
+ "types": "./initOnlyAsm.d.ts",
95
+ "default": "./initOnlyAsm.js"
96
+ },
97
+ "require": {
98
+ "types": "./cjs/initOnlyAsm.d.ts",
99
+ "default": "./cjs/initOnlyAsm.js"
100
+ },
101
+ "default": {
102
+ "types": "./initOnlyAsm.d.ts",
103
+ "default": "./initOnlyAsm.js"
104
+ }
105
+ },
106
+ "./initOnlyWasm": {
107
+ "module": {
108
+ "types": "./initOnlyWasm.d.ts",
109
+ "default": "./initOnlyWasm.js"
110
+ },
111
+ "require": {
112
+ "types": "./cjs/initOnlyWasm.d.ts",
113
+ "default": "./cjs/initOnlyWasm.js"
114
+ },
115
+ "default": {
116
+ "types": "./initOnlyWasm.d.ts",
117
+ "default": "./initOnlyWasm.js"
118
+ }
119
+ },
120
+ "./initWasmAsm": {
121
+ "module": {
122
+ "types": "./initWasmAsm.d.ts",
123
+ "default": "./initWasmAsm.js"
124
+ },
125
+ "require": {
126
+ "types": "./cjs/initWasmAsm.d.ts",
127
+ "default": "./cjs/initWasmAsm.js"
128
+ },
129
+ "default": {
130
+ "types": "./initWasmAsm.d.ts",
131
+ "default": "./initWasmAsm.js"
132
+ }
133
+ },
134
+ "./package.json": {
135
+ "0": ".",
136
+ "1": "/",
137
+ "2": "p",
138
+ "3": "a",
139
+ "4": "c",
140
+ "5": "k",
141
+ "6": "a",
142
+ "7": "g",
143
+ "8": "e",
144
+ "9": ".",
145
+ "10": "j",
146
+ "11": "s",
147
+ "12": "o",
148
+ "13": "n",
149
+ "require": "./cjs/package.json",
150
+ "default": "./package.json"
151
+ },
152
+ "./packageDetect": {
153
+ "module": {
154
+ "types": "./packageDetect.d.ts",
155
+ "default": "./packageDetect.js"
156
+ },
157
+ "require": {
158
+ "types": "./cjs/packageDetect.d.ts",
159
+ "default": "./cjs/packageDetect.js"
160
+ },
161
+ "default": {
162
+ "types": "./packageDetect.d.ts",
163
+ "default": "./packageDetect.js"
164
+ }
165
+ },
166
+ "./packageInfo.js": {
167
+ "module": {
168
+ "types": "./packageInfo.d.ts",
169
+ "default": "./packageInfo.js"
170
+ },
171
+ "require": {
172
+ "types": "./cjs/packageInfo.d.ts",
173
+ "default": "./cjs/packageInfo.js"
174
+ },
175
+ "default": {
176
+ "types": "./packageInfo.d.ts",
177
+ "default": "./packageInfo.js"
178
+ }
179
+ },
180
+ "./packageInfo": {
181
+ "module": {
182
+ "types": "./packageInfo.d.ts",
183
+ "default": "./packageInfo.js"
184
+ },
185
+ "require": {
186
+ "types": "./cjs/packageInfo.d.ts",
187
+ "default": "./cjs/packageInfo.js"
188
+ },
189
+ "default": {
190
+ "types": "./packageInfo.d.ts",
191
+ "default": "./packageInfo.js"
192
+ }
193
+ }
194
+ },
195
+ "dependencies": {
196
+ "@noble/hashes": "^1.3.3",
197
+ "@pezkuwi/wasm-bridge": "7.5.15",
198
+ "@pezkuwi/wasm-crypto-asmjs": "7.5.15",
199
+ "@pezkuwi/wasm-crypto-init": "7.5.15",
200
+ "@pezkuwi/wasm-crypto-wasm": "7.5.15",
201
+ "@pezkuwi/wasm-util": "7.5.15",
202
+ "tslib": "^2.7.0"
203
+ },
204
+ "peerDependencies": {
205
+ "@pezkuwi/util": "*",
206
+ "@pezkuwi/x-randomvalues": "*"
207
+ }
208
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { detectPackage } from '@pezkuwi/util';
2
+ import { packageInfo as bridgeInfo } from '@pezkuwi/wasm-bridge/packageInfo';
3
+ import { packageInfo as asmInfo } from '@pezkuwi/wasm-crypto-asmjs/packageInfo';
4
+ import { packageInfo as initInfo } from '@pezkuwi/wasm-crypto-init/packageInfo';
5
+ import { packageInfo as wasmInfo } from '@pezkuwi/wasm-crypto-wasm/packageInfo';
6
+ import { packageInfo as utilInfo } from '@pezkuwi/wasm-util/packageInfo';
7
+ import { packageInfo } from './packageInfo.js';
8
+ detectPackage(packageInfo, null, [asmInfo, bridgeInfo, initInfo, utilInfo, wasmInfo]);
@@ -0,0 +1,6 @@
1
+ export declare const packageInfo: {
2
+ name: string;
3
+ path: string;
4
+ type: string;
5
+ version: string;
6
+ };
@@ -0,0 +1 @@
1
+ export const packageInfo = { name: '@pezkuwi/wasm-crypto', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '7.5.15' };
@@ -0,0 +1,25 @@
1
+ # @pezkuwi/wasm-crypto
2
+
3
+ Wrapper around crypto hashing functions
4
+
5
+ ## Usage
6
+
7
+ Install the package (also requires `@pezkuwi/util` for `TextEncoder` polyfills - not included here as a dependency to keep the tree lean)
8
+
9
+ `yarn add @pezkuwi/wasm-crypto @pezkuwi/util`
10
+
11
+ Use it -
12
+
13
+ ```js
14
+ import { u8aToHex } from 'https://deno.land/x/pezkuwi/util/mod.ts';
15
+ import { bip39Generate, bip39ToSeed, waitReady } from 'https://deno.land/x/pezkuwi/wasm-crypto/mod.ts';
16
+
17
+ await waitReady();
18
+
19
+ const phrase = bip39Generate(12);
20
+
21
+ const seed = bip39ToSeed(phrase, '');
22
+
23
+ console.log('phrase:', phrase);
24
+ console.log('seed:', u8aToHex(seed));
25
+ ```