Diffie–Hellman oblivious pseudorandom functions: algebra and message laws #
[BS23], Section 11.6.3 (pp. 454–456), defines the function
F′(k, x) = H′(x, H(x)^k) of equation (11.21) over a cyclic group G of prime order q with
generator g, and gives two protocols, OPRF1 and OPRF2, by which a sender holding the key k
and a receiver holding the input x evaluate F′(k, x). Here G is written additively as a
ZMod q-module, so H(x)^k is k • H x, g^k is k • g, equation (11.21) is H' x (k • H x),
and the hashed input H(x) is an element h : G:
- In
OPRF1(pp. 454–455), the receiver draws a uniform nonzero exponentρ : (ZMod q)ˣand sendsv = ρ • h; the sender returnsw = k • v; the receiver unblindsρ⁻¹ • w(which equalsk • hbysmul_commandinv_smul_smul) and appliesH' x. - In
OPRF2(p. 456), the sender publishesu = k • g; the receiver drawsρ : (ZMod q)ˣandτ : ZMod q, sendsv = maskedBlind g ρ τ h = ρ • h + τ • g, and unblinds the sender's replywasmaskedUnblind u ρ τ w = ρ⁻¹ • (w - τ • u).
This module defines maskedBlind and maskedUnblind (exposed so tests and downstream protocols can
unfold them directly), and proves the OPRF2 identities and five exact PMF laws for the
receiver's message in each protocol and for the joint distribution against a deviating OPRF2
sender that adds d v to its response.
Deviations from [BS23] #
- Group elements only. The protocols are expressed as operations on
Gand exactPMFlaws of uniform exponents, through an arbitrary continuationfas inCslib.Crypto.uniformOfFintype_bind_smul_add. Interactive protocol executions,F′(k, x), random-oracle games forHandH', thatF′is a PRF under CDH (Exercise 11.3, p. 458), that a wrong output inOPRF2is uniform inYwhenH'is a random oracle, and receiver security under one-more Diffie–Hellman (pp. 455–456) are not formalized here. - Invertible blinding exponents without primality. Because
ρis typed in(ZMod q)ˣ, correctness (maskedUnblind_smul_maskedBlind_add,maskedUnblind_smul_maskedBlind), the general invarianceuniformOfFintype_bind_units_smul_smul, theOPRF2message lawuniformOfFintype_bind_maskedBlind, and the general deviating-sender lawuniformOfFintype_bind_maskedUnblind_adddo not require primality ofq(for primeq,(ZMod q)ˣis the book'sℤ_q \ {0}). The threePMFlaws still require[NeZero q]soZMod qand(ZMod q)ˣare finite, anduniformOfFintype_bind_maskedBlindanduniformOfFintype_bind_maskedUnblind_addrequiregto generateG. - Two sentences of §11.6.3 hold only away from the identity element:
- For
OPRF1(p. 455), the book states that withρuniform inℤ_q \ {0}, the receiver's messagev = H(x)^ρis "a random group element, statistically independent ofx". This sentence needsH(x) ≠ 1(additivelyH x ≠ 0), which the book does not state; for a random oracleH : X → G,H(x) = 1with probability1 / qper input. Becauseρis drawn from(ZMod q)ˣ,ρ • 0 = 0always, whereas forh ≠ 0in a prime-order group generated byg,uniformOfFintype_bind_units_smul_of_ne_zeroproves thatρ • hhas the law ofρ • gfor uniformρ : (ZMod q)ˣ(which is never0sinceg ≠ 0). Thus, for fixedH, the message distribution is independent ofxonly among inputs withH x ≠ 0. - For
OPRF2(p. 456), the book states that when a deviating sender replies tovwithw = v^k · dford ≠ 1(additivelyk • v + d vwithd v ≠ 0), the receiver computesk • h + ρ⁻¹ • (d v)where the error termρ⁻¹ • (d v)"is just a random group element (uniformly distributed overG)". Because bothρandd vare nonzero,ρ⁻¹ • (d v)is never0: for primeqand generatorg,uniformOfFintype_bind_maskedUnblind_add_of_ne_zeroproves thatρ⁻¹ • (d v)has the law ofρ • gfor uniformρ : (ZMod q)ˣ, which is never0(for primeqandg ≠ 0,ρ • gis the uniform distribution on the nonzero elementsG \ {0}, which this module does not prove), rather than the uniform distribution overG.
- For
Main definitions #
Cslib.Crypto.Protocols.OPRF.maskedBlind,Cslib.Crypto.Protocols.OPRF.maskedUnblind: the receiver's masked blinding and unblinding steps inOPRF2.
Main results #
Cslib.Crypto.Protocols.OPRF.maskedUnblind_smul_maskedBlind_add: inOPRF2, if the sender addsdto its honest response, the receiver computesk • h + ρ⁻¹ • d.Cslib.Crypto.Protocols.OPRF.maskedUnblind_smul_maskedBlind: correctness ofOPRF2.Cslib.Crypto.Protocols.OPRF.uniformOfFintype_bind_units_smul_smul,Cslib.Crypto.Protocols.OPRF.uniformOfFintype_bind_units_smul_of_ne_zero: the law of the receiver's message inOPRF1for nonzero hashed inputs.Cslib.Crypto.Protocols.OPRF.uniformOfFintype_bind_maskedBlind: the law of the receiver's message inOPRF2.Cslib.Crypto.Protocols.OPRF.uniformOfFintype_bind_maskedUnblind_add,Cslib.Crypto.Protocols.OPRF.uniformOfFintype_bind_maskedUnblind_add_of_ne_zero: the joint law of the receiver's message and unblinded group element against a deviatingOPRF2sender.
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography,
Version 0.6, Section 11.6.3, equation (11.21) and Protocols
OPRF1andOPRF2, pp. 454–456.
Protocol OPRF2 blinding and unblinding #
The receiver's unblinding step in Protocol OPRF2 ([BS23], Section 11.6.3, p. 456),
given the sender's public key u = k • g: subtract τ • u from w and multiply by ρ⁻¹.
In Protocol OPRF2 ([BS23], Section 11.6.3, p. 456), if the sender answers
v = maskedBlind g ρ τ h with k • v + d, the receiver's unblinded group element is
k • h + ρ⁻¹ • d.
Correctness of Protocol OPRF2 ([BS23], Section 11.6.3, p. 456) at the level of
group elements: when the sender responds honestly under public key k • g, maskedUnblind
recovers k • h.
What the sender sees #
Without primality of q, hashed inputs that differ by an invertible factor a : (ZMod q)ˣ
induce the same OPRF1 message distribution under a uniform ρ : (ZMod q)ˣ.
The receiver's message law in Protocol OPRF1 ([BS23], Section 11.6.3, p. 455): in a
group of prime order q generated by g, for every nonzero hashed input h ≠ 0, ρ • h under
uniform ρ : (ZMod q)ˣ has the same distribution as ρ • g (which is never 0 since g ≠ 0).
The book's statement that "the sender just sees a random group element, statistically independent
of x" needs H(x) ≠ 1 (H x ≠ 0), which the book does not state; for a random oracle
H : X → G, H(x) ≠ 1 fails with probability 1 / q per input. Because ρ is drawn from
(ZMod q)ˣ, if h = 0 then ρ • 0 = 0 always, whereas if h ≠ 0 then ρ • h has the law of
ρ • g and is never 0. Thus, for a fixed H, the message distribution is independent of x only
among inputs with H x ≠ 0.
The receiver's message law in Protocol OPRF2 ([BS23], Section 11.6.3, p. 456): when
g generates G, for every hashed input h and every ρ : (ZMod q)ˣ, maskedBlind g ρ τ h
under uniform τ : ZMod q has the distribution of τ • g, so the message leaks nothing about h
or ρ. This is Cslib.Crypto.uniformOfFintype_bind_smul_add applied at ρ • h.
Joint law of the receiver's message and unblinded group element against a deviating OPRF2
sender ([BS23], Section 11.6.3, p. 456), without primality of q: when g generates G
and the sender adds d v to its honest response on message v, the message v and the element
computed by the receiver have the joint distribution of (τ • g, k • h + ρ • d (τ • g)) for
independent uniform τ : ZMod q and ρ : (ZMod q)ˣ.
Joint law of the receiver's message and unblinded group element against a deviating OPRF2
sender in a prime-order group ([BS23], Section 11.6.3, p. 456): when q is prime, g
generates G, and the sender's deviation d v on every message v is nonzero, the message and
the element computed by the receiver are jointly distributed as (τ • g, k • h + ρ • g) for
independent uniform τ : ZMod q and ρ : (ZMod q)ˣ.
The book's statement that for a wrong answer (d ≠ 0), the error term ρ⁻¹ • d (printed
d^(1/ρ)) "is just a random group element (uniformly distributed over G)" omits 0: because ρ
is a unit and d v ≠ 0, ρ⁻¹ • d v is never 0, and instead has the law of ρ • g for uniform
ρ : (ZMod q)ˣ (which is never 0 since g ≠ 0; for prime q and g ≠ 0, this is the uniform
distribution on G \ {0}, which this module does not prove).