public static uint[] FromBigInteger(BigInteger x) { uint[] array = Nat256.FromBigInteger(x); while (Nat256.Gte(array, Curve25519Field.P)) { Nat256.SubFrom(Curve25519Field.P, array); } return(array); }
public static uint[] FromBigInteger(BigInteger x) { uint[] z = Nat256.FromBigInteger(x); if (z[7] == P7 && Nat256.Gte(z, P)) { Nat256.SubFrom(P, z); } return(z); }
public static void AddExt(uint[] xx, uint[] yy, uint[] zz) { uint c = Nat256.Add(xx, yy, zz); if (c != 0 || (zz[7] == PExt7 && Nat256.Gte(zz, PExt))) { Nat.AddTo(PExtInv.Length, PExtInv, zz); } }
public static void MultiplyAddToExt(uint[] x, uint[] y, uint[] zz) { uint c = Nat128.MulAddTo(x, y, zz); if (c != 0 || (zz[7] == PExt7 && Nat256.Gte(zz, PExt))) { Nat.AddTo(PExtInv.Length, PExtInv, zz); } }
public static void AddOne(uint[] x, uint[] z) { uint c = Nat.Inc(8, x, z); if (c != 0 || (z[7] == P7 && Nat256.Gte(z, P))) { Nat.Add33To(8, PInv33, z); } }
public static void Add(uint[] x, uint[] y, uint[] z) { uint c = Nat256.Add(x, y, z); if (c != 0 || (z[7] >= P7 && Nat256.Gte(z, P))) { AddPInvTo(z); } }
public static void Twice(uint[] x, uint[] z) { uint c = Nat.ShiftUpBit(8, x, 0, z); if (c != 0 || (z[7] >= P7 && Nat256.Gte(z, P))) { AddPInvTo(z); } }
public static uint[] FromBigInteger(BigInteger x) { uint[] numArray = Nat256.FromBigInteger(x); while (Nat256.Gte(numArray, P)) { Nat256.SubFrom(P, numArray); } return(numArray); }
public static void AddOne(uint[] x, uint[] z) { uint c = Nat.Inc(8, x, z); if (c != 0 || (z[7] >= P7 && Nat256.Gte(z, P))) { AddPInvTo(z); } }
public static void Add(uint[] x, uint[] y, uint[] z) { var c = Nat256.Add(x, y, z); if (c != 0 || z[7] == P7 && Nat256.Gte(z, P)) { Nat.Add33To(8, PInv33, z); } }
public static uint[] FromBigInteger(BigInteger x) { uint[] array = Nat256.FromBigInteger(x); if (array[7] == uint.MaxValue && Nat256.Gte(array, P)) { Nat256.SubFrom(P, array); } return array; }
public static uint[] FromBigInteger(BigInteger x) { uint[] z = Nat256.FromBigInteger(x); while (Nat256.Gte(z, P)) { Nat256.SubFrom(P, z); } return(z); }
public static void Twice(uint[] x, uint[] z) { uint c = Nat.ShiftUpBit(8, x, 0, z); if (c != 0 || (z[7] == P7 && Nat256.Gte(z, P))) { Nat.Add33To(8, PInv33, z); } }
public static void Reduce27(uint x, uint[] z) { uint num = z[7]; uint num2 = (x << 1) | (num >> 31); num &= 0x7FFFFFFFu; if ((z[7] = num + Nat.AddWordTo(7, num2 * 19, z)) >= 2147483647 && Nat256.Gte(z, P)) { SubPFrom(z); } }
public static void Reduce27(uint x, uint[] z) { uint num = z[7]; uint num2 = (x << 1) | (num >> 31); num &= int.MaxValue; if ((z[7] = num + Nat.AddWordTo(7, num2 * 19, z)) >= int.MaxValue && Nat256.Gte(z, P)) { SubPFrom(z); } }
public static void Reduce(uint[] xx, uint[] z) { ulong cc = Nat256.Mul33Add(PInv33, xx, 8, xx, 0, z, 0); uint c = Nat256.Mul33DWordAdd(PInv33, cc, z, 0); Debug.Assert(c == 0 || c == 1); if (c != 0 || (z[7] == P7 && Nat256.Gte(z, P))) { Nat.Add33To(8, PInv33, z); } }
public static void Reduce27(uint x, uint[] z) { uint num = z[7]; uint num2 = x << 1 | num >> 31; num &= 2147483647u; num += Nat.AddWordTo(7, num2 * 19u, z); z[7] = num; if (num >= 2147483647u && Nat256.Gte(z, Curve25519Field.P)) { Curve25519Field.SubPFrom(z); } }
public static void Reduce27(uint x, uint[] z) { uint num = z[7]; uint num2 = (x << 1) | (num >> 0x1f); num &= 0x7fffffff; num += Nat.AddWordTo(7, num2 * 0x13, z); z[7] = num; if ((num >= 0x7fffffff) && Nat256.Gte(z, P)) { SubPFrom(z); } }
public static void Reduce(uint[] xx, uint[] z) { uint num = xx[7]; Nat.ShiftUpBit(8, xx, 8, num, z, 0); uint num2 = Nat256.MulByWordAddTo(19u, xx, z) << 1; uint num3 = z[7]; num2 += (num3 >> 31) - (num >> 31); num3 &= 0x7FFFFFFFu; if ((z[7] = num3 + Nat.AddWordTo(7, num2 * 19, z)) >= 2147483647 && Nat256.Gte(z, P)) { SubPFrom(z); } }
public static void Reduce27(uint x, uint[] z) { Debug.Assert(x >> 26 == 0); uint z7 = z[7]; uint c = (x << 1 | z7 >> 31); z7 &= P7; z7 += Nat.AddWordTo(7, c * PInv, z); z[7] = z7; if (z7 >= P7 && Nat256.Gte(z, P)) { SubPFrom(z); } }
public static void Reduce32(uint x, uint[] z) { long cc = 0; if (x != 0) { long xx08 = x; cc += (long)z[0] + xx08; z[0] = (uint)cc; cc >>= 32; if (cc != 0) { cc += (long)z[1]; z[1] = (uint)cc; cc >>= 32; cc += (long)z[2]; z[2] = (uint)cc; cc >>= 32; } cc += (long)z[3] - xx08; z[3] = (uint)cc; cc >>= 32; if (cc != 0) { cc += (long)z[4]; z[4] = (uint)cc; cc >>= 32; cc += (long)z[5]; z[5] = (uint)cc; cc >>= 32; } cc += (long)z[6] - xx08; z[6] = (uint)cc; cc >>= 32; cc += (long)z[7] + xx08; z[7] = (uint)cc; cc >>= 32; Debug.Assert(cc == 0 || cc == 1); } if (cc != 0 || (z[7] == P7 && Nat256.Gte(z, P))) { AddPInvTo(z); } }
public static void Reduce(uint[] xx, uint[] z) { uint num = xx[7]; Nat.ShiftUpBit(8, xx, 8, num, z, 0); uint num2 = Nat256.MulByWordAddTo(19u, xx, z) << 1; uint num3 = z[7]; num2 += (num3 >> 31) - (num >> 31); num3 &= 2147483647u; num3 += Nat.AddWordTo(7, num2 * 19u, z); z[7] = num3; if (num3 >= 2147483647u && Nat256.Gte(z, Curve25519Field.P)) { Curve25519Field.SubPFrom(z); } }
public static void Reduce(uint[] xx, uint[] z) { uint c = xx[7]; Nat.ShiftUpBit(8, xx, 8, c, z, 0); uint num2 = Nat256.MulByWordAddTo(0x13, xx, z) << 1; uint num3 = z[7]; num2 += (num3 >> 0x1f) - (c >> 0x1f); num3 &= 0x7fffffff; num3 += Nat.AddWordTo(7, num2 * 0x13, z); z[7] = num3; if ((num3 >= 0x7fffffff) && Nat256.Gte(z, P)) { SubPFrom(z); } }
public static void Reduce(uint[] xx, uint[] z) { Debug.Assert(xx[15] >> 30 == 0); uint xx07 = xx[7]; Nat.ShiftUpBit(8, xx, 8, xx07, z, 0); uint c = Nat256.MulByWordAddTo(PInv, xx, z) << 1; uint z07 = z[7]; z[7] = z07 & P7; c += (z07 >> 31) - (xx07 >> 31); Nat.AddWordTo(8, c * PInv, z); if (Nat256.Gte(z, P)) { AddPInvTo(z); } }
public static void Reduce(uint[] xx, uint[] z) { Debug.Assert(xx[15] >> 30 == 0); uint xx07 = xx[7]; Nat.ShiftUpBit(8, xx, 8, xx07, z, 0); uint c = Nat256.MulByWordAddTo(PInv, xx, z) << 1; uint z7 = z[7]; c += (z7 >> 31) - (xx07 >> 31); z7 &= P7; z7 += Nat.AddWordTo(7, c * PInv, z); z[7] = z7; if (z7 >= P7 && Nat256.Gte(z, P)) { SubPFrom(z); } }
public static void Reduce32(uint x, uint[] z) { long num = 0L; if (x != 0) { long num2 = x; num += z[0] + num2; z[0] = (uint)num; num >>= 32; if (num != 0) { num += z[1]; z[1] = (uint)num; num >>= 32; num += z[2]; z[2] = (uint)num; num >>= 32; } num += z[3] - num2; z[3] = (uint)num; num >>= 32; if (num != 0) { num += z[4]; z[4] = (uint)num; num >>= 32; num += z[5]; z[5] = (uint)num; num >>= 32; } num += z[6] - num2; z[6] = (uint)num; num >>= 32; num += z[7] + num2; z[7] = (uint)num; num >>= 32; } if (num != 0 || (z[7] == uint.MaxValue && Nat256.Gte(z, P))) { AddPInvTo(z); } }
public static void Reduce32(uint x, uint[] z) { if ((x != 0 && Nat256.Mul33WordAdd(977u, x, z, 0) != 0) || (z[7] == uint.MaxValue && Nat256.Gte(z, P))) { Nat.Add33To(8, 977u, z); } }
private static bool CheckScalarVar(byte[] s) { uint[] n = new uint[ScalarUints]; DecodeScalar(s, 0, n); return(!Nat256.Gte(n, L)); }
private static bool CheckScalarVar(byte[] s, uint[] n) { DecodeScalar(s, 0, n); return(!Nat256.Gte(n, L)); }