How Does Peggy Prove To Victor The Banker That Her Salary is between $30K and $100K Without…

There are many things in life ask if we have something that is in a certain range, such as for our age, our salary or even our weight. But…

Photo by Mathieu Stern on Unsplash

How Does Peggy Prove To Victor The Banker That Her Salary is between $30K and $100K Without Revealing It?

There are many things in life ask if we have something that is in a certain range, such as for our age, our salary or even our weight. But when we answer the question we often have to give away the actual value. So how can we take our value, and show someone that the range is in a certain range? Well for this we can use range proofs.

So let’s say that Victor wants Peggy to prove that her salary is between $30K and $100K. We will now use the Damgard Fukisaki method to prove that Peggy’s salary is in a given range [here]:

First Victor and Peggy agree on two bases for their calculations (g and h) and a prime number (n). Victor then sends Peggy using a random number (r) as a challenge. Every positive value can be represented in the form:

For example:

Peggy now creates four commitments from these four values and takes four random numbers (r0, r1, r2 and r3).

And:

Victor then checks:

And this should be equal to:

Now to prove the range, we take (x-a) and (b-x) and which should be positive values. Next, we compute a commitment of:

and:

To prove the commitments we take:

and:

and they should be equal to:

And so I have coded this here:

https://asecuritysite.com/zero/z_df3

Now, let’s code for ECC. We start with two points on the curve: G and H. And then can compute:

and then:

r=r_0+r_1+r_2+r_3

Victor then checks:

c=c_1+c_2+c_3+c_4

and check than this equals:

x.G+r.H

Next, the code is [here]:

c1 := G.Mul(b.Sub(n)).Add(H.Mul(r.Neg()))
c2 := G.Mul(n.Sub(a)).Add(H.Mul(r))
p1 := G.Mul(b).Sub(c1)
2 := c2.Add(G.Mul(a))
if p1.Equal(p2) {
fmt.Printf("\n%d is in the range of %d and %d\n", nv, na, nb)
} else {
fmt.Printf("\n%d is NOT in the range of %d and %d\n", nv, na, nb)
}

Here is the demo:

https://asecuritysite.com/zero/z_df5

Conclusions

Range proofs can be used in a whole lot of applications, include within a cryptocurrency transaction, and where Peggy can prove to Victor that she has enough cryptocurrency to pay for a transaction, without revealing the amount of cryptocurrency she has.