The Oblivious Pseudorandom Function (OPRF) is an important building block of modern password-authenticated key exchange like OPAQUE. In OPAQUE, it helps computing the password hashing without the need to exchange the 'salt'.
In this challenge, a user will play with a OPRF based on a variant of Diffie-Hellman. The user stores a password at password.txt. The pre-agreed parameters are p (in p.txt) and q = (p-1) / 2. They define a group of order p and its element mostly like can generate a subgroup of order q. During the key exchange,
- The user samples a random
r and sends X = Hash(password)^r to the server. The value r can be found in r.txt.
- The server returns with
Y = X^k. The value Y can be found in hashed_pw_to_rk.txt.
- The user computes the final key material
SHA256(password || Y^{1/r}), where || denotes the concatenation, Y^{1/r} is represented as a 256-byte integer with big endian, and 1/r is the multiplicative inverse of r.
Your task is to help this user finish the last step. Think about how the multiplicative inverse of r should be computed.
You can verify your result by /challenge/solve.