# Which elliptic curve cryptography algorithm can be used for this scenario and how to do? Please explain step by step

I want to implement the below scenario using elliptic curve cryptography:

1. Steve has list of IDs and he wants to encrypt with private key - IDs
2. Steve send the list of encrypted IDS to John - Steve(IDs)
3. Now John wants to encrypt the Steve IDs with his private key - John(Steve(IDs))
4. Now Steve wants to decrypt the John encrypted Key to get the list of IDs which he encrypted - John(IDs)

Here both Steve and John maintains their private keys and it's not shared between 2 parties.

• Does Steve want to conceal the list of IDs from third parties? That's the one purpose of using encryption on that. And in this case "encrypt with private key" makes no sense. In asymmetric cryptography, encryption is with a public key. – fgrieu Apr 18 '18 at 5:12
• I guess the easiest way of doing so with elliptic curves is using hybrid encryption. – VincBreaker Apr 18 '18 at 7:18
• Yes. Steve want to conceal the list of IDs from third parties. – guest Apr 18 '18 at 11:42

The easiest way to do this is to implement an EC version of Polig-Hellman. Here's how it would work in this case:

• You would define an efficiently invertable transform between 'id' and elliptic curve point.

• You would define encryption as, for a plaintext point $P$, and a key $k$, you compute the point $kP$; note that $k$ needs to be relatively prime to $q$, the number of points on the curve.

• Decryption then becomes, for a ciphertext point $C$ and a key $k$, you compute the point $(k^{-1} \bmod q)C$.

So:

1. Steve has list of IDs and he wants to encrypt with private key - IDs

Steve would apply the invertable transform to the IDs, forming a list of curve points $I_1, I_2, ...$

1. Steve send the list of encrypted IDS to John - Steve(IDs)

Steve would take his secret value $s$, and compute $sI_1, sI_2, ...$ and send that to John

1. Now John wants to encrypt the Steve IDs with his private key - John(Steve(IDs))

John would take his secret value $j$, and compute $j(sI_1), j(sI_2), ...$

1. Now Steve wants to decrypt the John encrypted Key to get the list of IDs which he encrypted - John(IDs)

Steve would take the list $j(sI_1), j(sI_2), ...$, and compute $(s^{-1}(j(sI_1)), s^{-1}(j(sI_2)), ...) = (jI_1, jI_2, ...)$

There you go, that's the list of id's encrypted with John's key; with John's key, you could decrypt the list, and then invert the transform to reveal the original ids.

Now, this works, but it differs from most EC crypto, in the sense that this is a symmetric encryption system; knowledge of an encryption key allows you to decrypt as well.

• Thank you so much for your answer. Can you share if any sample piece of code for these kind of scenarios if possible. – guest Apr 20 '18 at 14:57