/** Hash one or two MPIs. To hash only one MPI, b may be set to NULL. */ public static MPI hash(int version, MPI a, MPI b, Provider prov) throws OTRException { int totalsize = 1 + 4 + a.getLength(); if (b != null) { totalsize += 4 + b.getLength(); } byte[] buf = new byte[totalsize]; OutBuf obuf = new OutBuf(buf); obuf.writeByte((byte) version); obuf.writeUInt(a.getLength()); a.writeRaw(obuf); if (b != null) { obuf.writeUInt(b.getLength()); b.writeRaw(obuf); } byte[] out = obuf.getBytes(); SHA256 sha = prov.getSHA256(); byte[] digest = sha.hash(out); return new MPI(digest); }