public void TestCreateCryptoGroup() { var expectedGroupAlgebra = new XOnlyMontgomeryCurveAlgebra(curveParameters); var group = XOnlyMontgomeryCurveAlgebra.CreateCryptoGroup(curveParameters); Assert.AreEqual(expectedGroupAlgebra, group.Algebra); }
public void TestEqualsFalseForDifferent() { var curve = new XOnlyMontgomeryCurveAlgebra(curveParameters); var otherCurve = new XOnlyMontgomeryCurveAlgebra(largeParameters); Assert.IsFalse(curve.Equals(otherCurve)); }
public void TestGetHashCodeSameForEqual() { var curve = new XOnlyMontgomeryCurveAlgebra(curveParameters); var otherCurve = new XOnlyMontgomeryCurveAlgebra(curveParameters); Assert.AreEqual(curve.GetHashCode(), otherCurve.GetHashCode()); }
public void TestEqualsTrueForEqual() { var curve = new XOnlyMontgomeryCurveAlgebra(curveParameters); var otherCurve = new XOnlyMontgomeryCurveAlgebra(curveParameters); Assert.IsTrue(curve.Equals(otherCurve)); }
public void TestXOnlyGenerate(BigInteger k, BigInteger expectedX) { var curve25519Algebra = new XOnlyMontgomeryCurveAlgebra(CurveParameters.Curve25519); var point = curve25519Algebra.GenerateElement(k); Assert.AreEqual(point, expectedX); }
public void TestXOnlyMultiplyScalar(BigInteger k, BigInteger inputX, BigInteger expectedX) { var curve25519Algebra = new XOnlyMontgomeryCurveAlgebra(CurveParameters.Curve25519); var point = curve25519Algebra.MultiplyScalar(inputX, k); Assert.AreEqual(point, expectedX); }
public void TestIsElementForLowOrderElements() { var curve = new XOnlyMontgomeryCurveAlgebra(curveParameters); var p = new BigInteger(0); Assert.IsTrue(curve.IsPotentialElement(p)); Assert.IsFalse(curve.IsSafeElement(p)); }
public void TestNegateThrowsNotSupported() { var point = new BigInteger(2); var algebra = new XOnlyMontgomeryCurveAlgebra(curveParameters); Assert.Throws <NotSupportedException>( () => algebra.Negate(point) ); }
public void TestMultiplyScalar(int k, int x, int expectedX) { var algebra = new XOnlyMontgomeryCurveAlgebra(curveParameters); var p = new BigInteger(x); var result = algebra.MultiplyScalar(p, k); Assert.AreEqual(new BigInteger(expectedX), result); }
public void TestConstructorAndProperties() { var algebra = new XOnlyMontgomeryCurveAlgebra(curveParameters); Assert.AreEqual(curveParameters.Generator.X, algebra.Generator); Assert.AreEqual(curveParameters.Order, algebra.Order); Assert.AreEqual(curveParameters.Cofactor, algebra.Cofactor); Assert.AreEqual(NumberLength.GetLength(curveParameters.Equation.Field.Modulo).InBits, algebra.ElementBitLength); Assert.AreEqual(algebra.OrderBitLength / 2, algebra.SecurityLevel); }
public void TestToBytesWithLessThanOneByteLargeElements() { var curve = new XOnlyMontgomeryCurveAlgebra(curveParameters); var p = new BigInteger(5); var expected = new byte[] { 5 }; var result = curve.ToBytes(p); CollectionAssert.AreEqual(expected, result); }
public void TestFromBytesWithLessThanOneByteLargeElements() { var curve = new XOnlyMontgomeryCurveAlgebra(curveParameters); var expected = new BigInteger(5); var buffer = new byte[] { 5 }; var result = curve.FromBytes(buffer); Assert.AreEqual(expected, result); }
public void TestEqualsFalseForNull() { var curve = new XOnlyMontgomeryCurveAlgebra(curveParameters); Assert.IsFalse(curve.Equals(null)); }