/** Test method for {@link GroupElement#cmov(GroupElement, int)}. */ @Test public void testCmov() { GroupElement a = curve.getZero(GroupElement.Representation.PRECOMP); GroupElement b = GroupElement.precomp(curve, TWO, ZERO, TEN); assertThat(a.cmov(b, 0), is(equalTo(a))); assertThat(a.cmov(b, 1), is(equalTo(b))); }
/** * Test method for {@link GroupElement#precomp(Curve, FieldElement, FieldElement, FieldElement)}. */ @Test public void testPrecomp() { final GroupElement t = GroupElement.precomp(curve, ONE, ONE, ZERO); assertThat(t.curve, is(equalTo(curve))); assertThat(t.repr, is(GroupElement.Representation.PRECOMP)); assertThat(t.X, is(ONE)); assertThat(t.Y, is(ONE)); assertThat(t.Z, is(ZERO)); assertThat(t.T, is((FieldElement) null)); }
/** Test method for {@link GroupElement#select(int, int)}. */ @Test public void testSelect() { GroupElement B = ed25519.getB(); for (int i = 0; i < 32; i++) { // 16^i 0 B assertThat( i + ",0", B.select(i, 0), is(equalTo(GroupElement.precomp(curve, ONE, ONE, ZERO)))); for (int j = 1; j < 8; j++) { // 16^i r_i B GroupElement t = B.select(i, j); assertThat(i + "," + j, t, is(equalTo(B.precmp[i][j - 1]))); // -16^i r_i B t = B.select(i, -j); GroupElement neg = GroupElement.precomp( curve, B.precmp[i][j - 1].Y, B.precmp[i][j - 1].X, B.precmp[i][j - 1].Z.negate()); assertThat(i + "," + -j, t, is(equalTo(neg))); } } }