示例#1
0
        public void TestEquals()
        {
            ECPoint point = ECCurve.Secp256k1.G;

            point.Equals(point).Should().BeTrue();
            point.Equals(null).Should().BeFalse();

            point = new ECPoint(null, null, ECCurve.Secp256k1);
            point.Equals(new ECPoint(null, null, ECCurve.Secp256r1)).Should().BeTrue();
            point.Equals(ECCurve.Secp256r1.G).Should().BeFalse();
            ECCurve.Secp256r1.G.Equals(point).Should().BeFalse();

            ECFieldElement X1     = new ECFieldElement(new BigInteger(100), ECCurve.Secp256k1);
            ECFieldElement Y1     = new ECFieldElement(new BigInteger(200), ECCurve.Secp256k1);
            ECFieldElement X2     = new ECFieldElement(new BigInteger(300), ECCurve.Secp256k1);
            ECFieldElement Y2     = new ECFieldElement(new BigInteger(400), ECCurve.Secp256k1);
            ECPoint        point1 = new ECPoint(X1, Y1, ECCurve.Secp256k1);
            ECPoint        point2 = new ECPoint(X2, Y1, ECCurve.Secp256k1);
            ECPoint        point3 = new ECPoint(X1, Y2, ECCurve.Secp256k1);

            point1.Equals(point2).Should().BeFalse();
            point1.Equals(point3).Should().BeFalse();
        }