]> git.codecow.com Git - nano25519.git/commitdiff
Fix similar issue with asc bit shift operand masking when checking canonicity.
authorChris Duncan <chris@zoso.dev>
Sun, 16 Aug 2026 05:54:12 +0000 (22:54 -0700)
committerChris Duncan <chris@zoso.dev>
Sun, 16 Aug 2026 05:54:12 +0000 (22:54 -0700)
src/assembly/ge.ts

index c82639f28782a32901cafc1c51b08fcde9a33239..c9e4c58226533f3ba3cd7b9c49bbf4b258cec813 100644 (file)
@@ -169,13 +169,13 @@ export function ge_has_small_order (p: ge_p3): i32 {
  * true if `s < p`
  */
 export function ge_is_canonical (s: StaticArray<u8>): u8 {
-       let c: u8 = (s[31] & 0x7f) ^ 0x7f
+       let c: i32 = (s[31] & 0x7f) ^ 0x7f
        for (let i = 30; i > 0; i--) {
                c |= s[i] ^ 0xff
        }
        c = (c - 1) >> 8
-       const d: u8 = (0xec - s[0]) >> 8
-       return 1 - (c & d & 1)
+       const d: i32 = (0xec - s[0]) >> 8
+       return u8(1 - (c & d & 1))
 }
 
 const ge_scalarmult_base_e: StaticArray<i8> = new StaticArray<i8>(64)