toDer static method
DER-encodes a SEQUENCE of INTEGERs from raw unsigned big-endian byte
arrays (e.g. [signature.r, signature.s]).
Unlike BigInt.toBeBytes(), a fixed-length byte array (e.g. 32 bytes)
may carry leading zero bytes that aren't part of the integer's minimal
representation — those are stripped before DER-encoding each value.
Implementation
static BuBytes toDer(List<List<int>> values) {
final List<BuBytes> encodedIntegers =
values.map((bytes) => _encodeInteger(bytes)).toList();
final content = encodedIntegers.expand((e) => e);
final BuBytes lengthBytes = _encodeLength(content.length);
return BuBytes([0x30, ...lengthBytes, ...encodedIntegers.expand((e) => e)]);
}