x25519JwkFromX25519PrivateKey function
Converts a X25519 private key to a JWK (JSON Web Key) representation. Returns a Future that completes with the JWK.
Implementation
Future<Map<String, dynamic>> x25519JwkFromX25519PrivateKey(
List<int> privateKey,
) async {
final algorithm = X25519();
final keyPair = await algorithm.newKeyPairFromSeed(privateKey);
final publicKey = await keyPair.extractPublicKey();
final jwk = {
"kty": "OKP",
"crv": "X25519",
"x": base64Url.encode(publicKey.bytes),
"d": base64Url.encode(privateKey),
};
return jwk;
}