@Test
    public void pkcs8AndX509EncodedKeys_work() throws Exception {
        // Test vectors from https://datatracker.ietf.org/doc/html/rfc8032#section-7
        // Encoding from https://datatracker.ietf.org/doc/html/rfc8410
        byte[] pkcs8EncodedPrivateKey = decodeHex(
                // PKCS#8 header
                "302e020100300506032b657004220420"
                // raw private key
                + "9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60");
        byte[] x509EncodedPublicKey = decodeHex(
                // X.509 header
                "302a300506032b6570032100"
                // raw public key
                + "d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a");
        byte[] message = decodeHex("");
        byte[] expectedSig =
                decodeHex("e5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e06522490155"
                        + "5fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b");

        KeyFactory keyFactory = KeyFactory.getInstance("Ed25519", conscryptProvider);
        PrivateKey privateKey =
                keyFactory.generatePrivate(new PKCS8EncodedKeySpec(pkcs8EncodedPrivateKey));
        PublicKey publicKey =
                keyFactory.generatePublic(new X509EncodedKeySpec(x509EncodedPublicKey));

        Signature signature = Signature.getInstance("Ed25519", conscryptProvider);

        signature.initSign(privateKey);
        signature.update(message);
        byte[] sig = signature.sign();
        assertArrayEquals(expectedSig, sig);

        signature.initVerify(publicKey);
        signature.update(message);
        assertTrue(signature.verify(sig));
    }
Implements a KeySpec that contains the raw bytes of a key.
common/src/test/java/org/conscrypt/EdDsaTest.java