示例#1
0
        private static bool DecodePointVar(byte[] p, int pOff, bool negate, PointExt r)
        {
            byte[] py = Arrays.CopyOfRange(p, pOff, pOff + PointBytes);
            if (!CheckPointVar(py))
            {
                return(false);
            }

            int x_0 = (py[PointBytes - 1] & 0x80) >> 7;

            py[PointBytes - 1] &= 0x7F;

            X448Field.Decode(py, 0, r.y);

            uint[] u = X448Field.Create();
            uint[] v = X448Field.Create();

            X448Field.Sqr(r.y, u);
            X448Field.Mul(u, (uint)-C_d, v);
            X448Field.Negate(u, u);
            X448Field.AddOne(u);
            X448Field.AddOne(v);

            if (!X448Field.SqrtRatioVar(u, v, r.x))
            {
                return(false);
            }

            X448Field.Normalize(r.x);
            if (x_0 == 1 && X448Field.IsZeroVar(r.x))
            {
                return(false);
            }

            if (negate ^ (x_0 != (r.x[0] & 1)))
            {
                X448Field.Negate(r.x, r.x);
            }

            PointExtendXY(r);
            return(true);
        }