getEncoded method
return the field element encoded with point compression. (S 4.3.6)
Implementation
@override
Uint8List getEncoded([bool compressed = true]) {
if (isInfinity) {
return Uint8List.fromList([1]);
}
var qLength = x!.byteLength;
if (compressed) {
int pc;
if (_testBit(y!.toBigInteger()!, 0)) {
pc = 0x03;
} else {
pc = 0x02;
}
var X = _x9IntegerToBytes(x!.toBigInteger(), qLength);
var po = Uint8List(X.length + 1);
po[0] = pc.toInt();
po.setAll(1, X);
return po;
} else {
var X = _x9IntegerToBytes(x!.toBigInteger(), qLength);
var Y = _x9IntegerToBytes(y!.toBigInteger(), qLength);
var po = Uint8List(X.length + Y.length + 1);
po[0] = 0x04;
po.setAll(1, X);
po.setAll(X.length + 1, Y);
return po;
}
}