toDer method
Constructs DER encoding of this public key.
The implementation generates DER encodings identical to those generated by Apple CryptoKit.
Implementation
Uint8List toDer() {
final config = CupertinoEcDer.get(type);
final numberLength = config.numberLength;
final x = this.x;
if (x.length != numberLength) {
throw StateError(
'$this parameter "x" should have $numberLength bytes, not ${x.length}',
);
}
final y = this.y;
if (y.length != numberLength) {
throw StateError(
'$this parameter "y" should have $numberLength bytes, not ${y.length}',
);
}
return Uint8List.fromList([
...config.publicKeyPrefix,
...x,
...y,
]);
}