Skip to content

Proxy Re-Encryption

Table of contents

Open Table of contents

What it is

A Proxy Re-Encryption scheme allows for the modification of a ciphertext that was encrypted under key A to be decryptable with a different key B. This ciphertext modification can be done by any untrusted third party as it won’t learn anything about the underlying plaintext or the private keys involved.

How it works

Note: The Proxy Re-Encryption scheme presented here is a simplified version of a variant that uses the Diffie-Hellman Key Exchange protocol. It’s discussed here for educational purposes only and shouldn’t be used in a production environment.

In our example we have four different parties we call Alice, Bob, Charlie and Dave:

  1. Alice receives an encrypted message from Charlie and wants Bob to be able to decrypt that message as well
  2. Bob who relies on Dave, the untrusted third Party, to be able to decrypt Alice’s message
  3. Charlie who sends a message to Alice encrypted under her public key
  4. Dave, the untrusted third party who acts as a proxy to allow Bob to decrypt Alice’s message without learning anything about the message or the private keys involved

In this writeup we’ll be working with an Elliptic Curve EE that is of order qq and has a generator GG. All calculations are done mod q\bmod\ q if not stated otherwise.

As a first step, Alice, Bob and Charlie generate their private- and public keys.

Alice does this by sampling a random value from Zq\mathbb{Z}_q which serves as her private key aa.

a$Zqa \overset{{\scriptscriptstyle\$}}{\leftarrow} \mathbb{Z}_q

This value is then multiplied by the generator GG to calculate her public key AA.

A=aGA = aG

Bob follows the exact same steps and starts the key generation procedure by sampling a random value from Zq\mathbb{Z}_q which is interpreted as his private key bb.

b$Zqb \overset{{\scriptscriptstyle\$}}{\leftarrow} \mathbb{Z}_q

His private key bb is then multiplied by GG to derive the corresponding public key BB.

B=bGB = bG

The exact same steps are followed by Charlie who generates his private key cc by sampling a random value from Zq\mathbb{Z}_q.

c$Zqc \overset{{\scriptscriptstyle\$}}{\leftarrow} \mathbb{Z}_q

He then also multiplies this private key cc by GG to calculate his public key CC.

C=cGC = cG

Given that Charlie wants to send a message to Alice he needs to get access to her public key AA, so both Alice and Charlie do a key exchange of their public keys AA and CC.

As Alice wants Bob to be able to decrypt her message she’ll receive from Charlie, she needs to get access to Bob’s public key to generate a re-encryption key for Bob. Both of them therefore also do a key exchange of their public keys AA and BB.

Charlie is now able to send Alice a message that’s encrypted under her public key AA.

To do that, he generates a shared secret XX following the regular Elliptic Curve Diffie-Hellman protocol by multiplying his private key cc with Alice’s public key AA.

X=cAX = cA

This shared secret XX can then be used to “blind” the plaintext message MM Charlie wants to send to Alice. The “blinding” is a simple multiplication of MM by XX which results in the ciphertext EAE_A.

EA=MXE_A = MX

Charlie sends this ciphertext to Alice.

Given that Alice wants Bob to be able to read the plaintext message MM of EAE_A, she can use Bob’s public key to calculate a re-encryption key rkrk that can be used by Dave, the untrusted third party to create a decryption key for Bob which he can use to decrypt Alice’s message with his own private key bb.

Alice calculates rkrk by dividing her private key by a Hash of the multiplication of Bob’s public key with her private key. The Hash is computed via a cryptographic hash function HH.

rk=aH(Ba)rk = \frac{a}{H(Ba)}

Notice that the multiplication of Bob’s public key BB with Alice’s private key aa is another instance of the regular Elliptic Curve Diffie-Hellman protocol in which Alice and Bob can use their public- and private keys to derive a shared secret only both of them have access to. We’ll see a similar computation later on when Bob derives the same shared secret by multiplying Alice’s public key AA with his private key bb.

This re-encryption key rkrk can be publicly shared. Alice send the re-encryption key rkrk as well as Charlie’s public key CC to the untrusted third-party Dave.

Using this information, Dave creates a decryption key bb' for Bob that allows Bob to later decrypt Alice’s ciphertext EAE_A. The decryption key is calculated by multiplying Charlie’s public key CC with the re-encryption key rkrk.

b=Crkb' = Crk

Notice that Dave learns nothing about Alice’s, Bob’s or Charlie’s private keys as he’s only working with the publicly shareable re-encryption key rkrk as well as Charlie’s public key CC. In addition to that, he also doesn’t learn anything about the plaintext message MM.

