static String whichInitiates(String a,String b) throws NoSuchAlgorithmException, UnsupportedEncodingException {
  if (a == null || b == null) {
    return null;
  }
  if (a.compareTo(b) < 0) {
    if (startsWithAOneBit(concatAndHash(a,b))) {
      return a;
    }
 else {
      return b;
    }
  }
 else {
    if (startsWithAOneBit(concatAndHash(b,a))) {
      return b;
    }
 else {
      return a;
    }
  }
}

static String whichInitiates ( String a , String b ) throws NoSuchAlgorithmException , UnsupportedEncodingException { if ( a == null || b == null ) { return null ; } if ( a . compareTo ( b ) < 0 ) { if ( startsWithAOneBit ( concatAndHash ( a , b ) ) ) { return a ; } else { return b ; } } else { if ( startsWithAOneBit ( concatAndHash ( b , a ) ) ) { return b ; } else { return a ; } } }
decide which of the two addresses given should initiate communications . the algorithm is : sort the strings lexicographically , concatenate them , take their sha - 256 hash . if the first bit of the hash is a 1 , then the lexicographically lower one initiates . otherwise , the higher one initiates .
