nonceGenerate method

  1. @override
MuSig2Nonce nonceGenerate({
  1. required List<int> publicKey,
  2. List<int>? rand,
  3. List<int>? sk,
  4. List<int>? aggPubKey,
  5. List<int>? msg,
  6. List<int>? extra,
})
override

Generates a MuSig2 nonce for signing publicKey is 33 bytes (compressed); optional 32-byte rand (random if null) and 32-byte sk (binds nonce to key); aggPubKey, msg and extra bind the nonce hash. Returns the 97-byte secret nonce with its 66-byte public nonce. Throws on invalid lengths.

Implementation

@override
MuSig2Nonce nonceGenerate({
  required List<int> publicKey,
  List<int>? rand,
  List<int>? sk,
  List<int>? aggPubKey,
  List<int>? msg,
  List<int>? extra,
}) {
  ApiValidate.length(
    publicKey,
    33,
    operation: '$_tag.nonceGenerate',
    name: 'publicKey',
  );
  if (sk != null) {
    ApiValidate.length(sk, 32, operation: '$_tag.nonceGenerate', name: 'sk');
  }
  if (rand != null) {
    ApiValidate.length(
      rand,
      32,
      operation: '$_tag.nonceGenerate',
      name: 'rand',
    );
  }
  return ApiValidate.call(
    '$_tag.nonceGenerate',
    () => inner.nonceGenerate(
      publicKey: publicKey,
      rand: rand,
      sk: sk,
      aggPubKey: aggPubKey,
      msg: msg,
      extra: extra,
    ),
  );
}