/** * Test method for {@link GroupElement#p3(Curve, FieldElement, FieldElement, FieldElement, * FieldElement)}. */ @Test public void testP3() { final GroupElement t = GroupElement.p3(curve, ZERO, ONE, ONE, ZERO); assertThat(t.curve, is(equalTo(curve))); assertThat(t.repr, is(GroupElement.Representation.P3)); assertThat(t.X, is(ZERO)); assertThat(t.Y, is(ONE)); assertThat(t.Z, is(ONE)); assertThat(t.T, is(ZERO)); }
@Test public void addingNeutralGroupElementDoesNotChangeGroupElement() { final GroupElement neutral = GroupElement.p3( curve, curve.getField().ZERO, curve.getField().ONE, curve.getField().ONE, curve.getField().ZERO); for (int i = 0; i < 1000; i++) { // Arrange: final GroupElement g = MathUtils.getRandomGroupElement(); // Act: final GroupElement h1 = g.add(neutral.toCached()); final GroupElement h2 = neutral.add(g.toCached()); // Assert: Assert.assertThat(g, IsEqual.equalTo(h1)); Assert.assertThat(g, IsEqual.equalTo(h2)); } }
/** Test method for {@link GroupElement#GroupElement(Curve, byte[])}. */ @Test public void testGroupElementByteArray() { final GroupElement t = new GroupElement(curve, BYTES_PKR); final GroupElement s = GroupElement.p3(curve, PKR[0], PKR[1], ONE, PKR[0].multiply(PKR[1])); assertThat(t, is(equalTo(s))); }