deriveKeyPair function

KeyPair deriveKeyPair(
  1. String seed,
  2. int index, {
  3. String curve = 'ed25519',
  4. bool isSeedHexa = true,
  5. int originId = softwareId,
})

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") @param {int} originId Origin id of the public key (0, 1, 2) = ("on chain wallet", "software", "tpm")

Implementation

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

  final pvBuf = derivePrivateKey(seed, index, isSeedHexa: isSeedHexa);
  return generateDeterministicKeyPair(pvBuf, curve, originId);
}