public bool CheckSignature(string message, int w, BigInteger s) { BigInteger m = new GostHash().CalculateHash(message.ToCharArray()); BigInteger v = BigInteger.Pow(m, _q - 2) % _q; int z1 = (int)((s * v) % _q); int z2 = (int)(((_q - w) * v) % _q); BigInteger u = ((BigInteger.Pow(_a, z1) * BigInteger.Pow(_y, z2)) % _p % _q); return(w == u); }
public (int, BigInteger) Sign(string message) { BigInteger m = new GostHash().CalculateHash(message.ToCharArray()); int w = (int)(BigInteger.Pow(_a, _k) % _p); w = w % _q; BigInteger s = (_x * w + _k * m) % _q; return(w, s); }