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

index 4f9a00742f9d2b6481bcecb87dba9ac56540ddfc..27690e367e39fb209414e6e9f9076e5995356741 100644 (file)
@@ -34,11 +34,12 @@ export function equal (b: i8, c: i8): u8 {
 //@ts-expect-error
 @inline
 export function equalbytes (f: StaticArray<u8>, g: StaticArray<u8>, n: i32): u8 {
-       let s: u8 = 0
+       let b: i32 = 0
        for (let i = 0; i < n; i++) {
-               s |= f[i] ^ g[i]
+               b |= f[i] ^ g[i]
        }
-       return ((s - 1) >> 8) & 1
+       b &= 255
+       return u8(((b - 1) >> 8) & 1)
 }
 
 //@ts-expect-error