private static void RP(uint[] nc, uint[] d1, uint[] e1, uint[] f1, uint[] t) { Nat224.Copy(nc, f1); uint[] array = Nat224.Create(); uint[] array2 = Nat224.Create(); for (int i = 0; i < 7; i++) { Nat224.Copy(d1, array); Nat224.Copy(e1, array2); int num = 1 << i; while (--num >= 0) { SecP224R1FieldElement.RS(d1, e1, f1, t); } SecP224R1FieldElement.RM(nc, array, array2, d1, e1, f1, t); } }
private static bool TrySqrt(uint[] nc, uint[] r, uint[] t) { uint[] array = Nat224.Create(); Nat224.Copy(r, array); uint[] array2 = Nat224.Create(); array2[0] = 1u; uint[] array3 = Nat224.Create(); SecP224R1FieldElement.RP(nc, array, array2, array3, t); uint[] array4 = Nat224.Create(); uint[] z = Nat224.Create(); for (int i = 1; i < 96; i++) { Nat224.Copy(array, array4); Nat224.Copy(array2, z); SecP224R1FieldElement.RS(array, array2, array3, t); if (Nat224.IsZero(array)) { Mod.Invert(SecP224R1Field.P, z, t); SecP224R1Field.Multiply(t, array4, t); return(true); } } return(false); }