/* this*=this */ public void sqr() { norm(); FP2 t1 = new FP2(a); FP2 t2 = new FP2(b); FP2 t3 = new FP2(a); t3.mul(b); t1.add(b); t2.mul_ip(); t2.add(a); a.copy(t1); a.mul(t2); t2.copy(t3); t2.mul_ip(); t2.add(t3); t2.neg(); a.add(t2); b.copy(t3); b.add(t3); norm(); }
/* this*=y */ public void mul(FP4 y) { norm(); FP2 t1 = new FP2(a); FP2 t2 = new FP2(b); FP2 t3 = new FP2(0); FP2 t4 = new FP2(b); t1.mul(y.a); t2.mul(y.b); t3.copy(y.b); t3.add(y.a); t4.add(a); t4.mul(t3); t4.sub(t1); // t4.norm(); b.copy(t4); b.sub(t2); t2.mul_ip(); a.copy(t2); a.add(t1); norm(); }
/* this=1/this */ public void inverse() { norm(); FP2 t1 = new FP2(a); FP2 t2 = new FP2(b); t1.sqr(); t2.sqr(); t2.mul_ip(); t1.sub(t2); t1.inverse(); a.mul(t1); t1.neg(); b.mul(t1); }