コード例 #1
0
ファイル: PointMontgomery.cs プロジェクト: AlbertGaliev/ECM
 public PointMontgomery(BigInteger x, BigInteger y, EllipticCurveMontgomery E)
 {
     this.x = x;
     this.y = y;
     this.z = 1;
     this.E = E;
 }
コード例 #2
0
        public override bool Equals(Object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            EllipticCurveMontgomery E = obj as EllipticCurveMontgomery;

            return(new EllipticCurveMontgomery(this.An, this.Ad, this.n) == E);
        }
コード例 #3
0
        public static PointMontgomeryBrent Double(PointMontgomeryBrent P)
        {
            EllipticCurveMontgomery E = P.E as EllipticCurveMontgomery;
            BigInteger t1             = (P.x + P.z) * (P.x + P.z);
            BigInteger t2             = (P.x - P.z) * (P.x - P.z);
            BigInteger t = t1 - t2;
            BigInteger x = (t1 * t2 * 4 * E.Ad) % P.E.n;
            BigInteger z = ((4 * E.Ad * t2 + t * E.An) * t) % P.E.n;

            return(new PointMontgomeryBrent(x, 0, z, P.E));
        }
コード例 #4
0
        }//Montgomery

        private static EllipticCurveMontgomery GenerateCurve(BigInteger n, out BigInteger x, out BigInteger y, TorsionType type)
        {
            switch (type)
            {
            case TorsionType.RandomCurve:
                return(EllipticCurveMontgomery.GenerateCurveRandom(n, out x, out y));

            case TorsionType.Curve6:
                return(EllipticCurveMontgomery.GenerateCurve6(n, out x, out y));

            default:
                return(EllipticCurveMontgomery.GenerateCurveRandom(n, out x, out y));
            }
        }
コード例 #5
0
        public bool IsOnCurve()
        {
            EllipticCurveMontgomery E = this.E as EllipticCurveMontgomery;

            return((x * x * x + (E.An / E.Ad - 2) * x * x * z + x * z * z) % E.n == 0);
        }