Dave can now send this decryption key bb' to Bob who can use it to decrypt Alice’s ciphertext EAE_A.

In our case, we assume that Alice forwarded EAE_A to Bob, but it doesn’t really matter who sends EAE_A to Bob as it’s a ciphertext which can be kept by different entities. The only important part is that it’s the correct EAE_A Bob get’s access to.

Now that Bob got his decryption key bb' from Dave which itself is based on the re-encryption key rkrk Alice calculated, he can decrypt the message Charlie sent to Alice using bb' and his own private key bb.

To do so, Bob first recomputes the blinding factor XX by multiplying bb' with a hash of a multiplication of his private key bb by Alice’s public key AA. The Hash is computed via a cryptographic hash function HH.

X=bH(Ab)X = b'H(Ab)

Again, notice that the multiplication of Alice’s public key AA with Bob’s private key bb is an instance of the regular Elliptic Curve Diffie-Hellman protocol. Bob therefore derives the same shared secret Alice also computed in a prior step.

Bob can then use XX to recover the plaintext message MM. To do so, he divides the ciphertext EAE_A by XX.

M=EAXM = \frac{E_A}{X}

Proxy Re-Encryption

Why it works

The first thing to note is that the message MM that Charlie initially sent to Alice is “blinded” by the value XX which is a shared secret that both Alice and Charlie can calculate following the regular Elliptic Curve Diffie-Hellman protocol. Due to the usage of this “blinding” factor, the resulting ciphertext EAE_A looks like random noise and thanks to the “hardness” assumption of the discrete logarithm, it’s impossible to recover XX from EAE_A and therefore learn anything about MM.

The re-encryption key rkrk that Alice calculates also uses a shared secret BaBa that both Alice and Bob can calculate. This shared secret is hashed with a cryptographic hash function HH and serves as the denominator in the equation of rkrk.

rk=aH(Ba)rk = \frac{a}{H(Ba)}

Given that Bob also has Alice’s public key, he’s able to recompute the denominator of rkrk himself using his private key bb to derive the same shared secret and hashing it with the same cryptographic hash function HH.

H(Ab)H(Ab)

Bob can now recompute the blinding factor XX himself as his decryption key bb' is just a multiplication of rkrk with Charlie’s public key CC. He can use H(Ab)H(Ab) to “isolate” a multiplication of Alice’s private key aa by Charlie’s private key cc multiplied by the generator GG.

X=bH(Ab)=CrkH(Ab)=cGaH(Ba)H(aGb)=cGaH(bGa)H(abG)=cGaH(abG)H(abG)=cGaH(abG)H(abG)=cGaH(abG)H(abG)=cGa=cA\begin{aligned} X &= b'H(Ab) \\ &= CrkH(Ab) \\ &= cG\frac{a}{H(Ba)}H(aGb) \\ &= cG\frac{a}{H(bGa)}H(abG) \\ &= cG\frac{a}{H(abG)}H(abG) \\ &= cG\frac{aH(abG)}{H(abG)} \\ &= cG\frac{a\cancel{H(abG)}}{\cancel{H(abG)}} \\ &= cGa \\ &= cA \end{aligned}

Note that this is the exact XX that Charlie used to “blind” his message MM he sent to Alice.

Given that Bob has now access to XX he can recover the plaintext MM by dividing EAE_A by XX.

M=EAX=McAX=McAcA=McAcA=M\begin{aligned} M &= \frac{E_A}{X} \\ &= \frac{McA}{X} \\ &= \frac{McA}{cA} \\ &= \frac{M\cancel{cA}}{\cancel{cA}} \\ &= M \end{aligned}

To show that this is indeed a message originally intended for Alice, we can show that Alice can recover MM as well. To do that she calculates XX by multiplying her private key with Charlie’s public key CC. As a reminder, this is just the regular Elliptic Curve Diffie-Hellman protocol to derive a shared secret.

X=aCX = aC

She’s then also able to use this XX (which is the same XX that Bob was able to calculate) to recover MM by dividing the ciphertext EAE_A by XX.

M=EAX=McAX=McAcA=McAcA=M\begin{aligned} M &= \frac{E_A}{X} \\ &= \frac{McA}{X} \\ &= \frac{McA}{cA} \\ &= \frac{M\cancel{cA}}{\cancel{cA}} \\ &= M \end{aligned}

References

The following resources have been invaluable for me to learn the concepts discussed in this article.

You should definitely give them a read if you want to dive deeper into the topic.