ed25519PublicKeyToX25519 function
Converts an Ed25519 public key to X25519 by the birational map from Edwards to Montgomery form, as the Go client does.
Implementation
Uint8List ed25519PublicKeyToX25519(Uint8List edPublic) {
if (edPublic.length != 32) {
throw ArgumentError('Ed25519 public key must be 32 bytes, got ${edPublic.length}');
}
final out = Uint8List(32);
if (TweetNaClExt.crypto_sign_ed25519_pk_to_x25519_pk(out, edPublic) != 0) {
throw ArgumentError('invalid Ed25519 public key');
}
return out;
}