コード例 #1
0
ファイル: ECCurve.cs プロジェクト: Eurodocs/p2abcengine
        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));
        }
コード例 #2
0
ファイル: ECCurve.cs プロジェクト: skemper/uprove-csharp-sdk
        protected override ECPoint DecompressPoint(int yTilde, BigInteger X1)
        {
            ECFieldElement x     = FromBigInteger(X1);
            ECFieldElement alpha = x.Square().Add(m_a).Multiply(x).Add(m_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");
            }

            if (beta.TestBitZero() != (yTilde == 1))
            {
                // Use the other root
                beta = beta.Negate();
            }

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