toDer static method
Converts a list of BigInt values to DER-encoded bytes.
The toDer method takes a list of BigInt values bigIntList
and encodes them in DER format.
It returns a list of bytes representing the DER-encoded sequence of integers.
Example Usage:
List<BigInt> values = [BigInt.from(123), BigInt.from(456)];
`List<int>` derBytes = DEREncoding.toDer(values);
Parameters:
bigIntList
: The list of BigInt values to be DER-encoded. Returns: A list of bytes representing the DER-encoded sequence of integers.
Implementation
static List<int> toDer(List<BigInt> bigIntList) {
final List<List<int>> encodedIntegers = bigIntList.map((bi) {
final List<int> bytes = _encodeInteger(bi);
return bytes;
}).toList();
final content = encodedIntegers.expand((e) => e);
final List<int> lengthBytes = _encodeLength(content.length);
final derBytes = [
0x30,
...lengthBytes,
...encodedIntegers.expand((e) => e)
];
return derBytes;
}