toBytesWithReduceScalar method
Generates pseudo-random bytes and reduces them using scalar reduction.
This method generates pseudo-random bytes based on the current transcript state and applies scalar reduction to the output. Scalar reduction ensures that the result is a valid scalar value used in cryptographic operations. It takes a label and an output length as parameters and appends the label to the transcript.
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 List<int>
containing the pseudo-random bytes of the specified length after scalar reduction.
Usage:
MerlinTranscript transcript = MerlinTranscript("MyApp");
List<int> randomScalar = transcript.toBytesWithReduceScalar("scalar".codeUnits, 32);
// Generate 32 bytes of pseudo-random data with the label "scalar," and reduce the result to a valid scalar value.
This method is particularly useful for generating random scalars used in cryptographic operations.
Implementation
List<int> toBytesWithReduceScalar(List<int> label, int outLen) {
return Ed25519Utils.scalarReduce(toBytes(label, outLen));
}