deriveSecretScalars static method

List<BigInt> deriveSecretScalars(
  1. Uint8List rand,
  2. Uint8List secretKey,
  3. Uint8List compressedPubKey,
  4. Uint8List aggXOnly,
  5. Uint8List message,
)

Implementation

static List<BigInt> deriveSecretScalars(
  Uint8List rand,
  Uint8List secretKey,
  Uint8List compressedPubKey,
  Uint8List aggXOnly,
  Uint8List message,
) {
  final auxInput = concatBytes([
    rand,
    secretKey,
    compressedPubKey,
    aggXOnly,
    message,
  ]);
  final randPrime = taggedHash('MuSig/nonce', auxInput);

  final k1Hash = taggedHash('MuSig/aux', randPrime);
  final k1 = bytesToBigInt(k1Hash) % secp256k1N;

  final k2Input = concatBytes([randPrime, Uint8List.fromList([0x01])]);
  final k2Hash = taggedHash('MuSig/aux', k2Input);
  final k2 = bytesToBigInt(k2Hash) % secp256k1N;

  return [k1, k2];
}