### Question:
PublicKey extends Key { public static PublicKey fromHexString(final String hex) { return new PublicKey(hex); } PublicKey(byte[] bytes);  PublicKey(BigInteger value);  PublicKey(String hex); static PublicKey fromHexString(final String hex); static PublicKey generateRandom(); static final int SIZE; }### Answer:
@Test public void canCreateFromHexString() { final PublicKey key = PublicKey.fromHexString("227F"); Assertions.assertEquals(PublicKey.SIZE, key.getSize()); MatcherAssert.assertThat( key.getBytes(), IsEqual.equalTo(ByteUtils.byteArrayLeadingZeros(new byte[] {0x22, 0x7F}, PublicKey.SIZE))); }
@Test public void shouldBeEquals() { final PublicKey key1 = PublicKey.fromHexString("227F"); final PublicKey key2 = PublicKey.fromHexString("227F"); final PublicKey key3 = PublicKey.fromHexString("327F"); MatcherAssert.assertThat(key1, IsEqual.equalTo(key2)); MatcherAssert.assertThat(key1, IsNot.not(IsEqual.equalTo(key3))); }
@Test public void cannotCreateAroundMalformedHexString() { Assertions.assertThrows(IllegalArgumentException.class, () -> PublicKey.fromHexString("22G75")); }