zkcrypto / bulletproofs Goto Github PK
View Code? Open in Web Editor NEWThis project forked from dalek-cryptography/bulletproofs
A pure-Rust implementation of Bulletproofs using Ristretto.
License: MIT License
This project forked from dalek-cryptography/bulletproofs
A pure-Rust implementation of Bulletproofs using Ristretto.
License: MIT License
The code below adds 2 commitments with the value of 200
using 8 bits as size. 200 + 200
should overflow a u8
, this code tries to find what value matches this commitment. Surprisingly (or not), the output I get is 400
which sounds ok since it's 200 + 200
but it is not an u8
. Did I understand the 8 bits size wrong?
use rand::rngs::OsRng;
use curve25519_dalek_ng::scalar::Scalar;
use merlin::Transcript;
use bulletproofs::{BulletproofGens, PedersenGens, RangeProof};
use curve25519_dalek_ng::ristretto::RistrettoPoint;
fn main() {
let nbits = 8;
let ped_commits = PedersenGens::default();
let bullet_gens = BulletproofGens::new(nbits, 1);
let mut csprng: OsRng = OsRng::default();
let blinding_factor = Scalar::random(&mut csprng);
let mut prover_ts = Transcript::new("Test".as_bytes());
let mut prover_ts2 = Transcript::new("Test".as_bytes());
let (_proof, commitment) = RangeProof::prove_single( &bullet_gens,&ped_commits,&mut prover_ts,200,&blinding_factor, nbits,).expect("Oops!");
let (_proof2, commitment2) = RangeProof::prove_single( &bullet_gens,&ped_commits,&mut prover_ts2,200,&blinding_factor, nbits,).expect("Oops!");
// sum for c1 c2
let vec_in = vec![commitment, commitment2];
let res:RistrettoPoint = vec_in.iter()
.map(|v|v.decompress().unwrap())
.sum::<RistrettoPoint>();
// brute force
let bf_sum_inputs = blinding_factor + blinding_factor;
for i in 0..u64::MAX {
// proof for c3
let mut prover_ts3 = Transcript::new("Test".as_bytes());
let (_proof3, commitment3) = RangeProof::prove_single( &bullet_gens,&ped_commits,&mut prover_ts3,i,&bf_sum_inputs, nbits,).expect("Oops!");
// sum for c3
let vec_out = vec![commitment3];
let res2:RistrettoPoint = vec_out.iter()
.map(|v|v.decompress().unwrap())
.sum::<RistrettoPoint>();
// eq check
if res == res2 {
println!("Eq {}", i);
break;
} else {
//println!("{}", i);
}
}
}
@cathieyun can you please publish v5 of this repo
v5 was created from this issue: #15
This involves a 4.0.0
release, and requires aligning versions in dependencies:
curve25519-dalek
;merlin
.Context:
The InnerProductProofs takes a few inputs including g_vec, h_vec, a_vec, b_vec, Q and basically gives a point P and a proof that we know a_vec, b_vec such that
(g_vec^a_vec) (h_vec^b_vec) Q^<a_vec, b_vec> = P
My question:
It seems to me that Q can be any point as long as finding a non trivial discrete log relation between elements of g_vec, h_vec and Q is hard. It particular, I think Q = RISTRETTO_BASEPOINT_POINT (aka self.pc_gens.B) would do. Well, as long as we didn't pick one of the points of g_vec or h_vec to be a known power of RISTRETTO_BASEPOINT_POINT.
In the range proof, this is how Q is defined:
// Get a challenge value to combine statements for the IPP
let w = self.transcript.challenge_scalar(b"w");
let Q = w * self.pc_gens.B;
I'm wondering what is the motivation for constructing it with a challenge. Do we need this point to not be predictable?
This example doesn't compile with neither rust 1.61 (stable) nor rust 1.63 (nightly) as it contains a mistake. Line use curve25519_dalek::scalar::Scalar;
must be replaced with use curve25519_dalek_ng::scalar::Scalar;
for example to build correctly.
Also, extern crate
statements are obsolete since rust 2018 edition and could be safely removed as README suggests using rust nightly which supports 2021 edition
Hi I am trying to understand what is happening around the following 2 repos and their forks:
The repo I am currently building depends on both of the forked repos mentioned above. I have some concerns around curve25519-dalek-ng because there have been no updates since 2021 while the original one receives updates fairly regularly. It seems that the original reason for creating the fork was not actually valid so I tried changing to using curve25519-dalek but since this bulletproos repo depends on curve25519-dalek-ng I can't change to curve25519-dalek unless I change to the original dalek bulletproofs repo. But the problem there is that if I want to use the original repo I must use the rust crate bulletproofs 2.0.0
, which does not compile. Also, it's strange that this bulletproofs repo takes the crate identifier bulletproofs 4.0.0
(why are 2 different versions pointing to 2 different repos?).
What is the recommendation here? Could I make a PR to change this repo to use curve25519-dalek? Should I just fork both repos and do my own thing? Are the changes in curve25519-dalek not necessary for curve25519-dalek-ng?
Failed to compile subtle-ng 2.4.1
(it's also reflected in repo CI). See zkcrypto/subtle-ng#3 or zkcrypto/curve25519-dalek-ng#10.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.