Skip to content

Commit 8614e49

Browse files
committed
Further Divsteps30 improvement
1 parent 86a4479 commit 8614e49

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

crypto/src/math/raw/Mod.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -278,21 +278,19 @@ private static int Divsteps30(int eta, int f0, int g0, int[] t)
278278
Debug.Assert((u * f0 + v * g0) == f << i);
279279
Debug.Assert((q * f0 + r * g0) == g << i);
280280

281-
int p = -(g & 1);
282-
int s = eta >> 31;
281+
int c1 = eta >> 31;
282+
int c2 = -(g & 1);
283283

284-
int c1 = p & s;
285-
int c2 = p & ~s;
284+
int x = (f ^ c1) - c1;
285+
int y = (u ^ c1) - c1;
286+
int z = (v ^ c1) - c1;
286287

287-
eta = (eta ^ c1) - (c1 + 1);
288-
289-
g += f & c2;
290-
q += u & c2;
291-
r += v & c2;
288+
g += x & c2;
289+
q += y & c2;
290+
r += z & c2;
292291

293-
g -= f & c1;
294-
q -= u & c1;
295-
r -= v & c1;
292+
c1 &= c2;
293+
eta = (eta ^ c1) - (c1 + 1);
296294

297295
f += g & c1;
298296
u += q & c1;

0 commit comments

Comments
 (0)