示例#1
0
    private static void ge_msub(ref ge_p1p1 r, ge_p3 p, ge_precomp q)
    {
        Span <int> t0     = stackalloc int[10];
        ge_p1p1    result = new()
        {
            X = stackalloc int[10],
            Y = stackalloc int[10],
            Z = stackalloc int[10],
            T = stackalloc int[10],
        };

        r.X.CopyTo(result.X);
        r.Y.CopyTo(result.Y);
        r.Z.CopyTo(result.Z);
        r.T.CopyTo(result.T);

        fe_add(ref result.X, p.Y, p.X);
        fe_sub(ref result.Y, p.Y, p.X);
        fe_mul(ref result.Z, result.X, q.yminusx);
        fe_mul(ref result.Y, result.Y, q.yplusx);
        fe_mul(ref result.T, q.xy2d, p.T);
        fe_add(ref t0, p.Z, p.Z);
        fe_sub(ref result.X, result.Z, result.Y);
        fe_add(ref result.Y, result.Z, result.Y);
        fe_sub(ref result.Z, t0, result.T);
        fe_add(ref result.T, t0, result.T);

        result.X.CopyTo(r.X);
        result.Y.CopyTo(r.Y);
        result.Z.CopyTo(r.Z);
        result.T.CopyTo(r.T);
    }
示例#2
0
    private static void select(ref ge_precomp t, int pos, sbyte b)
    {
        ge_precomp result = new()
        {
            yminusx = stackalloc int[10],
            yplusx  = stackalloc int[10],
            xy2d    = stackalloc int[10],
        };

        ge_precomp minust = new()
        {
            yminusx = stackalloc int[10],
            yplusx  = stackalloc int[10],
            xy2d    = stackalloc int[10],
        };

        ge_precomp p0 = new()
        {
            yminusx = stackalloc int[10],
            yplusx  = stackalloc int[10],
            xy2d    = stackalloc int[10],
        };

        byte bnegative = negative(b);
        byte babs      = (byte)(b - (((-bnegative) & b) << 1));

        fe_1(ref result.yplusx);
        fe_1(ref result.yminusx);
        fe_0(ref result.xy2d);
        fe_0(ref minust.yplusx);
        fe_0(ref minust.yminusx);
        fe_0(ref minust.xy2d);

        GetPrecompBase(pos, 0, ref p0);
        cmov(ref result, p0, equal((sbyte)babs, 1));
        GetPrecompBase(pos, 1, ref p0);
        cmov(ref result, p0, equal((sbyte)babs, 2));
        GetPrecompBase(pos, 2, ref p0);
        cmov(ref result, p0, equal((sbyte)babs, 3));
        GetPrecompBase(pos, 3, ref p0);
        cmov(ref result, p0, equal((sbyte)babs, 4));
        GetPrecompBase(pos, 4, ref p0);
        cmov(ref result, p0, equal((sbyte)babs, 5));
        GetPrecompBase(pos, 5, ref p0);
        cmov(ref result, p0, equal((sbyte)babs, 6));
        GetPrecompBase(pos, 6, ref p0);
        cmov(ref result, p0, equal((sbyte)babs, 7));
        GetPrecompBase(pos, 7, ref p0);
        cmov(ref result, p0, equal((sbyte)babs, 8));

        fe_copy(ref minust.yminusx, result.yplusx);
        fe_copy(ref minust.yplusx, result.yminusx);
        fe_neg(ref minust.xy2d, result.xy2d);
        cmov(ref result, minust, bnegative);

        result.yplusx.CopyTo(t.yplusx);
        result.yminusx.CopyTo(t.yminusx);
        result.xy2d.CopyTo(t.xy2d);
    }
示例#3
0
    private static void cmov(ref ge_precomp t, ge_precomp u, byte b)
    {
        Span <int> yplusx  = stackalloc int[10];
        Span <int> yminusx = stackalloc int[10];
        Span <int> xy2d    = stackalloc int[10];

        t.yplusx.CopyTo(yplusx);
        t.yminusx.CopyTo(yminusx);
        t.xy2d.CopyTo(xy2d);

        fe_cmov(ref yplusx, u.yplusx, b);
        fe_cmov(ref yminusx, u.yminusx, b);
        fe_cmov(ref xy2d, u.xy2d, b);

        yplusx.CopyTo(t.yplusx);
        yminusx.CopyTo(t.yminusx);
        xy2d.CopyTo(t.xy2d);
    }