crypto_sign_keypair static method

int crypto_sign_keypair(
  1. Uint8List pk,
  2. Uint8List sk,
  3. Uint8List seed
)

The crypto_sign_keypair function randomly generates a secret key and a corresponding public key. It puts the secret key into sk and public key into pk. It returns 0 on success.

Implementation

static int crypto_sign_keypair(Uint8List pk, Uint8List sk, Uint8List seed) {
  final k = Uint8List(64);
  final p = List<Int32List>.generate(4, (_) => Int32List(16));

  _crypto_hash_off(k, seed, 0, 32);
  k[0] &= 248;
  k[31] &= 127;
  k[31] |= 64;

  _scalarbase(p, k, 0);
  _pack(pk, p);

  for (var i = 0; i < 32; i++) {
    sk[i] = seed[i];
  }
  for (var i = 0; i < 32; i++) {
    sk[i + 32] = pk[i];
  }

  for (var i = 0; i < 64; i++) {
    k[i] = 0;
  }
  return 0;
}