This is a follow up on the question I asked here. I designed a scheme that allows the following:
- Alice has a value $a$ which she wants to keep secret
- Bob has a value $b$ which he wants to keep secret
- Alice can "transfer" a part of her value to Bob such that whatever she transfers must be subtracted from her value (the sum of their value must remain the same). For example, if she has $10$ and Bob has $5$, after transferring $2$, she should have $8$ and Bob should have $7$
- Victor is an independent observer and must be able to verify that the sum of the values does not change as a result of the transfer. But he should do it without learning any of the numbers involved
The scheme below is inspired by EC El Gamal. If anyone can see holes in it, would really appreciate feedback.
Setup
- Alice and Bob hold pairs of EC keys generated using an Elliptic Curve with generator $G$ (an example of such curve could be secp256k1)
- Their private keys are $x_a, x_b$, and $X_a, X_b$ are corresponding public keys
- Alice has committed to her number by making $A = a*G + X_a$ public
- Bob has committed to his number by making $B = b*G + X_b$ public
Transfer
Alice wants to transfer value $c$ to Bob such that $a' = a - c$ and $b' = b + c$. To do this, she does the following:
- Calculates commitment to the new number $A' = (a - c)*G + X_a$
- Calculates commitment to the transferred number $C_1 = c*G$
- Calculates shared secret with Bob and uses it to build a shared key $s = H(x_a * X_b$), where $H$ is a hashing function
- Encrypts $c$ with the shared key $C_2 = E(c, s)$, where $E$ is a symmetric encryption function
- Makes the following info public $(A', C_1, C_2)$
Bob receives the info and does the following:
- Calculates shared secret with Alice and uses it to build a shared key $s = H(x_b * X_a$)
- Uses the shared key to decrypt the value of $c = D(C_2, s)$, where $D$ is a symmetric decryption function
- Verifies that $C_1 = c * G$
- Calculates commitment to the new number $B' = (b + c) * G + X_b$
- Makes $B'$ public
Verification
An independent observer (Victor) can verify that the total value in the system didn't change by doing the following:
- Verify that $A = A' + C_1$
- Verify that $B' = B + C_1$
The scheme above should be secure because all numbers are padded. The numbers are 256-bit integers with:
- 64 most significant bits containing the actual number
- The remaining 192 bits set randomly
So, effectively, instead of transferring something like $2$, Alice would be transferring something like $2.00034094035343043$