Example #1
0
    /* RSA decryption with the private key */
    public static void DECRYPT(rsa_private_key PRIV, sbyte[] G, sbyte[] F)
    {
        int n = PRIV.p.getlen();
        FF  g = new FF(2 * n);

        FF.fromBytes(g, G);
        FF jp = g.dmod(PRIV.p);
        FF jq = g.dmod(PRIV.q);

        jp.skpow(PRIV.dp, PRIV.p);
        jq.skpow(PRIV.dq, PRIV.q);

        g.zero();
        g.dscopy(jp);
        jp.mod(PRIV.q);
        if (FF.comp(jp, jq) > 0)
        {
            jq.add(PRIV.q);
        }
        jq.sub(jp);
        jq.norm();

        FF t = FF.mul(PRIV.c, jq);

        jq = t.dmod(PRIV.q);

        t = FF.mul(jq, PRIV.p);
        g.add(t);
        g.norm();

        g.toBytes(F);
    }