{
"options": {
- "outFile": "./src/lib/generate/wasm/asm/compute.wasm",
+ "outFile": "./src/lib/generate/wasm/asm/build/compute.wasm",
"optimizeLevel": 3,
"shrinkLevel": 2,
"converge": true,
+<!--
+SPDX-FileCopyrightText: 2025 Chris Duncan <chris@zoso.dev>
+SPDX-License-Identifier: GPL-3.0-or-later
+-->
+
Twelve rounds of G mixing as part of BLAKE2b compression step, each divided into eight subprocesses. Each subprocess applies transformations to `m` and `v` variables based on a defined set of index inputs. The algorithm for each subprocess is defined as ollows:
* r is the current round
\# SPDX-FileCopyrightText: 2025 Chris Duncan <chris@zoso.dev>
\# SPDX-License-Identifier: GPL-3.0-or-later
-.TH nano-pow 1 2025-06-17 "nano-pow v5.0.0"
+.TH nano-pow 1 2025-06-27 "nano-pow v5.1.2"
.SH NAME
nano-pow \- proof-of-work generation and validation for Nano cryptocurrency
const main = (() => {
switch (api) {
case 'wasm': {
- return `export function main (seed: u64, h0: u64, h1: u64, h2: u64, h3: u64, difficulty: u64): u64 {
+ return `//! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@zoso.dev>
+//! SPDX-License-Identifier: GPL-3.0-or-later
+
+export function main (seed: u64, h0: u64, h1: u64, h2: u64, h3: u64, difficulty: u64): u64 {
${declare} m0 = ${ctr(`0`)};
const m1 = ${ctr(`h0`)};
const m2 = ${ctr(`h1`)};
`
}
case 'webgpu': {
- return `// Input buffers
+ return `//! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@zoso.dev>
+//! SPDX-License-Identifier: GPL-3.0-or-later
+
+// Input buffers
struct INPUT {
hash: array<vec4<u32>, 2>,
difficulty: vec2<u32>,
+++ /dev/null
-/** Exported memory */
-export declare const memory: WebAssembly.Memory;
-/**
- * src/lib/generate/wasm/asm/index/main
- * @param seed `u64`
- * @param h0 `u64`
- * @param h1 `u64`
- * @param h2 `u64`
- * @param h3 `u64`
- * @param difficulty `u64`
- * @returns `u64`
- */
-export declare function main(seed: bigint, h0: bigint, h1: bigint, h2: bigint, h3: bigint, difficulty: bigint): bigint;
+++ /dev/null
-async function instantiate(module, imports = {}) {
- const { exports } = await WebAssembly.instantiate(module, imports);
- const memory = exports.memory || imports.env.memory;
- const adaptedExports = Object.setPrototypeOf({
- main(seed, h0, h1, h2, h3, difficulty) {
- // src/lib/generate/wasm/asm/index/main(u64, u64, u64, u64, u64, u64) => u64
- seed = seed || 0n;
- h0 = h0 || 0n;
- h1 = h1 || 0n;
- h2 = h2 || 0n;
- h3 = h3 || 0n;
- difficulty = difficulty || 0n;
- return BigInt.asUintN(64, exports.main(seed, h0, h1, h2, h3, difficulty));
- },
- }, exports);
- return adaptedExports;
-}
-export const {
- memory,
- main,
-} = await (async url => instantiate(
- await (async () => {
- const isNodeOrBun = typeof process != "undefined" && process.versions != null && (process.versions.node != null || process.versions.bun != null);
- if (isNodeOrBun) { return globalThis.WebAssembly.compile(await (await import("node:fs/promises")).readFile(url)); }
- else { return await globalThis.WebAssembly.compileStreaming(globalThis.fetch(url)); }
- })(), {
- }
-))(new URL("compute.wasm", import.meta.url));
+//! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@zoso.dev>
+//! SPDX-License-Identifier: GPL-3.0-or-later
export function main (seed: u64, h0: u64, h1: u64, h2: u64, h3: u64, difficulty: u64): u64 {
let m0 = v128.splat<u64>(0);
const m1 = v128.splat<u64>(h0);
//! SPDX-License-Identifier: GPL-3.0-or-later
//@ts-expect-error
-import compute from './asm/compute.wasm'
+import compute from './asm/build/compute.wasm'
type Main = (w: bigint, h0: bigint, h1: bigint, h2: bigint, h3: bigint, d: bigint) => any
const worker = async (compute: number[]): Promise<void> => {
+//! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@zoso.dev>
+//! SPDX-License-Identifier: GPL-3.0-or-later
// Input buffers
struct INPUT {
hash: array<vec4<u32>, 2>,