Ejemplo n.º 1
0
        protected internal override ECPoint DecompressPoint(
            int yTilde,
            BigInteger X1)
        {
            ECFieldElement x     = FromBigInteger(X1);
            ECFieldElement alpha = x.Multiply(x.Square().Add(a)).Add(b);
            ECFieldElement beta  = alpha.Sqrt();

            //
            // if we can't find a sqrt we haven't got a point on the
            // curve - run!
            //
            if (beta == null)
            {
                throw new ArithmeticException("Invalid point compression");
            }

            BigInteger betaValue = beta.ToBigInteger();
            int        bit0      = betaValue.TestBit(0) ? 1 : 0;

            if (bit0 != yTilde)
            {
                // Use the other root
                beta = FromBigInteger(q.Subtract(betaValue));
            }

            return(new FpPoint(this, x, beta, true));
        }