DhKeyExchange
Diffie-Hellman key exchange for BitTorrent Message Stream Encryption (MSE/PE). Pure-Kotlin port of dh_key_exchange in libtorrent's src/pe_crypto.cpp.
MSE fixes the group: a 768-bit safe prime P (the same prime libtorrent embeds as dh_prime) and generator g = 2. Each peer picks a random 96-byte (768-bit) secret x, publishes g^x mod P (96 bytes, big-endian, left-zero-padded), and derives the shared secret remote^x mod P. Both peers arrive at the same value g^(x_a * x_b) mod P.
The shared-secret bytes are then fed (with the literal "req3" prefix) into SHA-1 to form the obfuscation XOR mask used later in the MSE handshake; req3XorMask reproduces libtorrent's hasher(req3).update(buffer).final().
Bignum support (modular exponentiation) comes from BigInt. There is no BigInteger in the Kotlin common stdlib, so libtorrent's boost::multiprecision usage is reimplemented from scratch.