Companion

object Companion

Properties

Link copied to clipboard

MSE generator g = 2.

Link copied to clipboard
const val KEY_LEN: Int = 96

Size of public keys and the shared secret, in bytes (768 bits).

Link copied to clipboard

The MSE 768-bit prime P, identical to libtorrent's dh_prime (src/pe_crypto.cpp). This is the Diffie-Hellman prime from the BitTorrent MSE spec.

Functions

Link copied to clipboard

Create an exchange from an explicit secret (big-endian bytes, any length up to 96). Primarily for deterministic tests; the secret is reduced mod P implicitly by the exponentiation.

Link copied to clipboard
fun random(rng: Random = Random.Default): DhKeyExchange

Create an exchange with a fresh random 96-byte secret (libtorrent's default constructor: aux::random_bytes then import_bits).