Here are the examples of the java api org.vision.common.crypto.zksnark.Params.TWIST.mul() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
19
Source : PairingCheck.java
with GNU Lesser General Public License v3.0
from vision-consensus
with GNU Lesser General Public License v3.0
from vision-consensus
private static Precomputed flippedMillerLoopMixedAddition(BN128G2 base, BN128G2 addend) {
Fp2 x1 = addend.x, y1 = addend.y, z1 = addend.z;
Fp2 x2 = base.x, y2 = base.y;
// d = x1 - x2 * z1
Fp2 d = x1.sub(x2.mul(z1));
// e = y1 - y2 * z1
Fp2 e = y1.sub(y2.mul(z1));
// f = d^2
Fp2 f = d.squared();
// g = e^2
Fp2 g = e.squared();
// h = d * f
Fp2 h = d.mul(f);
// i = x1 * f
Fp2 i = x1.mul(f);
// j = h + z1 * g - 2 * i
Fp2 j = h.add(z1.mul(g)).sub(i.dbl());
// x3 = d * j
Fp2 x3 = d.mul(j);
// y3 = e * (i - j) - h * y1)
Fp2 y3 = e.mul(i.sub(j)).sub(h.mul(y1));
// z3 = Z1*H
Fp2 z3 = z1.mul(h);
// ell_0 = TWIST * (e * x2 - d * y2)
Fp2 ell0 = TWIST.mul(e.mul(x2).sub(d.mul(y2)));
// ell_VV = -e
Fp2 ellVV = e.negate();
// ell_VW = d
Fp2 ellVW = d;
return Precomputed.of(new BN128G2(x3, y3, z3), new EllCoeffs(ell0, ellVW, ellVV));
}
17
Source : PairingCheck.java
with GNU Lesser General Public License v3.0
from vision-consensus
with GNU Lesser General Public License v3.0
from vision-consensus
private static Precomputed flippedMillerLoopDoubling(BN128G2 g2) {
Fp2 x = g2.x, y = g2.y, z = g2.z;
// a = x * y / 2
Fp2 a = Fp._2_INV.mul(x.mul(y));
// b = y^2
Fp2 b = y.squared();
// c = z^2
Fp2 c = z.squared();
// d = 3 * c
Fp2 d = c.add(c).add(c);
// e = twist_b * d
Fp2 e = B_Fp2.mul(d);
// f = 3 * e
Fp2 f = e.add(e).add(e);
// g = (b + f) / 2
Fp2 g = Fp._2_INV.mul(b.add(f));
// h = (y + z)^2 - (b + c)
Fp2 h = y.add(z).squared().sub(b.add(c));
// i = e - b
Fp2 i = e.sub(b);
// j = x^2
Fp2 j = x.squared();
// e2 = e^2
Fp2 e2 = e.squared();
// rx = a * (b - f)
Fp2 rx = a.mul(b.sub(f));
// ry = g^2 - 3 * e^2
Fp2 ry = g.squared().sub(e2.add(e2).add(e2));
// rz = b * h
Fp2 rz = b.mul(h);
// ell_0 = twist * i
Fp2 ell0 = TWIST.mul(i);
// ell_VW = -h
Fp2 ellVW = h.negate();
// ell_VV = 3 * j
Fp2 ellVV = j.add(j).add(j);
return Precomputed.of(new BN128G2(rx, ry, rz), new EllCoeffs(ell0, ellVW, ellVV));
}