private static void ScalarMultBase(byte[] k, PointExt r) { Precompute(); PointSetNeutral(r); uint[] n = new uint[ScalarUints + 1]; DecodeScalar(k, 0, n); // Recode the scalar into signed-digit form { n[ScalarUints] = 4U + Nat.CAdd(ScalarUints, ~(int)n[0] & 1, n, L, n); uint c = Nat.ShiftDownBit(n.Length, n, 0); Debug.Assert(c == (1U << 31)); } PointPrecomp p = new PointPrecomp(); int cOff = PrecompSpacing - 1; for (;;) { int tPos = cOff; for (int b = 0; b < PrecompBlocks; ++b) { uint w = 0; for (int t = 0; t < PrecompTeeth; ++t) { uint tBit = n[tPos >> 5] >> (tPos & 0x1F); w &= ~(1U << t); w ^= (tBit << t); tPos += PrecompSpacing; } int sign = (int)(w >> (PrecompTeeth - 1)) & 1; int abs = ((int)w ^ -sign) & PrecompMask; Debug.Assert(sign == 0 || sign == 1); Debug.Assert(0 <= abs && abs < PrecompPoints); PointLookup(b, abs, p); X448Field.CNegate(sign, p.x); PointAddPrecomp(p, r); } if (--cOff < 0) { break; } PointDouble(r); } }