clean up README and clproto.rs
This commit is contained in:
parent
3a9104ab86
commit
cad745d80f
30
README.md
30
README.md
|
@ -11,23 +11,41 @@ The libbolt library is a proof of concept implementation that relies on experime
|
|||
# Dependencies
|
||||
|
||||
* secp256k1
|
||||
* libsodium
|
||||
* sodiumoxide
|
||||
* bn
|
||||
* bulletproofs
|
||||
|
||||
Note that the above rust dependencies will be compiled and installed as a result of running `make` command.
|
||||
|
||||
# Rust Nightly Setup
|
||||
|
||||
Please keep in mind we are currently working with nightly Rust for now which gives access to the nightly compiler and experimental features.
|
||||
|
||||
rustup install nightly
|
||||
|
||||
To run a quick test of the nightly toolchain, run the following command:
|
||||
|
||||
rustup run nightly rustc --version
|
||||
|
||||
Optionally, to make this the default globally, run the following command:
|
||||
|
||||
rustup default nightly
|
||||
|
||||
We will switch to the stable release channel once libbolt (and dependencies) are ready for production use.
|
||||
|
||||
# Build & Install
|
||||
|
||||
Please ensure you have installed the libsodium library for your platform. See install instructions [here](https://download.libsodium.org/doc/installation/index.html).
|
||||
|
||||
To build the library, run `make`
|
||||
To build the library and execute basic tests, run `make`
|
||||
|
||||
# Tests
|
||||
|
||||
To run libbolt tests, run `cargo test` or `make test`
|
||||
To run libbolt unit tests, run `make test`
|
||||
|
||||
# Benchmarks
|
||||
|
||||
To run libbolt benchmarks, run `cargo bench` or `make bench`
|
||||
To run libbolt benchmarks, run `make bench`
|
||||
|
||||
# Usage
|
||||
|
||||
|
@ -57,11 +75,11 @@ The libbolt library provides APIs for three types of privacy-preserving payment
|
|||
|
||||
Build the api documentation by simply running `make doc`. Documentation will be generated in your local `target/doc` directory.
|
||||
|
||||
For the libbolt design documentation, see the `docs/bolt_design.pdf`.
|
||||
For the libbolt design documentation, see the `docs/bolt_design.pdf` document.
|
||||
|
||||
# Contributions
|
||||
|
||||
To contribute code improvements, please checkout the repository as follows:
|
||||
To contribute code improvements, please checkout the repository, make your changes and submit a pull request.
|
||||
|
||||
git clone https://github.com/yeletech/libbolt.git
|
||||
|
||||
|
|
|
@ -44,10 +44,6 @@ pub fn bs_gen_nizk_proof(x: &Vec<Fr>, pub_bases: &Vec<G2>, C: G2) -> ProofCV {
|
|||
|
||||
// hash T to get the challenge
|
||||
let c = hash_g2_to_fr(&T);
|
||||
// debug
|
||||
//let msg = "challenge -> c";
|
||||
//debug_elem_in_hex(msg, &c);
|
||||
|
||||
// compute s values
|
||||
let mut s: Vec<Fr> = Vec::new();
|
||||
for i in 0 .. l {
|
||||
|
@ -70,10 +66,6 @@ pub fn bs_check_proof_and_gen_signature(mpk: &PublicParams, sk: &SecretKeyD, pro
|
|||
pub fn bs_verify_nizk_proof(proof: &ProofCV) -> bool {
|
||||
// if proof is valid, then call part
|
||||
let c = hash_g2_to_fr(&proof.T);
|
||||
// debug
|
||||
//let mut msg = "(in verify proof) challenge -> c";
|
||||
//debug_elem_in_hex(msg, &c);
|
||||
|
||||
let l = proof.s.len(); // number of s values
|
||||
assert!(l <= proof.pub_bases.len());
|
||||
|
||||
|
@ -82,14 +74,7 @@ pub fn bs_verify_nizk_proof(proof: &ProofCV) -> bool {
|
|||
//println!("(in verify proof) i => {}", i);
|
||||
lhs = lhs + (proof.pub_bases[i] * proof.s[i]);
|
||||
}
|
||||
// debug
|
||||
//msg = "(in verify proof) lhs => ";
|
||||
//debug_g2_in_hex(msg, &lhs);
|
||||
|
||||
let rhs = (proof.C * c) + proof.T;
|
||||
// debug
|
||||
//msg = "(in verify proof) rhs => ";
|
||||
//debug_g2_in_hex(msg, &rhs);
|
||||
return lhs == rhs;
|
||||
}
|
||||
|
||||
|
@ -100,8 +85,7 @@ pub fn bs_compute_blind_signature(mpk: &PublicParams, sk: &SecretKeyD, M: G2, nu
|
|||
let a = mpk.g2 * alpha;
|
||||
let mut A: Vec<G2> = Vec::new();
|
||||
let mut B: Vec<G2> = Vec::new();
|
||||
//println!("Num secrets: {}", num_secrets);
|
||||
//println!("sk z len: {}", sk.z.len());
|
||||
|
||||
assert!(sk.z.len() <= num_secrets);
|
||||
let l = sk.z.len();
|
||||
|
||||
|
@ -168,11 +152,6 @@ pub fn gen_common_params(mpk: &PublicParams, pk: &PublicKeyD, sig: &SignatureD)
|
|||
vxyi.push(pairing(pk.X, sig.B[i]));
|
||||
}
|
||||
let vs = pairing(mpk.g1, sig.c);
|
||||
|
||||
// let lhs = vx * vxy.pow(m[0]) * vxyi[0].pow(m[1]) * vxyi[1].pow(m[2]) * vxyi[2].pow(m[3]);
|
||||
// assert!(lhs == vs);
|
||||
// println!("Validated the statement (without blinding)");
|
||||
|
||||
return CommonParams { vx: vx, vxy: vxy, vxyi: vxyi, vs: vs };
|
||||
}
|
||||
|
||||
|
@ -190,8 +169,6 @@ pub fn vs_gen_nizk_proof(x: &Vec<Fr>, cp: &CommonParams, A: Gt) -> ProofVS {
|
|||
for i in 0 .. cp.vxyi.len() {
|
||||
pub_bases.push(cp.vxyi[i]); // u_1 ... u_l
|
||||
}
|
||||
//println!("(vs_gen_nizk_proof) Number of secrets: {}", l);
|
||||
//println!("(vs_gen_nizk_proof) Number of bases: {}", pub_bases.len());
|
||||
|
||||
// compute the T
|
||||
let mut T = pub_bases[0].pow(t[0]); // vx ^ t0
|
||||
|
@ -201,10 +178,6 @@ pub fn vs_gen_nizk_proof(x: &Vec<Fr>, cp: &CommonParams, A: Gt) -> ProofVS {
|
|||
|
||||
// hash T to get the challenge
|
||||
let c = hash_gt_to_fr(&T);
|
||||
// debug
|
||||
//let msg = "(gen nizk proof) challenge -> c";
|
||||
//debug_elem_in_hex(msg, &c);
|
||||
|
||||
// compute s values
|
||||
let mut s: Vec<Fr> = Vec::new();
|
||||
let _s = c + t[0]; // for vx => s0 = (1*c + t[0])
|
||||
|
@ -219,29 +192,15 @@ pub fn vs_gen_nizk_proof(x: &Vec<Fr>, cp: &CommonParams, A: Gt) -> ProofVS {
|
|||
}
|
||||
|
||||
fn part1_verify_proof_vs(proof: &ProofVS) -> bool {
|
||||
// if proof is valid, then call part
|
||||
let c = hash_gt_to_fr(&proof.T);
|
||||
// debug
|
||||
//let mut msg = "(in verify proof) challenge -> c";
|
||||
//debug_elem_in_hex(msg, &c);
|
||||
|
||||
let l = proof.s.len();
|
||||
assert!(l > 1);
|
||||
|
||||
//println!("(in verify proof) i => 0");
|
||||
let mut lhs = proof.pub_bases[0].pow(proof.s[0]);
|
||||
for i in 1 .. l {
|
||||
//println!("(in verify proof) i => {}", i);
|
||||
lhs = lhs * (proof.pub_bases[i].pow(proof.s[i]));
|
||||
}
|
||||
// debug
|
||||
//msg = "(in verify proof) lhs => ";
|
||||
//debug_gt_in_hex(msg, &lhs);
|
||||
|
||||
let rhs = proof.A.pow(c) * proof.T;
|
||||
// debug
|
||||
//msg = "(in verify proof) rhs => ";
|
||||
//debug_gt_in_hex(msg, &rhs);
|
||||
return lhs == rhs;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue