예제 #1
0
        public override bool Equals(Object other)
        {
            if (other == null)
            {
                return(false);
            }
            if (!(other is DjbECPublicKey))
            {
                return(false);
            }

            DjbECPublicKey that = (DjbECPublicKey)other;

            return(Enumerable.SequenceEqual(this.publicKey, that.publicKey));
        }
예제 #2
0
		public void TestECPublicKeyEquals()
		{
			curve25519.Curve25519Native native = new curve25519.Curve25519Native();
			byte[] privKey = native.generatePrivateKey();
			byte[] pubKey = native.generatePublicKey(privKey);
			DjbECPublicKey key1 = new DjbECPublicKey(pubKey);

			byte[] pubKey2 = native.generatePublicKey(privKey);

			Assert.IsTrue(StructuralComparisons.StructuralEqualityComparer.Equals(
					pubKey, pubKey2));

			DjbECPublicKey key2 = new DjbECPublicKey(pubKey2);

			Assert.IsTrue(key1.Equals(key2));

			int hash1 = key1.GetHashCode();
			int hash2 = key2.GetHashCode();

			Assert.AreEqual<int>(hash1, hash2);
		}