}
public static List<String> buildSignature(long userID, String cookie, String passphrase, String serverNonce, byte[] clientNonce) {
try {
final SHA224Digest sha = new SHA224Digest();
DataOutputStream dos = new DataOutputStream(new OutputStream() {
@Override
public void write(int b) {
sha.update((byte) b);
}
@Override
public void write(byte[] buf, int off, int len) {
sha.update(buf, off, len);
}
});
dos.writeLong(userID);
dos.write(passphrase.getBytes(Charset.forName("UTF-8")));
dos.flush();
byte[] digest = new byte[28];
sha.doFinal(digest, 0);
ECDSASigner signer = new ECDSASigner();
signer.init(true, new ECPrivateKeyParameters(new BigInteger(1, digest), secp224k1));
dos.writeLong(userID);
dos.write(Base64.decode(serverNonce));
dos.write(clientNonce);
dos.flush();
dos.close();
sha.doFinal(digest, 0);
BigInteger[] signature = signer.generateSignature(digest);
return Arrays.asList(bigIntegerToBase64(signature[0]), bigIntegerToBase64(signature[1]));
} catch (IOException e) {
throw new ExchangeException("Could not build signature for authentication");
}