cryptoBoxBeforenm static method

Uint8List cryptoBoxBeforenm(
  1. Uint8List pk,
  2. Uint8List sk
)

Implementation

static Uint8List cryptoBoxBeforenm(Uint8List pk, Uint8List sk) {
  RangeError.checkValueInInterval(pk.length, cryptoBoxPublickeybytes,
      cryptoBoxPublickeybytes, 'pk', 'Invalid length');
  RangeError.checkValueInInterval(sk.length, cryptoBoxSecretkeybytes,
      cryptoBoxSecretkeybytes, 'sk', 'Invalid length');

  final _k = calloc<Uint8>(cryptoBoxBeforenmbytes);
  final _pk = pk.toPointer();
  final _sk = sk.toPointer();
  try {
    _cryptoBox
        .crypto_box_beforenm(_k, _pk, _sk)
        .mustSucceed('crypto_box_beforenm');

    return _k.toList(cryptoBoxBeforenmbytes);
  } finally {
    calloc.free(_k);
    calloc.free(_pk);
    calloc.free(_sk);
  }
}