Function addMixed [src]
Add secp256k1 points, the second being specified using affine coordinates.
Prototype
pub fn addMixed(p: Secp256k1, q: AffineCoordinates) Secp256k1
Parameters
p: Secp256k1
q: AffineCoordinates
Source
pub fn addMixed(p: Secp256k1, q: AffineCoordinates) Secp256k1 {
var t0 = p.x.mul(q.x);
var t1 = p.y.mul(q.y);
var t3 = q.x.add(q.y);
var t4 = p.x.add(p.y);
t3 = t3.mul(t4);
t4 = t0.add(t1);
t3 = t3.sub(t4);
t4 = q.y.mul(p.z);
t4 = t4.add(p.y);
var Y3 = q.x.mul(p.z);
Y3 = Y3.add(p.x);
var X3 = t0.dbl();
t0 = X3.add(t0);
// b3 = (2^2)^2 + 2^2 + 1
const t2_4 = p.z.dbl().dbl();
var t2 = t2_4.dbl().dbl().add(t2_4).add(p.z);
var Z3 = t1.add(t2);
t1 = t1.sub(t2);
const Y3_4 = Y3.dbl().dbl();
Y3 = Y3_4.dbl().dbl().add(Y3_4).add(Y3);
X3 = t4.mul(Y3);
t2 = t3.mul(t1);
X3 = t2.sub(X3);
Y3 = Y3.mul(t0);
t1 = t1.mul(Z3);
Y3 = t1.add(Y3);
t0 = t0.mul(t3);
Z3 = Z3.mul(t4);
Z3 = Z3.add(t0);
var ret = Secp256k1{
.x = X3,
.y = Y3,
.z = Z3,
};
ret.cMov(p, @intFromBool(q.x.isZero()));
return ret;
}