-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using the library to test if a secret is within range #2
Comments
Hi, About your question: to use bulletproof to show that a number x is within interval ( I think this can be a nice addition to a library. The protocol is straight forward. Would you like to give it a try yourself?
|
Thanks @omershlo , |
It would be better if you add the feature to this library. |
sure, I have no problem take it but be aware that do to time constraints it will take some time (super busy at the moment). If this is a PoC I strongly encourage you to give it a go (I will review), Rust is much better suited for bulletproof and cryptography in general and the library in KZen repo will allow you to do it very easily. |
Thanks @omershlo |
Hi,
|
Hi @omershlo , So how would this look? const pedCom1 = utils.ec.g.mul(x1.toString(Consts.HEX)).add(utils.ec.g.mul((r0.multiply(r1)).toString(Consts.HEX))); How do I modify this to achieve the above steps? |
Does this look correct? const {A,S,T1,T2,tauX,miu,tX,L,R,aTag,bTag} = rangeBpProver(x1,pedCom1.subtract(pedComOfa),r0,r1); const result10 = rangeBpVerifier(r0,r1,pedCom1.subtract(pedComOfa),A,S,T1,T2,tauX,miu,tX,L,R,aTag,bTag); |
I think you got the general idea. pay attention that this library and in general bulletproofs will work for powers of 2. see my protocol in ZenGo-X/bulletproofs#16. |
Hi @omershlo , I am simply taking difference between number and start point and then calculate proof for that. const x1 = turnToBig(6) var {A,S,T1,T2,tauX,miu,tX,L,R,aTag,bTag} = rangeBpProver(difference,pedCom1,r0,r1); |
two comments:
|
How do you achieve subtraction of commitments? |
exactly. but you need to send the verifier both commitment and the opening of the commitment to the start value so that he can make sure you did not cheat with the subtraction |
This is what I got so far, But the proof is failing. is it because of the wrong random values? const x1 = turnToBig(4) // prover will generate a commitment of start //prover subtracts second commitment from first var {A,S,T1,T2,tauX,miu,tX,L,R,aTag,bTag} = rangeBpProver(difference,pedComDiff,r0,r1); if(result10 == false){} //abort |
ok, Finally got it, Took a bit of math to do it. here is algorithm to what I did pedcom1= gx+g(r2r3) gx+g(r2r3)-ga+g*(r0r1)-g(r2r1)-g(r0r3) pedcom1-ga+g(r0r1)-(g(r2r1)+g(r0*r3)) The Prover only sends the peddersen commitment for x1 and the random values he used. The verifier does the rest of the calculation based on the above formula This works I tested it Raised a pull request with the code |
your alg looks good overall. few comments:
I will check your pr after you answer this points :) |
Followed the steps mentioned on stackoverflow question I posted
|
regarding point 3: one range proof is enough. after all the subtractions the prover suppose to have one pedcom for value |
The problem with that is b-a needs to be to the power of 2. which really limits it. for example if I want to calculate number between 16 and 64 . both start and end are to the power of 2, this can be implemented easily with the current PR. however 64-16 becomes 48. which is not a number to the power of 2. |
I see. I thought that |
Well,I follow the below steps:
|
sounds right (up to the point of using too much randomness we discussed and making it non interactive). But we are in the world of proof of concept and what you are doing is working and its secure. I will merge :) |
Great! , should I close this issue? |
Can I use the library to test if a secret is within range. for example age>18 etc.
if so how would I write such a code?
The text was updated successfully, but these errors were encountered: