/* set this=-this */ public void neg() { if (is_infinity()) { return; } y.neg(); y.reduce(); return; }
/* Calculate RHS of twisted curve equation x^3+B/i */ public static FP2 RHS(FP2 x) { x.norm(); FP2 r = new FP2(x); r.sqr(); FP2 b = new FP2(new BIG(ROM.CURVE_B)); b.div_ip(); r.mul(x); r.add(b); r.reduce(); return(r); }
/* set this*=q, where q is Modulus, using Frobenius */ public void frob(FP2 X) { if (INF) { return; } FP2 X2 = new FP2(X); X2.sqr(); x.conj(); y.conj(); z.conj(); z.reduce(); x.mul(X2); y.mul(X2); y.mul(X); }
/* set to Affine - (x,y,z) to (x,y) */ public void affine() { if (is_infinity()) { return; } FP2 one = new FP2(1); if (z.Equals(one)) { return; } z.inverse(); FP2 z2 = new FP2(z); z2.sqr(); x.mul(z2); x.reduce(); y.mul(z2); y.mul(z); y.reduce(); z.copy(one); }
/* reduce all components of this mod Modulus */ public void reduce() { a.reduce(); b.reduce(); }