java.lang.Object
net.i2p.router.tunnel.pool.TunnelPeerSelector.HashComparator
All Implemented Interfaces:
Serializable, Comparator<Hash>
Enclosing class:
TunnelPeerSelector

private static class TunnelPeerSelector.HashComparatorextends Object implements Comparator<Hash>, Serializable
Implement a deterministic comparison that cannot be predicted by others. A naive implementation (using the distance from a random key) allows an attacker who runs two routers with hashes far apart to maximize his chances of those two routers being at opposite ends of a tunnel.

Previous Previous: d(l, h) - d(r, h)

Previous: d((H(l+h), h) - d(H(r+h), h)

Now: SipHash using h to generate the SipHash keys then siphash(l) - siphash(r).

  • Field Details

    • k0

      private final long k0
      First seed for the deterministic peer shuffle.
    • k1

      private final long k1
      Second seed for the deterministic peer shuffle.
  • Constructor Details

    • HashComparator

      private HashComparator(SessionKey k)
      Derives the SipHash sort keys from a session key, holding no state of its own.
      Parameters:
      k - container for sort keys, not used as a Hash
  • Method Details