nano-rspow-web 0.12.0 → 0.12.1
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_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_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nano-rspow-web",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.1",
|
|
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",
|