/* 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); }
/* nresidue mod m */ public void nres(FF m) { int n = m.length; FF d = new FF(2 * n); d.dsucopy(this); copy(d.dmod(m)); }
/* generate random x */ public void randomnum(FF p, RAND rng) { int n = length; FF d = new FF(2 * n); for (int i = 0; i < 2 * n; i++) { d.v[i].copy(BIG.random(rng)); } copy(d.dmod(p)); }