public void Test_SECP192r1() { SECP192r1 secp = new SECP192r1(); Number max1 = secp.ToElement(SECP192r1.PRIME - Number.One); Number max2 = secp.ToElement(SECP192r1.PRIME - new Number(new uint[] { 0, 0, 1, 0, 0, 0 })); Number hoge = secp.Multiply(max1, max2); }
static ECDomainParameters Create_secp192r1() { SECP192r1 ff = new SECP192r1(); Number a = new Number(new uint[] { 4294967292, 4294967295, 4294967294, 4294967295, 4294967295, 4294967295 }); Number b = new Number(new uint[] { 3242637745, 4273528556, 1914974281, 262662571, 3852239079, 1679885593 }); Number gX = new Number(new uint[] { 2197753874, 4110355197, 1134659584, 2092900587, 2955972854, 411936782 }); Number gY = new Number(new uint[] { 511264785, 1945728929, 1797574101, 1661997549, 4291353208, 119090069 }); Number order = new Number(new uint[] { 3033671729, 342608305, 2581526582, 4294967295, 4294967295, 4294967295 }); return(Create(a, b, gX, gY, order, 1, ff, _oidReverseMap[ECDomainNames.secp192r1])); }
public void SqrtTest() { IFiniteField[] ffList = new IFiniteField[2]; ffList[0] = new SECP192r1(); ffList[1] = new Montgomery(ffList[0].Modulus); int repeats = 10; foreach (IFiniteField ff in ffList) { for (int i = 0; i < repeats; i++) { Number x = ff.ToElement(Number.CreateRandomElement(ff.Modulus)); Number xx = ff.Multiply(x, x); Number sqrt = ff.Sqrt(xx); Assert.IsTrue(ff.Multiply(sqrt, sqrt).CompareTo(xx) == 0); } } }
public void PowTest() { IFiniteField[] ffList = new IFiniteField[2]; ffList[0] = new SECP192r1(); ffList[1] = new Montgomery(ffList[0].Modulus); foreach (IFiniteField ff in ffList) { Number x = ff.ToElement(Number.CreateRandomElement(ff.Modulus)); Number pow2 = ff.Multiply(x, x); Number pow3 = ff.Multiply(pow2, x); Number pow4 = ff.Multiply(pow3, x); Assert.IsTrue(ff.Pow(x, Number.Zero).CompareTo(ff.ToElement(Number.One)) == 0); Assert.IsTrue(ff.Pow(x, Number.One).CompareTo(x) == 0); Assert.IsTrue(ff.Pow(x, Number.Two).CompareTo(pow2) == 0); Assert.IsTrue(ff.Pow(x, Number.Three).CompareTo(pow3) == 0); Assert.IsTrue(ff.Pow(x, Number.Four).CompareTo(pow4) == 0); } }