ECUtil { public static byte[] createUncompressedPublicKey(ECPublicKey ecPublicKey) { byte[] x = convertToFixedByteArray(ecPublicKey.getW().getAffineX()); byte[] y = convertToFixedByteArray(ecPublicKey.getW().getAffineY()); byte format = 0x04; return ByteBuffer.allocate(65) .put(format) .put(x) .put(y) .array(); } private  ECUtil(); static byte[] createUncompressedPublicKey(ECPublicKey ecPublicKey); static byte[] convertToFixedByteArray(BigInteger value); static byte[] convertToFixedByteArray(int fixedSize, BigInteger value); static KeyPair createKeyPair(); static PublicKey createPublicKey(ECPublicKeySpec ecPublicKeySpec); static PrivateKey createPrivateKey(ECPrivateKeySpec ecPrivateKeySpec); static KeyPair createKeyPair(byte[] seed, ECParameterSpec ecParameterSpec); static KeyPair createKeyPair(byte[] seed); static KeyPair createKeyPair(ECParameterSpec ecParameterSpec); static PublicKey createPublicKeyFromUncompressed(byte[] publicKey); static final ECParameterSpec P_256_SPEC; static final ECParameterSpec P_384_SPEC; static final ECParameterSpec P_521_SPEC; }
@Test void createUncompressedPublicKey_test() { ECPublicKey publicKey = (ECPublicKey) TestAttestationUtil.load2tierTestRootCAPublicKey(); byte[] uncompressed = ECUtil.createUncompressedPublicKey(publicKey); assertThat(uncompressed).hasSize(65); assertThat(uncompressed).isEqualTo(Base64UrlUtil.decode("BM13LrnFulQ14TNByrUKAXrIakbDx5QPf5R2W_nKOOtoLboP5lWJSpgo-sE6dY0XGTkXvOkeVmVGjDNBQITd_yI")); }