Skip to content

Commit 6df1b29

Browse files
Change how the mask is set
1 parent c3f4dd2 commit 6df1b29

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Src/Autarkysoft.Bitcoin/Cryptography/EllipticCurve/Scalar8x32.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ public Scalar8x32 Half()
319319
// - the right summand is: a&1 ? n//2+1 : 0 = n//2+1 = (n-1)//2 + 2//2 = (n+1)//2
320320
// Together they sum to (n-3)//2 + (n+1)//2 = (2n-2)//2 = n - 1, which is less than n.
321321

322-
uint mask = (uint)-(b0 & 1U);
322+
// uint32_t mask = -(uint32_t)(a->d[0] & 1U);
323+
uint mask = (b0 & 1U) * 0xFFFFFFFFU;
323324
ulong t = (b0 >> 1) | (b1 << 31);
324325
Debug.Assert(GetOverflow(this) == 0);
325326

0 commit comments

Comments
 (0)