public static FpVector3 <Fp12> Twist(FpVector3 <Fp2> point) { // If the point isn't properly initialize if (point == null) { return(null); } // Place the items at the start and half way point BigInteger[] xcoefficients = new BigInteger[12] { point.X.Coefficients.ElementAt(0) - (point.X.Coefficients.ElementAt(1) * 9), 0, 0, 0, 0, 0, point.X.Coefficients.ElementAt(1), 0, 0, 0, 0, 0 }; BigInteger[] ycoefficients = new BigInteger[12] { point.Y.Coefficients.ElementAt(0) - (point.Y.Coefficients.ElementAt(1) * 9), 0, 0, 0, 0, 0, point.Y.Coefficients.ElementAt(1), 0, 0, 0, 0, 0 }; BigInteger[] zcoefficients = new BigInteger[12] { point.Z.Coefficients.ElementAt(0) - (point.Z.Coefficients.ElementAt(1) * 9), 0, 0, 0, 0, 0, point.Z.Coefficients.ElementAt(1), 0, 0, 0, 0, 0 }; // Instantiate fp12s from the extended fp2 Fp12 newx = new Fp12(xcoefficients); Fp12 newy = new Fp12(ycoefficients); Fp12 newz = new Fp12(zcoefficients); // Return a twisted point from fp2 to fp12. return(new FpVector3 <Fp12>(newx * _twistPoint.Pow(2), newy * _twistPoint.Pow(3), newz)); }
public static Fp12 FinalExponentiate(Fp12 p) { return(p.Pow((BigInteger.Pow(Bn128Curve.P, 12) - 1) / Bn128Curve.N)); }