public static BigInteger calculateKey(Digest digest,BigInteger N,BigInteger S){
  int padLength=(N.bitLength() + 7) / 8;
  byte[] _S=getPadded(S,padLength);
  digest.update(_S,0,_S.length);
  byte[] output=new byte[digest.getDigestSize()];
  digest.doFinal(output,0);
  return new BigInteger(1,output);
}

public static BigInteger calculateKey ( Digest digest , BigInteger N , BigInteger S ) { int padLength = ( N . bitLength ( ) + 7 ) / 8 ; byte [ ] _S = getPadded ( S , padLength ) ; digest . update ( _S , 0 , _S . length ) ; byte [ ] output = new byte [ digest . getDigestSize ( ) ] ; digest . doFinal ( output , 0 ) ; return new BigInteger ( 1 , output ) ; }
computes the final key according to the standard routine : key = h ( s )
