toBigint method

BigInt toBigint(
  1. List<int> label,
  2. int outLen
)

Converts pseudo-random bytes into a BigInt with scalar reduction.

This method generates pseudo-random bytes using the toBytesWithReduceScalar method and then converts those bytes into a BigInt. It's commonly used to obtain a random scalar value suitable for cryptographic operations.

Parameters:

  • label: A list of integers representing the label for the pseudo-random data.
  • outLen: The length of the pseudo-random data to generate, specified as an integer.

Returns: A BigInt obtained from the pseudo-random bytes after scalar reduction.

Usage:

MerlinTranscript transcript = MerlinTranscript("MyApp");
BigInt randomScalar = transcript.toBigint("scalar".codeUnits, 32);
// Generate 32 bytes of pseudo-random data with the label "scalar," reduce the result, and convert it into a BigInt.

This method is useful for obtaining random scalar values for cryptographic applications.

Implementation

BigInt toBigint(List<int> label, int outLen) {
  return BigintUtils.fromBytes(toBytesWithReduceScalar(label, outLen),
      byteOrder: Endian.little);
}