This is an improvement of the protocol described here. The protocol does not require trusted setup and is very efficient (much more efficient than anything else I could find). The protocol allows the following:
- Alice and Bob hold secret values $a$ and $b$ respectively.
- 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 so without learning any of the amounts involved.
If anyone sees holes in the protocol described below, or, if there is a better (more efficient) way to do it, I would greatly appreciate feedback.
Setup
To facilitate the transfer, two elliptic curves of different orders are used. These curves are $g_1$ and $g_2$ of orders $q_1$ and $q_2$ and generators $G_1$ and $G_2$. The orders $q_1$ and $q_2$ should be distinct but very close to each other, with $q_1 < q_2$.
Using these curves, Alice and Bob can create public commitments to their values. For example, committing to value $a$ would work as follows:
- Map value $a$ to points on both curves as $A_1 = a ⋅ G_1$ and $A_2 = a ⋅ G_2$
- Choose a random value $r$ and calculate $T=r⋅G_1$, $S=r⋅G_2$
- Calculate $u=H(G_1,G_2,A_1,A_2,T,S)$, where $H$ is a hash function
- Calculate $v=r+a⋅u$ such that $\frac{v}{u} < q_1$. This may require iterating through several values of $r$
- The commitment to $a$ is then defined as $A = (A_1,A_2, T, S, v)$
An observer can verify that $A_1$ and $A_2$ are derived from the same $a$ and that $a < q_1$ by doing the following:
- Compute $u$
- Check that $\frac{v}{u} < q_1$
- Check that $v⋅G_1=T+u⋅A_1$ and $v⋅G_2=S+u⋅A_2$
Initial State
- Alice has publicly committed to $a$ using the methodology described above and publishing $A = (A_1,A_2, T_a, S_a, v_a)$. We assume that is known for a fact that $A_1$ and $A_2$ refer to the same value $a$.
- Bob has publicly committed to $b$ using the methodology described above and publishing $B = (B_1,B_2, T_b, S_b, v_b)$. We assume that it is known for a fact that $B_1$ and $B_2$ refer to the same value $b$.
Transfer
Alice wants to transfer value $k$ to Bob such that $a' = a - k$ and $b' = b + k$. To do this, she does the following:
- Calculates commitment for the new value $a'$ as $A' = (A_1', A_2', T_{a'}, S_{a'}, v_{a'})$
- Calculates commitment for value $k$ as $K = (K_1,K_2,T_k,S_k,v_k)$
- Makes both commitments public by publishing $A'$ and $K$
Bob receives value $k$ from Alice via a secure channel and does the following:
- Verifies that $K_1 = k ⋅ G_1$ and $K_2 = k ⋅ G_2$
- Calculates his new value $b'$ as $b' = b + k$
- Calculates commitment to $b'$ as $B' = (B_1', B_2', T_{b'}, S_{b'}, v_{b'})$
- Makes the new commitment to $b$ public by sharing $B'$
Verification
An independent observer (Victor) can verify that the total value in the system didn't change by doing the following:
- Verify that each pair of points $(A_1', A_2'), (B_1', B_2'), (K_1, K_2)$ was derived from the same values and that each of the underlying values is less than $q_1$ using the methodology described previously
- Verify that $A_1 = A_1' + K_1$ and $A_2 = A_2' + K_2$
- Verify that $B_1' = B_1 + K_1$ and $B_2' = B_2 + K_2$
The scheme above should be secure because all values are effectively padded. The numbers are 256-bit integers that have the following properties:
- A single "coin" consists $10^{69}$ indivisible "units"
- This implies that a single coin requires 230 bits to express
- When transferring values, users randomize the lower bits (e.g. lower 220 bits) such that the same value is never sent twice
So, effectively, instead of transferring something like $2$, Alice would be transferring something like $2.0000003487094035343043$
Note: to prevent forgery, Alice and Bob could also sign their commitments - but this is not covered by the description above.