k1Shard method

  1. @override
FrostDealerShard k1Shard({
  1. required List<int> secret,
  2. required List<int> coefficients,
  3. required int maxParticipants,
})
override

Dealer shard: 32-byte secret + concatenated 32-byte polynomial coefficients (secret excluded) → one share record per participant (1..=[maxParticipants]).

Implementation

@override
FrostDealerShard k1Shard({
  required List<int> secret,
  required List<int> coefficients,
  required int maxParticipants,
}) {
  if (coefficients.length % 32 != 0) {
    _badArg(
      coefficients.length,
      'Frost.k1Shard',
      'must hold whole 32-byte scalars.',
      'coefficients',
    );
  }
  final result = api.frostK1Shard(
    secret32: secret.asBytes,
    coeffsConcat: coefficients.asBytes,
    nCoeffs: coefficients.length ~/ 32,
    max: maxParticipants,
  );
  return result
      .map(
        (e) => FrostDealerShard(
          shares: _parseShares(e.sharesConcat),
          poly: e.polyConcat,
        ),
      )
      .unwrapOrThrowCryptoError();
}