public static BigInteger hash(int version,BigInteger a,BigInteger b) throws SMException {
  try {
    MessageDigest sha256=MessageDigest.getInstance("SHA-256");
    sha256.update((byte)version);
    sha256.update(SerializationUtils.writeMpi(a));
    if (b != null)     sha256.update(SerializationUtils.writeMpi(b));
    return new BigInteger(1,sha256.digest());
  }
 catch (  NoSuchAlgorithmException e) {
    throw new SMException("cannot find SHA-256");
  }
catch (  IOException e) {
    throw new SMException("cannot serialize bigint");
  }
}

public static BigInteger hash ( int version , BigInteger a , BigInteger b ) throws SMException { try { MessageDigest sha256 = MessageDigest . getInstance ( "SHA-256" ) ; sha256 . update ( ( byte ) version ) ; sha256 . update ( SerializationUtils . writeMpi ( a ) ) ; if ( b != null ) sha256 . update ( SerializationUtils . writeMpi ( b ) ) ; return new BigInteger ( 1 , sha256 . digest ( ) ) ; } catch ( NoSuchAlgorithmException e ) { throw new SMException ( "cannot find SHA-256" ) ; } catch ( IOException e ) { throw new SMException ( "cannot serialize bigint" ) ; } }
hash one or two bigintegers . to hash only one biginteger , b may be set to null .
