raw property
Returns the key's raw bytes
Implementation
@override
Uint8List get raw {
try {
// Get the private value
final d = _key.d!;
// Get the public key point
final q = _publicKey._key.Q!;
// Create a simple ASN.1 sequence with the private value and public key coordinates
final asn1Sequence = pc.ASN1Sequence();
asn1Sequence.add(pc.ASN1Integer(d));
asn1Sequence.add(pc.ASN1Integer(q.x!.toBigInteger()!));
asn1Sequence.add(pc.ASN1Integer(q.y!.toBigInteger()!));
return Uint8List.fromList(asn1Sequence.encode());
} catch (e) {
throw ECDSAKeyException('Failed to encode ECDSA private key: ${e.toString()}');
}
}