cryptoSignEd25519PkToCurve25519 static method

Uint8List cryptoSignEd25519PkToCurve25519(
  1. Uint8List ed25519Pk
)

Implementation

static Uint8List cryptoSignEd25519PkToCurve25519(Uint8List ed25519Pk) {
  RangeError.checkValueInInterval(
      ed25519Pk.length,
      cryptoSignEd25519Publickeybytes,
      cryptoSignEd25519Publickeybytes,
      'ed25519Pk',
      'Invalid length');

  final _curve25519Pk = calloc<Uint8>(cryptoScalarmultCurve25519Bytes);
  final _ed25519Pk = ed25519Pk.toPointer();
  try {
    _cryptoSign
        .crypto_sign_ed25519_pk_to_curve25519(_curve25519Pk, _ed25519Pk)
        .mustSucceed('crypto_sign_ed25519_pk_to_curve25519');
    return _curve25519Pk.toList(cryptoScalarmultCurve25519Bytes);
  } finally {
    calloc.free(_curve25519Pk);
    calloc.free(_ed25519Pk);
  }
}