use of java.security.spec.ECPoint in project j2objc by google.
the class ECPointTest method testEqualsObject01.
/**
* Test #1 for <code>equals(Object other)</code> method<br>
* Assertion: return true if this and other objects are equal<br>
* Test preconditions: see test comments<br>
* Expected: all objects in this test must be equal
*/
public final void testEqualsObject01() {
// test case 1: must be equal to itself
ECPoint p2 = null, p1 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.ONE);
assertTrue(p1.equals(p1));
// test case 2: equal objects
p1 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.ONE);
p2 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.valueOf(1L));
assertTrue(p1.equals(p2) && p2.equals(p1));
// test case 3: equal POINT_INFINITY object(s)
p1 = ECPoint.POINT_INFINITY;
p2 = ECPoint.POINT_INFINITY;
assertTrue(p1.equals(p2) && p2.equals(p1));
}
use of java.security.spec.ECPoint in project j2objc by google.
the class ECPointTest method testHashCode01.
/**
* Test #1 for <code>hashCode()</code> method.<br>
*
* Assertion: must return the same value if invoked
* repeatedly on the same object.
*/
public final void testHashCode01() {
ECPoint f = new ECPoint(BigInteger.valueOf(-23457L), BigInteger.ONE);
int hc = f.hashCode();
assertTrue(hc == f.hashCode() && hc == f.hashCode() && hc == f.hashCode() && hc == f.hashCode() && hc == f.hashCode() && hc == f.hashCode() && hc == f.hashCode() && hc == f.hashCode());
// the same for POINT_INFINITY
hc = ECPoint.POINT_INFINITY.hashCode();
assertTrue(hc == ECPoint.POINT_INFINITY.hashCode() && hc == ECPoint.POINT_INFINITY.hashCode() && hc == ECPoint.POINT_INFINITY.hashCode() && hc == ECPoint.POINT_INFINITY.hashCode() && hc == ECPoint.POINT_INFINITY.hashCode() && hc == ECPoint.POINT_INFINITY.hashCode() && hc == ECPoint.POINT_INFINITY.hashCode() && hc == ECPoint.POINT_INFINITY.hashCode());
}
use of java.security.spec.ECPoint in project j2objc by google.
the class ECPointTest method testEqualsObject02.
/**
* Test #2 for <code>equals(Object other)</code> method<br>
* Assertion: return false if this and other objects are not equal<br>
* Test preconditions: see test comments<br>
* Expected: all objects in this test must be not equal
*/
public final void testEqualsObject02() {
// test case 1: must be not equal to null
ECPoint p2 = null, p1 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.ONE);
assertFalse(p1.equals(p2));
// test case 2: not equal objects - x
p1 = new ECPoint(BigInteger.valueOf(-23457L), BigInteger.ONE);
p2 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.valueOf(1L));
assertFalse(p1.equals(p2) || p2.equals(p1));
// test case 3: not equal objects - y
p1 = new ECPoint(BigInteger.valueOf(-23457L), BigInteger.ONE);
p2 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.ZERO);
assertFalse(p1.equals(p2) || p2.equals(p1));
// test case 4: not equal - some point and POINT_INFINITY
p1 = ECPoint.POINT_INFINITY;
p2 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.ZERO);
assertFalse(p1.equals(p2) || p2.equals(p1));
}
use of java.security.spec.ECPoint in project j2objc by google.
the class ECPointTest method testHashCode02.
/**
* Test #2 for <code>hashCode()</code> method.<br>
*
* Assertion: must return the same value if invoked
* on equal (according to the <code>equals(Object)</code> method) objects.
*/
public final void testHashCode02() {
ECPoint p1 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.ONE);
ECPoint p2 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.valueOf(1L));
assertEquals(p1.hashCode(), p2.hashCode());
}
use of java.security.spec.ECPoint in project j2objc by google.
the class ECPrivateKeySpecTest method setUp.
protected void setUp() throws Exception {
super.setUp();
ECPoint ecpoint = new ECPoint(BigInteger.valueOf(1), BigInteger.valueOf(1));
EllipticCurve curve = new EllipticCurve(new ECFieldF2m(2), BigInteger.valueOf(1), BigInteger.valueOf(1));
s = BigInteger.valueOf(1);
ecparams = new ECParameterSpec(curve, ecpoint, BigInteger.valueOf(1), 1);
ecpks = new ECPrivateKeySpec(s, ecparams);
}
Aggregations