generateConstants<F extends PastaFieldElement<F>> static method

MdsGenerateResult<F> generateConstants<F extends PastaFieldElement<F>>({
  1. required F fromBytes(
    1. List<int> bytes
    ),
  2. required F zero,
  3. required F one,
  4. int rate = 2,
  5. int width = 3,
  6. int fullRounds = 8,
  7. int partialRounds = 56,
  8. int secureMds = 0,
})

Implementation

static MdsGenerateResult<F>
generateConstants<F extends PastaFieldElement<F>>({
  required F Function(List<int> bytes) fromBytes,
  required F zero,
  required F one,
  int rate = 2,
  int width = 3,
  int fullRounds = 8,
  int partialRounds = 56,
  int secureMds = 0,
}) {
  final sbox = SboxType.pow;
  final Grain<F> grain = Grain<F>(
    sbox: sbox,
    t: width,
    fromBytes: fromBytes,
    rF: fullRounds,
    rP: partialRounds,
  );
  final iter = fullRounds + partialRounds;
  final roundConstants = List<List<F>>.generate(iter, (_) {
    return List<F>.generate(width, (i) => grain.nextFieldElement());
  });
  final mds = generateMds<F>(grain, width, secureMds, one, zero);
  return MdsGenerateResult(
    mds: mds.mds,
    mdsInv: mds.mdsInv,
    constants: roundConstants,
  );
}