package com.peachpasswords.sync /** * Who speaks first in a relay room. * * The relay is a two-party splice with no buffering and no "peer joined" * signal, so exactly one side must open with `PEACH_RECONNECT` and the other * must wait for it. Both sides derive the same room id from the shared pair * secret, so the role has to be derivable from state both already hold — * there is nothing on the wire to negotiate it with. * * The lower long-term public key dials and the higher key waits, independent * of device type. Browser service workers keep their waiter WebSocket alive * with application liveness frames, so extension-to-extension edges no longer * need a native device to act as the permanent listener. * * The keys are hex of the same length, so an ordinary lexicographic compare is * a total order over them. Ties are impossible: two devices sharing a static * key are the same device. */ internal fun weDialPeer(ourLongTermPublicKeyHex: String, peer: PairedDevice): Boolean { val theirs = peer.longTermPublicKeyHex ?: return false return ourLongTermPublicKeyHex.compareTo(theirs) < 0 }