]> git.codecow.com Git - nano25519.git/commitdiff
Fix unit test for equalbytes.
authorChris Duncan <chris@zoso.dev>
Sat, 29 Aug 2026 04:51:34 +0000 (21:51 -0700)
committerChris Duncan <chris@zoso.dev>
Sat, 29 Aug 2026 04:51:34 +0000 (21:51 -0700)
src/assembly/utils.ts

index 27690e367e39fb209414e6e9f9076e5995356741..d8cb54f42a01484e92f666a15dc5e43dee2198da 100644 (file)
@@ -81,9 +81,9 @@ export function sodium_is_zero (n: StaticArray<u8>, nlen: i32): u8 {
 const testbytesA = new StaticArray<u8>(32).fill(0)
 const testbytesB = new StaticArray<u8>(32).fill(0)
 for (let i = 0; i < 32; i++) {
-       testbytesA[i] = 1
-       if (equalbytes(testbytesA, testbytesB, 32)) {
-               throw new Error('equalbytes failed unit test')
+       for (let j: u8 = 0; j < 8; j++) {
+               testbytesA[i] = 1 << j
+               if (equalbytes(testbytesA, testbytesB, 32)) { throw new Error('equalbytes failed unit test') }
+               testbytesA[i] = 0
        }
-       testbytesA[i] = 0
 }