Function fromAffineCoordinates [src]
Create a point from affine coordinates after checking that they match the curve equation.
Prototype
pub fn fromAffineCoordinates(p: AffineCoordinates) EncodingError!P256
Parameters
p: AffineCoordinates
Possible Errors
Source
pub fn fromAffineCoordinates(p: AffineCoordinates) EncodingError!P256 {
const x = p.x;
const y = p.y;
const x3AxB = x.sq().mul(x).sub(x).sub(x).sub(x).add(B);
const yy = y.sq();
const on_curve = @intFromBool(x3AxB.equivalent(yy));
const is_identity = @intFromBool(x.equivalent(AffineCoordinates.identityElement.x)) & @intFromBool(y.equivalent(AffineCoordinates.identityElement.y));
if ((on_curve | is_identity) == 0) {
return error.InvalidEncoding;
}
var ret = P256{ .x = x, .y = y, .z = Fe.one };
ret.z.cMov(P256.identityElement.z, is_identity);
return ret;
}