Closed pranavkirtani88 closed 4 years ago
Can you find the specific part in the go code that is handling this ?
The following code: I believe they achieve this by having 2 end ranges. The first one is to the power of 2^n and the other one is user provided (b)
if x-b is a negative number then x-b+end_range would be within range. however if it is positive number then it will be out of range. same would apply for the value of "a" and start range. func ProveGeneric(secret big.Int, params bprp) (ProofBPRP, error) { var proof ProofBPRP
// x - b + 2^N
p2 := new(big.Int).SetInt64(MAX_RANGE_END)
xb := new(big.Int).Sub(secret, new(big.Int).SetInt64(params.B))
xb.Add(xb, p2)
var err1 error
proof.P1, err1 = Prove(xb, params.BP1)
if err1 != nil {
return proof, err1
}
xa := new(big.Int).Sub(secret, new(big.Int).SetInt64(params.A))
var err2 error
proof.P2, err2 = Prove(xa, params.BP2)
if err2 != nil {
return proof, err2
}
return proof, nil
}
If I understand correctly - to prove a number x
is between a
and b
: a<x<b
:
define, max_range
.
define y1 = x-b+max_range
define y2 = x -a
proof1 : y1< max_range
= 2^N
proof2: y2 > 0
which can be done by proving y2< max_range
This is clever. I think we can do it here as well.
l will ask it in our telegram group (https://t.me/kzen_research) as well, maybe someone will see a reason why it shouldn't work.
I raised a PR here with the changes made to the library
Hi, I was looking the go implementation of bullet proofs (https://github.com/ing-bank/zkrp ) It appears they support ranges for numbers which are not to the power of 2. Do you think there is a way to achieve a similar result in javascript?