示例#1
0
        /**
         * return a sqrt root - the routine verifies that the calculation returns the right value - if
         * none exists it returns null.
         */
        public override ECFieldElement Sqrt()
        {
            uint[] c = this.x;
            if (Nat224.IsZero(c) || Nat224.IsOne(c))
            {
                return(this);
            }

            uint[] nc = Nat224.Create();
            SecP224R1Field.Negate(c, nc);

            uint[] r = Mod.Random(SecP224R1Field.P);
            uint[] t = Nat224.Create();

            if (!IsSquare(c))
            {
                return(null);
            }

            while (!TrySqrt(nc, r, t))
            {
                SecP224R1Field.AddOne(r, r);
            }

            SecP224R1Field.Square(t, r);

            return(Nat224.Eq(c, r) ? new SecP224R1FieldElement(t) : null);
        }
示例#2
0
 public override ECFieldElement AddOne()
 {
     uint[] z = Nat224.Create();
     SecP224R1Field.AddOne(x, z);
     return(new SecP224R1FieldElement(z));
 }