]> zoso.dev Git - libnemo.git/commitdiff
Document odd difference between blake C reference implementation and nano-webgl-pow...
authorChris Duncan <chris@zoso.dev>
Mon, 6 Jan 2025 14:38:58 +0000 (06:38 -0800)
committerChris Duncan <chris@zoso.dev>
Mon, 6 Jan 2025 14:38:58 +0000 (06:38 -0800)
src/lib/workers/powgpu.ts

index b9be12c4d076a42962801c1a8103ae38bd2328ec..51c95068574954aaba5d5bf23bdbec8eed4eed1d 100644 (file)
@@ -199,6 +199,9 @@ export class PowGpu extends WorkerInterface {
 
                        /**
                        * Initialize (nonce||blockhash) concatenation
+                       * NOTE: blake2b reference uses uint64_t whereas we have u32
+                       * Array length might need to increase from 16 to 32 because of this
+                       * Unsure why it works anyway now since it should throw out-of-range error?
                        */
                        var m: array<u32, 16>;
                        m[0u] = ubo.random;
@@ -322,14 +325,14 @@ export class PowGpu extends WorkerInterface {
                        G(&v, &m, 6u, 8u, 18u, 28u, m[30u], m[31u], m[16u], m[17u]);
 
                        // ROUND(4)
-                       G(&v, &m, 0u, 8u, 16u, 24u, 18u, 0u);
-                       G(&v, &m, 2u, 10u, 18u, 26u, 10u, 14u);
-                       G(&v, &m, 4u, 12u, 20u, 28u, 4u, 8u);
-                       G(&v, &m, 6u, 14u, 22u, 30u, 20u, 30u);
-                       G(&v, &m, 0u, 10u, 20u, 30u, 28u, 2u);
-                       G(&v, &m, 2u, 12u, 22u, 24u, 22u, 24u);
-                       G(&v, &m, 4u, 14u, 16u, 26u, 12u, 16u);
-                       G(&v, &m, 6u, 8u, 18u, 28u, 6u, 26u);
+                       G(&v, &m, 0u, 8u, 16u, 24u, m[18u], m[19u], m[0u], m[1u]);
+                       G(&v, &m, 2u, 10u, 18u, 26u, m[10u], m[11u], m[14u], m[15u]);
+                       G(&v, &m, 4u, 12u, 20u, 28u, m[4u], m[5u], m[8u], m[9u]);
+                       G(&v, &m, 6u, 14u, 22u, 30u, m[20u], m[21u], m[30u], m[31u]);
+                       G(&v, &m, 0u, 10u, 20u, 30u, m[28u], m[29u], m[2u], m[3u]);
+                       G(&v, &m, 2u, 12u, 22u, 24u, m[22u], m[23u], m[24u], m[25u]);
+                       G(&v, &m, 4u, 14u, 16u, 26u, m[12u], m[13u], m[16u], m[17u]);
+                       G(&v, &m, 6u, 8u, 18u, 28u, m[6u], m[7u], m[26u], m[27u]);
 
                        // ROUND(5)
                        G(&v, &m, 0u, 8u, 16u, 24u, 4u, 24u);