I'm a software engineer, so I generally think in building blocks. And I'm not so familiar with the Math notation in Crytography, so I'll stick with function calls and function blueprints (which I assume would be as intuitive).
Lately I've been asking and reading several questions here and also some related papers on these topics. So I'll try to first list the definitions on how I understand them; and propose a protocol for an OPRF using OT and a PRF.
Can you please comment on the validity and security of this protocol?
Here are my definitions, which are independent of each others.
PRG
Alice initiates a PRG with an arbitrary seed. Alice can generate a random looking output of an arbitrary length of n. If Alice at another time, and another system would seed the PRG with the same seed, the the first n bits of the output would be the same as the previous output she got.
PRF
Alice has a key. Alice initiates her PRF with this key. And given any input of an arbitrary length of bits, Alice can deterministically get a random looking output of an arbitrary length of k. (sizes k and n don't necessarily have to be in any relation to each-other)
OT (specifically 1-2 OT)
Alice creates two messages of the same length (n-bits) m0 and m1. And Bob chooses either 0 or 1 and gets the respective message. Alice won't know which one Bob got, and Bob will get m0 if he has chosen 0, and will never know about m1 (or vice versa)
OPRF
Bob has an input. Alice has the key of the OPRF function. During the execution of the OPRF, Alice interactively generates a random looking output based on Bob's input, however Bob's input is concealed from Alice. Alice will never know Bob's input, and Bob will never know Alice's key. However if Alice were to share her key with Bob, or Bob were to share his input with Alice, the same "random looking output" could be re-generated.
Based on the definitions i have listed, I will now try to propose a Protocol which satisfies the definition of the OPRF above.
I'll first propose a naive and probably not so-secure version; and try to fix the security issue I see, with a small twist.
Alice has a PRG and this is how she uses it to build a PRF using it.
//input and output are bit arrays of any arbitrary size.
//output is initialized with 0 (identity element for XOR)
prf(key, input[], output[]) {
prg.setSeed(key)
for(i = 0; i < input.length; i++) {
bits0 = prg.nextBits(output.length)
bits1 = prg.nextBits(output.length)
if(input[i] == 0)
output (XOR) bits0
else
output (XOR) bits1
}
}
This approach of creating a PRF out of a PRG is built on the premises that:
- XOR operation will preserve entropy
- The PRG will be generating random sequences with no correlation.
Now Bob wants to use this PRF using Alice's key. The OPRF is as follows.
- Bob has an input of size n and wants a random output of size k
- Alice seeds the PRG with her key
- [OT] They execute an OT protocol for each bit in Bob's input
- [OT] Alice creates two random messages of size k-bits {bits0, bits1}
- [OT] If the current bit of Bob's input is 0 Bob chooses bits0, otherwise chooses bits1
- Finally Bob XOR's all the messages to get the output.
This protocol is equivalent to the PRF described above.
The above protocol would be secure:
- If we would run this protocol only once
- If Alice would use a random key for each execution
Because in a second run, Bob can switch the bits in his input and learn the full random sequence from Alice's PRG.
However none of the requirements above are realistic. The twist to make this protocol secure would be as follows:
- Alice requires an input of even size
- Bob has an input of size 2n and wants a random output of size k
- Using a PRG with a one-time seed, Alice generates n random masks of k-bits
- Alice generates a random permutation of these n masks in a sequence where every message is repeated exactly once. (giving us a sequence of size 2n, remember that's the size of Bob's input)
- [OT] Now, they execute an OT protocol for each bit in Bob's input
- [OT] Alice creates two random messages of size k-bits {bits0, bits1} and XORs them with the next mask from the sequence {bits0 (XOR) maskR, (bits1 (XOR) maskR}
- [OT] If the current bit of Bob's input is 0 Bob chooses the masked bits0, otherwise chooses masked bits1
- Finally Bob XOR's all the messages.
Since masks are going to cancel each-other out, and every execution of this protocol will involve a random mask. This protocol should still be equivalent to the PRF defined above and should not be suffering from the problem defined in the previous protocol.
My final goal for this OPRF is to use it for a Private Set Intersection protocol. see the answer of @Mikero in the question: How can Alice enable Bob to look-up values in a private map
Can you please comment on the validity and security of this protocol? And how can I improve it if you see any drawbacks on it.