public void TestGenerateRandomElement() { var algebra = new EllipticCurveAlgebra(EllipticCurveID.Prime256v1); var generator = algebra.Generator; (var index, var point) = algebra.GenerateRandomElement(RandomNumberGenerator.Create()); var expected = algebra.GenerateElement(index); Assert.That(point.Equals(expected)); }
public void TestGenerateElement() { var algebra = new EllipticCurveAlgebra(EllipticCurveID.Prime256v1); var generator = algebra.Generator; var groupHandle = ECGroupHandle.CreateByCurveNID((int)EllipticCurveID.Prime256v1); var ctx = BigNumberContextHandle.Create(); var index = SecureBigNumber.FromBigNumber(new BigNumber( BigInteger.Parse("97752369786356789875745735", System.Globalization.NumberStyles.Integer) )); var expected = new ECPoint(groupHandle); ECPointHandle.Multiply(groupHandle, expected.Handle, index.Handle, ECPointHandle.Null, BigNumberHandle.Null, ctx); var result = algebra.GenerateElement(index); Assert.That(result.Equals(expected)); }