deriveKeyPair static method

List<int> deriveKeyPair(
  1. List<int> seed
)

Derives a key pair from the given seed using a multi-step process.

This method takes a seed as input and performs a series of steps to derive a key pair. It then returns the derived key pair as a list of integers.

Implementation

static List<int> deriveKeyPair(List<int> seed) {
  // Obtain the order of the Secp256k1 curve generator.
  final BigInt order = Curves.generatorSecp256k1.order!;

  // Calculate the root value using the provided seed.
  final BigInt root = _getSecret(seed);

  // Generate a new public point using the Secp256k1 curve and the root value.
  final newPubPoint = Curves.generatorSecp256k1 * root;

  // Calculate the intermediate value using the new public point.
  final BigInt mid = _getSecret(newPubPoint.toBytes(), isMid: true);

  // Calculate the final key pair value by combining the root and intermediate values.
  final BigInt finalPair = (root + mid) % order;

  // Convert the final key pair value to a byte array representation with a specific length.
  return BigintUtils.toBytes(finalPair, length: BigintUtils.orderLen(order));
}