cryptoBoxSeedKeypair static method

KeyPair cryptoBoxSeedKeypair(
  1. Uint8List seed
)

Implementation

static KeyPair cryptoBoxSeedKeypair(Uint8List seed) {
  RangeError.checkValueInInterval(seed.length, cryptoBoxSeedbytes,
      cryptoBoxSeedbytes, 'seed', 'Invalid length');
  final _pk = calloc<Uint8>(cryptoBoxPublickeybytes);
  final _sk = calloc<Uint8>(cryptoBoxSecretkeybytes);
  final _seed = seed.toPointer();

  try {
    _cryptoBox
        .crypto_box_seed_keypair(_pk, _sk, _seed)
        .mustSucceed('crypto_box_seed_keypair');
    return KeyPair(
        pk: _pk.toList(cryptoBoxPublickeybytes),
        sk: _sk.toList(cryptoBoxSecretkeybytes));
  } finally {
    calloc.free(_pk);
    calloc.free(_sk);
    calloc.free(_seed);
  }
}