fromBytes static method
Implementation
static Secp256r1Point fromBytes(List<int> data) {
if (data.length == 1 && data[0] == 0x00) return identity_;
if (data.length == 33 && _isZeroEncoding(data)) return identity_;
if (data.length == 65 && _isZeroEncoding(data)) return identity_;
if (data.length == 33) return fromCompressed(data);
if (data.length == 65) return fromUncompressed(data);
if (data.length == 64) {
// Raw x||y has no infinity encoding: (0, 0) is rejected even though
// the affine identity shares those coordinates.
final p = Secp256r1AffinePoint(
x: Secp256r1Fp.fromBytes(data.sublist(0, 32)),
y: Secp256r1Fp.fromBytes(data.sublist(32, 64)),
);
if (p.isIdentity() || !p.isOnCurve()) {
throw CoreErrors.invalidOperationArguments(
"fromBytes",
reason: "Not on curve.",
);
}
return p.toCurve();
}
throw CoreErrors.invalidOperationArguments(
"fromBytes",
reason: "Invalid point encoding bytes length.",
);
}