deriveKeyPair function

KeyPair deriveKeyPair(
  1. String seed,
  2. int index, {
  3. String curve = 'ed25519',
})

Generate a keypair using a derivation function with a seed and an index. Each keys is prepending with a curve identification. @param {String} seed Keypair derivation seed @param {int} index Number to identify the order of keys to generate @param {String} curve Elliptic curve to use ("P256", "secp256k1", "ed25519")

Implementation

KeyPair deriveKeyPair(String seed, int index, {String curve = 'ed25519'}) {
  if (index < 0) {
    throw "index' must be a positive number";
  }

  final Uint8List pvBuf = derivePrivateKey(seed, index);
  return generateDeterministicKeyPair(pvBuf, curve, softwareId);
}