nano-rspow-web 0.12.0 → 0.13.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 +37 -8
- package/nano_rspow_web.d.ts +3 -3
- package/nano_rspow_web.js +11 -11
- package/nano_rspow_web_bg.wasm +0 -0
- package/package.json +11 -1
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# nano-rspow-web
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
If you are looking for the same functionality on the server side, see the [nano-rspow-node README](../nano-rspow-node/README.md).
|
|
4
|
+
|
|
5
|
+
Nano (XNO) proof-of-work generation for browsers using WebAssembly and WebGPU.
|
|
4
6
|
|
|
5
7
|
Tries WebGPU first, then automatically falls back to single-threaded CPU WebAssembly if WebGPU is unavailable.
|
|
6
8
|
|
|
@@ -32,21 +34,36 @@ const isValid = validate_work(hash, result.nonce, threshold); // true
|
|
|
32
34
|
|
|
33
35
|
## Benchmarking Dashboard
|
|
34
36
|
|
|
35
|
-
<
|
|
37
|
+
<table>
|
|
38
|
+
<tr>
|
|
39
|
+
<td>
|
|
40
|
+
<img src="../assets/benchmark-ui.png" width="480" alt="The nano-rspow-web browser-only benchmarking dashboard" />
|
|
41
|
+
<p><strong>Browser-only benchmark:</strong> fully in-browser, benchmarking the <code>nano-rspow-web</code> package's WebGPU and CPU WebAssembly backends.</p>
|
|
42
|
+
</td>
|
|
43
|
+
<td>
|
|
44
|
+
<img src="benchmark-compare/benchmark-charts.png" width="480" alt="Post-run charts comparing nano-rspow-web, nano-rspow-node, the nano-rspow CLI, and nano-pow" />
|
|
45
|
+
<p><strong>Local comparison results:</strong> requires building and running this repository locally; these post-run charts compare in-browser providers with the server-side <code>nano-rspow-node</code> addon and native Rust CLI side by side.</p>
|
|
46
|
+
</td>
|
|
47
|
+
</tr>
|
|
48
|
+
</table>
|
|
49
|
+
|
|
36
50
|
An interactive benchmarking dashboard is included in `browser-demo/index.html` to measure WebGPU and CPU WebAssembly performance.
|
|
37
51
|
|
|
38
52
|
Try it out for yourself: **[https://casualsecurityinc.github.io/nano-rspow/](https://casualsecurityinc.github.io/nano-rspow/)**
|
|
39
53
|
|
|
40
|
-
<br clear="right" />
|
|
41
54
|
|
|
42
55
|
|
|
43
56
|
|
|
44
57
|
|
|
58
|
+
## API reference
|
|
59
|
+
|
|
60
|
+
### `init(moduleOrPath?)`
|
|
45
61
|
|
|
46
|
-
|
|
62
|
+
Initializes the asynchronous WASM loader. Await this default export before calling the work functions. It accepts an optional WebAssembly module, bytes, `Response`, URL, request, or promise for one of those inputs.
|
|
47
63
|
|
|
48
|
-
### `
|
|
49
|
-
|
|
64
|
+
### `initSync(module)`
|
|
65
|
+
|
|
66
|
+
Initializes the module synchronously from bytes or a precompiled `WebAssembly.Module`. Use this only when the module bytes are already available.
|
|
50
67
|
|
|
51
68
|
### `generate_work(hash_hex: string, threshold_hex: string): Promise<GenerateResult>`
|
|
52
69
|
Asynchronously generates Proof of Work for a 32-byte block hash. Tries WebGPU first, falling back to CPU WebAssembly.
|
|
@@ -57,6 +74,10 @@ Forces WebGPU PoW generation. Rejects if WebGPU is unavailable or if the cancell
|
|
|
57
74
|
### `generate_work_cpu(hash_hex: string, threshold_hex: string): GenerateResult`
|
|
58
75
|
Synchronously generates PoW forcing single-threaded CPU WebAssembly.
|
|
59
76
|
|
|
77
|
+
### `generate_work_cpu_batch(hash_hex: string, threshold_hex: string, max_nonces: number): string | null`
|
|
78
|
+
|
|
79
|
+
Tests at most `max_nonces` nonces synchronously on the CPU. Returns a lowercase 16-character nonce when found, otherwise `null`. The CPU random-number-generator state persists between calls. Pass an unsigned 32-bit integer.
|
|
80
|
+
|
|
60
81
|
### `validate_work(hash_hex: string, nonce_hex: string, threshold_hex: string): boolean`
|
|
61
82
|
Synchronously validates whether a nonce meets the difficulty threshold for the given block hash.
|
|
62
83
|
|
|
@@ -65,12 +86,20 @@ A class utilized to signal cancellation to the asynchronous GPU solver loop.
|
|
|
65
86
|
* `new WasmCancelToken()`: Instantiates a new token.
|
|
66
87
|
* `cancel()`: Aborts the ongoing GPU compute loop.
|
|
67
88
|
|
|
89
|
+
### `GenerateResult`
|
|
90
|
+
|
|
91
|
+
Returned by all generation functions.
|
|
92
|
+
|
|
93
|
+
* `nonce: string`: Lowercase 16-character hexadecimal nonce.
|
|
94
|
+
* `is_gpu: boolean`: `true` when WebGPU found the nonce.
|
|
95
|
+
* `free()` or `[Symbol.dispose]()` releases the WebAssembly wrapper when manual resource cleanup is needed.
|
|
96
|
+
|
|
68
97
|
|
|
69
98
|
---
|
|
70
99
|
|
|
71
|
-
## Browser
|
|
100
|
+
## Browser compatibility
|
|
72
101
|
|
|
73
|
-
WebGPU
|
|
102
|
+
Use a browser with WebGPU support to use the GPU path. Browsers without WebGPU use the synchronous single-threaded WebAssembly CPU fallback.
|
|
74
103
|
|
|
75
104
|
|
|
76
105
|
|
package/nano_rspow_web.d.ts
CHANGED
|
@@ -67,9 +67,9 @@ export interface InitOutput {
|
|
|
67
67
|
readonly validate_work: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
68
68
|
readonly wasmcanceltoken_cancel: (a: number) => void;
|
|
69
69
|
readonly wasmcanceltoken_new: () => number;
|
|
70
|
-
readonly
|
|
71
|
-
readonly
|
|
72
|
-
readonly
|
|
70
|
+
readonly wasm_bindgen_8b74beb86e9b2264___convert__closures_____invoke___wasm_bindgen_8b74beb86e9b2264___JsValue__core_f0fd674eaa06beef___result__Result_____wasm_bindgen_8b74beb86e9b2264___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
71
|
+
readonly wasm_bindgen_8b74beb86e9b2264___convert__closures_____invoke___js_sys_7c33e7a1356e6034___Function_fn_wasm_bindgen_8b74beb86e9b2264___JsValue_____wasm_bindgen_8b74beb86e9b2264___sys__Undefined___js_sys_7c33e7a1356e6034___Function_fn_wasm_bindgen_8b74beb86e9b2264___JsValue_____wasm_bindgen_8b74beb86e9b2264___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void;
|
|
72
|
+
readonly wasm_bindgen_8b74beb86e9b2264___convert__closures_____invoke___wasm_bindgen_8b74beb86e9b2264___JsValue______true_: (a: number, b: number, c: any) => void;
|
|
73
73
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
74
74
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
75
75
|
readonly __wbindgen_exn_store: (a: number) => void;
|
package/nano_rspow_web.js
CHANGED
|
@@ -333,7 +333,7 @@ function __wbg_get_imports() {
|
|
|
333
333
|
const a = state0.a;
|
|
334
334
|
state0.a = 0;
|
|
335
335
|
try {
|
|
336
|
-
return
|
|
336
|
+
return wasm_bindgen_8b74beb86e9b2264___convert__closures_____invoke___js_sys_7c33e7a1356e6034___Function_fn_wasm_bindgen_8b74beb86e9b2264___JsValue_____wasm_bindgen_8b74beb86e9b2264___sys__Undefined___js_sys_7c33e7a1356e6034___Function_fn_wasm_bindgen_8b74beb86e9b2264___JsValue_____wasm_bindgen_8b74beb86e9b2264___sys__Undefined_______true_(a, state0.b, arg0, arg1);
|
|
337
337
|
} finally {
|
|
338
338
|
state0.a = a;
|
|
339
339
|
}
|
|
@@ -351,7 +351,7 @@ function __wbg_get_imports() {
|
|
|
351
351
|
const a = state0.a;
|
|
352
352
|
state0.a = 0;
|
|
353
353
|
try {
|
|
354
|
-
return
|
|
354
|
+
return wasm_bindgen_8b74beb86e9b2264___convert__closures_____invoke___js_sys_7c33e7a1356e6034___Function_fn_wasm_bindgen_8b74beb86e9b2264___JsValue_____wasm_bindgen_8b74beb86e9b2264___sys__Undefined___js_sys_7c33e7a1356e6034___Function_fn_wasm_bindgen_8b74beb86e9b2264___JsValue_____wasm_bindgen_8b74beb86e9b2264___sys__Undefined_______true_(a, state0.b, arg0, arg1);
|
|
355
355
|
} finally {
|
|
356
356
|
state0.a = a;
|
|
357
357
|
}
|
|
@@ -607,13 +607,13 @@ function __wbg_get_imports() {
|
|
|
607
607
|
arg0.writeBuffer(arg1, arg2, getArrayU8FromWasm0(arg3, arg4), arg5, arg6);
|
|
608
608
|
}, arguments); },
|
|
609
609
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
610
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
611
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
610
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 65, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
611
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8b74beb86e9b2264___convert__closures_____invoke___wasm_bindgen_8b74beb86e9b2264___JsValue______true_);
|
|
612
612
|
return ret;
|
|
613
613
|
},
|
|
614
614
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
615
615
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 99, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
616
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
616
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8b74beb86e9b2264___convert__closures_____invoke___wasm_bindgen_8b74beb86e9b2264___JsValue__core_f0fd674eaa06beef___result__Result_____wasm_bindgen_8b74beb86e9b2264___JsError___true_);
|
|
617
617
|
return ret;
|
|
618
618
|
},
|
|
619
619
|
__wbindgen_cast_0000000000000003: function(arg0) {
|
|
@@ -647,19 +647,19 @@ function __wbg_get_imports() {
|
|
|
647
647
|
};
|
|
648
648
|
}
|
|
649
649
|
|
|
650
|
-
function
|
|
651
|
-
wasm.
|
|
650
|
+
function wasm_bindgen_8b74beb86e9b2264___convert__closures_____invoke___wasm_bindgen_8b74beb86e9b2264___JsValue______true_(arg0, arg1, arg2) {
|
|
651
|
+
wasm.wasm_bindgen_8b74beb86e9b2264___convert__closures_____invoke___wasm_bindgen_8b74beb86e9b2264___JsValue______true_(arg0, arg1, arg2);
|
|
652
652
|
}
|
|
653
653
|
|
|
654
|
-
function
|
|
655
|
-
const ret = wasm.
|
|
654
|
+
function wasm_bindgen_8b74beb86e9b2264___convert__closures_____invoke___wasm_bindgen_8b74beb86e9b2264___JsValue__core_f0fd674eaa06beef___result__Result_____wasm_bindgen_8b74beb86e9b2264___JsError___true_(arg0, arg1, arg2) {
|
|
655
|
+
const ret = wasm.wasm_bindgen_8b74beb86e9b2264___convert__closures_____invoke___wasm_bindgen_8b74beb86e9b2264___JsValue__core_f0fd674eaa06beef___result__Result_____wasm_bindgen_8b74beb86e9b2264___JsError___true_(arg0, arg1, arg2);
|
|
656
656
|
if (ret[1]) {
|
|
657
657
|
throw takeFromExternrefTable0(ret[0]);
|
|
658
658
|
}
|
|
659
659
|
}
|
|
660
660
|
|
|
661
|
-
function
|
|
662
|
-
wasm.
|
|
661
|
+
function wasm_bindgen_8b74beb86e9b2264___convert__closures_____invoke___js_sys_7c33e7a1356e6034___Function_fn_wasm_bindgen_8b74beb86e9b2264___JsValue_____wasm_bindgen_8b74beb86e9b2264___sys__Undefined___js_sys_7c33e7a1356e6034___Function_fn_wasm_bindgen_8b74beb86e9b2264___JsValue_____wasm_bindgen_8b74beb86e9b2264___sys__Undefined_______true_(arg0, arg1, arg2, arg3) {
|
|
662
|
+
wasm.wasm_bindgen_8b74beb86e9b2264___convert__closures_____invoke___js_sys_7c33e7a1356e6034___Function_fn_wasm_bindgen_8b74beb86e9b2264___JsValue_____wasm_bindgen_8b74beb86e9b2264___sys__Undefined___js_sys_7c33e7a1356e6034___Function_fn_wasm_bindgen_8b74beb86e9b2264___JsValue_____wasm_bindgen_8b74beb86e9b2264___sys__Undefined_______true_(arg0, arg1, arg2, arg3);
|
|
663
663
|
}
|
|
664
664
|
|
|
665
665
|
|
package/nano_rspow_web_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nano-rspow-web",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "WebGPU-accelerated Nano (XNO) Proof of Work generation in the browser using WebAssembly",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"nano",
|
|
7
|
+
"xno",
|
|
8
|
+
"nanocurrency",
|
|
9
|
+
"pow",
|
|
10
|
+
"proof-of-work",
|
|
11
|
+
"wasm",
|
|
12
|
+
"webgpu",
|
|
13
|
+
"browser"
|
|
14
|
+
],
|
|
5
15
|
"repository": {
|
|
6
16
|
"type": "git",
|
|
7
17
|
"url": "git+https://github.com/CasualSecurityInc/nano-rspow.git",
|