Skip to content

Commit

Permalink
Fix compile issues and some refactoring
Browse files Browse the repository at this point in the history
Signed-off-by: lovesh <[email protected]>
  • Loading branch information
lovesh committed Nov 4, 2024
1 parent 8b705f4 commit 1702486
Show file tree
Hide file tree
Showing 16 changed files with 350 additions and 369 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ jobs:
toolchain: stable
override: true
- name: Run tests
run: cargo test --release --all
run: RUST_MIN_STACK=8388608 cargo test --release --all --no-fail-fast
1 change: 1 addition & 0 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.4.0"
edition.workspace = true
authors.workspace = true
license.workspace = true
publish = false

[dependencies]
bbs_plus = { default-features = false, path = "../bbs_plus" }
Expand Down
3 changes: 2 additions & 1 deletion benches/benches/bbs_plus_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ use ark_std::{
UniformRand,
};
use bbs_plus::{
proof::{MessageOrBlinding, PoKOfSignatureG1Protocol},
proof::PoKOfSignatureG1Protocol,
setup::{KeypairG2, SignatureParamsG1},
signature::SignatureG1,
};
use benches::setup_bbs_plus;
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
use dock_crypto_utils::signature::MessageOrBlinding;

type Fr = <Bls12_381 as Pairing>::ScalarField;

Expand Down
3 changes: 2 additions & 1 deletion benches/benches/bbs_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ use ark_std::{
UniformRand,
};
use bbs_plus::prelude::{
KeypairG2, MessageOrBlinding, PoKOfSignature23G1Protocol, Signature23G1, SignatureParams23G1,
KeypairG2, PoKOfSignature23G1Protocol, Signature23G1, SignatureParams23G1,
};

use benches::setup_bbs_plus;
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
use dock_crypto_utils::signature::MessageOrBlinding;

type Fr = <Bls12_381 as Pairing>::ScalarField;

Expand Down
4 changes: 3 additions & 1 deletion kvac/src/bbs_sharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ In the former, the verifier is either the signer (has the secret key) or can ask
In the latter, the user needs to communicate with the signer before creating a proof and get "some helper data"
to create a proof which the verifier can check without needing the secret key or interacting with the issuer.
For efficiency and avoiding correlation (when signer and verifier collude), the user gets a batch of
"helper data" to let him create several proofs.
"helper data" to let him create several proofs.
Also, the proof of knowledge of MAC protocol specified in footnote 31 in the paper is modified to allow integration with other
protocols, see the code comments in the relevant module.

Implements designated verifier proof for both issuer's signature (proof of validity of MAC) and user's proof of knowledge of MAC
4 changes: 3 additions & 1 deletion kvac/src/bbs_sharp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
//! In the latter, the user needs to communicate with the signer before creating a proof and get "some helper data"
//! to create a proof which the verifier can check without needing the secret key or interacting with the issuer.
//! For efficiency and avoiding correlation (when signer and verifier collude), the user gets a batch of
//! "helper data" to let him create several proofs.
//! "helper data" to let him create several proofs.
//! Also, the proof of knowledge of MAC protocol specified in footnote 31 in the paper is modified to allow
//! integration with other protocols, see the code comments in the relevant module.
//!
//! Implements designated verifier proof for both issuer's signature (proof of validity of MAC) and user's proof of
//! knowledge of MAC
Expand Down
9 changes: 6 additions & 3 deletions legogroth16/src/circom/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use std::{
collections::{BTreeSet, HashMap},
ops::AddAssign,
path::PathBuf,
time::Instant,
};

/// Given path relative to this crate, return absolute disk path
Expand Down Expand Up @@ -54,6 +55,7 @@ pub fn prove_and_verify_circuit<E: Pairing>(
params: &ProvingKey<E>,
commit_witness_count: u32,
) -> Vec<E::ScalarField> {
let start = Instant::now();
let cs = ConstraintSystem::<E::ScalarField>::new_ref();
circuit.clone().generate_constraints(cs.clone()).unwrap();
assert!(cs.is_satisfied().unwrap());
Expand All @@ -71,9 +73,10 @@ pub fn prove_and_verify_circuit<E: Pairing>(
let mut rng = StdRng::seed_from_u64(300u64);
let v = E::ScalarField::rand(&mut rng);
let proof = create_random_proof(circuit, v, params, &mut rng).unwrap();
println!("Proof generated");
println!("Proof generated in {:?}", start.elapsed());

let pvk = prepare_verifying_key::<E>(&params.vk);
let start = Instant::now();
// Prover verifies the openings of the commitments in proof.d
verify_witness_commitment(
&params.vk,
Expand All @@ -84,8 +87,8 @@ pub fn prove_and_verify_circuit<E: Pairing>(
)
.unwrap();
verify_proof(&pvk, &proof, &public_inputs).unwrap();
println!("Proof verified");
return public_inputs;
println!("Proof verified in {:?}", start.elapsed());
public_inputs
}

pub fn generate_params_prove_and_verify<
Expand Down
25 changes: 9 additions & 16 deletions proof_system/src/sub_protocols/verifiable_encryption_tz_21.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ pub mod dkgith_decls {
use super::BatchedHashedElgamalCiphertext;
use verifiable_encryption::tz_21::dkgith::{CompressedCiphertext, DkgithProof};

// Very large values for repetitions cause stack overflow
// pub const NUM_PARTIES: usize = 4;
// pub const NUM_REPS: usize = 64;
// pub const SUBSET_SIZE: usize = 48;
// pub const DEPTH: usize = 2;
// pub const NUM_NODES: usize = 7;

pub const NUM_PARTIES: usize = 16;
pub const NUM_REPS: usize = 32;
pub const SUBSET_SIZE: usize = 30;
Expand Down Expand Up @@ -64,16 +57,16 @@ pub mod rdkgith_decls {
use dock_crypto_utils::elgamal::BatchedHashedElgamalCiphertext;
use verifiable_encryption::tz_21::rdkgith::{CompressedCiphertext, RdkgithProof};

// Very large values cause stack overflow
// pub const NUM_PARTIES: usize = 192;
// pub const THRESHOLD: usize = 36;
// pub const NUM_PARTIES_MINUS_THRESHOLD: usize = 156;
// pub const SUBSET_SIZE: usize = 145;
pub const NUM_PARTIES: usize = 192;
pub const THRESHOLD: usize = 36;
pub const NUM_PARTIES_MINUS_THRESHOLD: usize = 156;
pub const SUBSET_SIZE: usize = 145;

pub const NUM_PARTIES: usize = 50;
pub const THRESHOLD: usize = 35;
pub const NUM_PARTIES_MINUS_THRESHOLD: usize = 15;
pub const SUBSET_SIZE: usize = 10;
// Very large values cause stack overflow so use them when testing on smaller stack
// pub const NUM_PARTIES: usize = 50;
// pub const THRESHOLD: usize = 35;
// pub const NUM_PARTIES_MINUS_THRESHOLD: usize = 15;
// pub const SUBSET_SIZE: usize = 10;

pub type Proof<G> = RdkgithProof<
G,
Expand Down
Loading

0 comments on commit 1702486

Please sign in to comment.