Skip to content

Commit a1b4fec

Browse files
committed
Integrate new accumulator in proof_system and remove unneccessary macro
Signed-off-by: lovesh <lovesh.bond@gmail.com>
1 parent 77ebdfa commit a1b4fec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+4888
-1684
lines changed

bbs_plus/src/setup.rs

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ use ark_ff::{
5454
PrimeField,
5555
};
5656
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
57-
use ark_std::{cfg_iter, fmt::Debug, io::Write, rand::RngCore, vec::Vec, UniformRand};
57+
use ark_std::{cfg_iter, fmt::Debug, rand::RngCore, vec::Vec, UniformRand};
5858
use digest::{Digest, DynDigest};
59-
use schnorr_pok::{error::SchnorrError, impl_proof_of_knowledge_of_discrete_log};
59+
6060
use zeroize::{Zeroize, ZeroizeOnDrop};
6161

6262
use core::iter::once;
@@ -434,8 +434,6 @@ impl_public_key!(PublicKeyG2, G2Affine, SignatureParamsG1);
434434
impl_public_key!(PublicKeyG1, G1Affine, SignatureParamsG2);
435435
impl_keypair!(KeypairG2, G2Projective, PublicKeyG2, SignatureParamsG1);
436436
impl_keypair!(KeypairG1, G1Projective, PublicKeyG1, SignatureParamsG2);
437-
impl_proof_of_knowledge_of_discrete_log!(PoKSecretKeyInPublicKeyG2, PoKSecretKeyInPublicKeyG2Proof);
438-
impl_proof_of_knowledge_of_discrete_log!(PoKSecretKeyInPublicKeyG1, PoKSecretKeyInPublicKeyG1Proof);
439437

440438
#[serde_as]
441439
#[derive(
@@ -603,7 +601,10 @@ mod tests {
603601
use ark_bls12_381::Bls12_381;
604602
use ark_std::rand::{rngs::StdRng, SeedableRng};
605603
use blake2::Blake2b512;
606-
use schnorr_pok::compute_random_oracle_challenge;
604+
use schnorr_pok::{
605+
compute_random_oracle_challenge,
606+
discrete_log::{PokDiscreteLog, PokDiscreteLogProtocol},
607+
};
607608

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

@@ -731,7 +732,7 @@ mod tests {
731732
#[test]
732733
fn proof_of_knowledge_of_public_key() {
733734
macro_rules! check {
734-
($group_affine:ident, $protocol_name:ident, $proof_name:ident, $public_key:ident, $params:ident) => {
735+
($group_affine:ident, $public_key:ident, $params:ident) => {
735736
let mut rng = StdRng::seed_from_u64(0u64);
736737
let params = $params::<Bls12_381>::new::<Blake2b512>("test".as_bytes(), 5);
737738
let seed = [0, 1, 2, 10, 11];
@@ -742,17 +743,18 @@ mod tests {
742743
let witness = sk.0.clone();
743744
let blinding = Fr::rand(&mut rng);
744745

745-
let protocol = $protocol_name::<<Bls12_381 as Pairing>::$group_affine>::init(
746-
witness, blinding, base,
747-
);
746+
let protocol =
747+
PokDiscreteLogProtocol::<<Bls12_381 as Pairing>::$group_affine>::init(
748+
witness, blinding, base,
749+
);
748750

749751
let mut chal_contrib_prover = vec![];
750752
protocol
751753
.challenge_contribution(base, &pk.0, &mut chal_contrib_prover)
752754
.unwrap();
753755

754756
test_serialization!(
755-
$protocol_name<<Bls12_381 as Pairing>::$group_affine>,
757+
PokDiscreteLogProtocol<<Bls12_381 as Pairing>::$group_affine>,
756758
protocol
757759
);
758760

@@ -771,23 +773,11 @@ mod tests {
771773
assert_eq!(chal_contrib_prover, chal_contrib_verifier);
772774
assert_eq!(challenge_prover, challenge_verifier);
773775

774-
test_serialization!($proof_name<<Bls12_381 as Pairing>::$group_affine>, proof);
776+
test_serialization!(PokDiscreteLog<<Bls12_381 as Pairing>::$group_affine>, proof);
775777
};
776778
}
777779

778-
check!(
779-
G2Affine,
780-
PoKSecretKeyInPublicKeyG2,
781-
PoKSecretKeyInPublicKeyG2Proof,
782-
PublicKeyG2,
783-
SignatureParamsG1
784-
);
785-
check!(
786-
G1Affine,
787-
PoKSecretKeyInPublicKeyG1,
788-
PoKSecretKeyInPublicKeyG1Proof,
789-
PublicKeyG1,
790-
SignatureParamsG2
791-
);
780+
check!(G2Affine, PublicKeyG2, SignatureParamsG1);
781+
check!(G1Affine, PublicKeyG1, SignatureParamsG2);
792782
}
793783
}

bbs_plus/src/threshold/base_ot_phase.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ use digest::Digest;
1414
use oblivious_transfer_protocols::{
1515
base_ot::simplest_ot::{
1616
Challenges, HashedKey, OneOfTwoROTSenderKeys, ROTReceiverKeys, ROTSenderSetup,
17-
ReceiverPubKeys, Responses, SecretKnowledgeProof, SenderPubKey, VSROTChallenger,
18-
VSROTResponder,
17+
ReceiverPubKeys, Responses, SenderPubKey, VSROTChallenger, VSROTResponder,
1918
},
2019
Bit, ParticipantId,
2120
};
21+
use schnorr_pok::discrete_log::PokDiscreteLog;
2222
use serde::{Deserialize, Serialize};
2323

2424
/// The participant runs an independent base OT with each participant and stores each OT's state. If
@@ -54,7 +54,7 @@ pub struct BaseOTPhaseOutput {
5454
Clone, Debug, PartialEq, CanonicalSerialize, CanonicalDeserialize, Serialize, Deserialize,
5555
)]
5656
#[serde(bound = "")]
57-
pub struct SenderPubKeyAndProof<G: AffineRepr>(SenderPubKey<G>, SecretKnowledgeProof<G>);
57+
pub struct SenderPubKeyAndProof<G: AffineRepr>(SenderPubKey<G>, PokDiscreteLog<G>);
5858

5959
impl<G: AffineRepr> BaseOTPhase<G> {
6060
pub fn init<R: RngCore, D: Digest>(

benches/benches/schnorr_protocol.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,40 @@
11
use ark_bls12_381::Bls12_381;
22
use ark_ec::{pairing::Pairing, AffineRepr, CurveGroup, VariableBaseMSM};
33
use ark_ff::PrimeField;
4-
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
54
use ark_std::{
6-
io::Write,
75
rand::{rngs::StdRng, SeedableRng},
86
UniformRand,
97
};
108
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
11-
use dock_crypto_utils::serde_utils::*;
12-
use schnorr_pok::{
13-
error::SchnorrError, impl_proof_of_knowledge_of_discrete_log, SchnorrCommitment,
14-
};
15-
use serde::{Deserialize, Serialize};
16-
use serde_with::serde_as;
17-
use zeroize::{Zeroize, ZeroizeOnDrop};
9+
use schnorr_pok::{discrete_log::PokDiscreteLogProtocol, SchnorrCommitment};
1810

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

2113
macro_rules! bench_single {
2214
($group_affine:ident, $group_projective:ident, $c: ident) => {
2315
let mut rng = StdRng::seed_from_u64(0u64);
24-
impl_proof_of_knowledge_of_discrete_log!(Protocol, Proof);
2516
let base = <Bls12_381 as Pairing>::$group_projective::rand(&mut rng).into_affine();
2617
let witness = Fr::rand(&mut rng);
2718

2819
$c.bench_function("Generate proof", |b| {
2920
b.iter(|| {
3021
let blinding = Fr::rand(&mut rng);
31-
let protocol = Protocol::<<Bls12_381 as Pairing>::$group_affine>::init(
32-
black_box(witness),
33-
blinding,
34-
black_box(&base),
35-
);
22+
let protocol =
23+
PokDiscreteLogProtocol::<<Bls12_381 as Pairing>::$group_affine>::init(
24+
black_box(witness),
25+
blinding,
26+
black_box(&base),
27+
);
3628
let challenge = Fr::rand(&mut rng);
3729
protocol.gen_proof(&challenge);
3830
})
3931
});
4032

4133
let y = base.mul_bigint(witness.into_bigint()).into_affine();
4234
let blinding = Fr::rand(&mut rng);
43-
let protocol =
44-
Protocol::<<Bls12_381 as Pairing>::$group_affine>::init(witness, blinding, &base);
35+
let protocol = PokDiscreteLogProtocol::<<Bls12_381 as Pairing>::$group_affine>::init(
36+
witness, blinding, &base,
37+
);
4538
// Not benchmarking challenge contribution as that is just serialization
4639
let challenge = Fr::rand(&mut rng);
4740
let proof = protocol.gen_proof(&challenge);

delegatable_credentials/src/msbm/issuance.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ use crate::{
77
PreparedRootIssuerPublicKey, RootIssuerSecretKey, UpdateKey, UserPublicKey,
88
UserSecretKey,
99
},
10-
sps_eq_uc_sig::{RandCommitmentProof, Signature},
10+
sps_eq_uc_sig::Signature,
1111
},
1212
set_commitment::{SetCommitment, SetCommitmentOpening, SetCommitmentSRS},
1313
};
1414
use ark_ec::pairing::Pairing;
1515
use ark_std::{rand::RngCore, vec::Vec, UniformRand};
16+
use schnorr_pok::discrete_log::PokDiscreteLog;
1617

1718
/// Credential issued by a root or delegated issuer when it knows the randomness for set commitments
1819
/// of attributes
@@ -454,7 +455,7 @@ impl<E: Pairing> CredentialWithoutOpenings<E> {
454455
rng: &mut R,
455456
trapdoor: &E::ScalarField,
456457
commitment_to_randomness: Vec<E::G1Affine>,
457-
commitment_to_randomness_proof: Vec<RandCommitmentProof<E::G1Affine>>,
458+
commitment_to_randomness_proof: Vec<PokDiscreteLog<E::G1Affine>>,
458459
challenge: &E::ScalarField,
459460
attributes: Vec<Vec<E::ScalarField>>,
460461
user_public_key: &UserPublicKey<E>,
@@ -502,16 +503,13 @@ impl<E: Pairing> CredentialWithoutOpenings<E> {
502503
#[cfg(test)]
503504
pub mod tests {
504505
use super::*;
505-
use crate::msbm::{
506-
keys::{RootIssuerPublicKey, UserSecretKey},
507-
sps_eq_uc_sig::RandCommitmentProtocol,
508-
};
506+
use crate::msbm::keys::{RootIssuerPublicKey, UserSecretKey};
509507
use ark_bls12_381::Bls12_381;
510508
use ark_ec::{AffineRepr, CurveGroup};
511509
use ark_ff::PrimeField;
512510
use ark_std::rand::{rngs::StdRng, SeedableRng};
513511
use blake2::Blake2b512;
514-
use schnorr_pok::compute_random_oracle_challenge;
512+
use schnorr_pok::{compute_random_oracle_challenge, discrete_log::PokDiscreteLogProtocol};
515513

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

@@ -608,7 +606,7 @@ pub mod tests {
608606

609607
for i in 0..l {
610608
commit_to_rands.push(P1.mul_bigint(randoms[i].into_bigint()).into_affine());
611-
protocols.push(RandCommitmentProtocol::init(randoms[i], blindings[i], P1));
609+
protocols.push(PokDiscreteLogProtocol::init(randoms[i], blindings[i], P1));
612610
protocols[i]
613611
.challenge_contribution(P1, &commit_to_rands[i], &mut challenge_bytes)
614612
.unwrap();

delegatable_credentials/src/msbm/show.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
//! Credential show and verification from Fig. 3 of the paper
22
3-
use ark_ec::{pairing::Pairing, AffineRepr, CurveGroup};
4-
use ark_ff::PrimeField;
5-
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
3+
use ark_ec::pairing::Pairing;
4+
65
use ark_std::{collections::BTreeSet, io::Write, rand::RngCore, vec::Vec, UniformRand};
76
use digest::Digest;
8-
use serde::{Deserialize, Serialize};
9-
use serde_with::serde_as;
10-
use zeroize::{Zeroize, ZeroizeOnDrop};
117

12-
use dock_crypto_utils::serde_utils::ArkObjectBytes;
13-
use schnorr_pok::{error::SchnorrError, impl_proof_of_knowledge_of_discrete_log};
8+
use schnorr_pok::discrete_log::{PokDiscreteLog, PokDiscreteLogProtocol};
149

1510
use crate::{
1611
error::DelegationError,
@@ -24,8 +19,6 @@ use crate::{
2419
},
2520
};
2621

27-
impl_proof_of_knowledge_of_discrete_log!(NymOwnershipProtocol, NymOwnership);
28-
2922
#[derive(Clone, Debug)]
3023
pub struct CredentialShow<E: Pairing> {
3124
/// Commitment to each attribute set
@@ -36,7 +29,7 @@ pub struct CredentialShow<E: Pairing> {
3629
pub disclosed_attributes_witness: AggregateSubsetWitness<E>,
3730
pub pseudonym: UserPublicKey<E>,
3831
/// Schnorr proof of knowledge of secret key corresponding to the pseudonym.
39-
pub schnorr: NymOwnership<E::G1Affine>,
32+
pub schnorr: PokDiscreteLog<E::G1Affine>,
4033
}
4134

4235
/// Protocol to create `CredentialShow`
@@ -47,7 +40,7 @@ pub struct CredentialShowProtocol<E: Pairing> {
4740
pub disclosed_attributes_witness: AggregateSubsetWitness<E>,
4841
pub pseudonym: UserPublicKey<E>,
4942
pub pseudonym_secret: UserSecretKey<E>,
50-
pub schnorr: NymOwnershipProtocol<E::G1Affine>,
43+
pub schnorr: PokDiscreteLogProtocol<E::G1Affine>,
5144
}
5245

5346
impl<E: Pairing> CredentialShowProtocol<E> {
@@ -94,7 +87,7 @@ impl<E: Pairing> CredentialShowProtocol<E> {
9487
)?;
9588

9689
let blinding = E::ScalarField::rand(rng);
97-
let schnorr = NymOwnershipProtocol::init(new_usk.0, blinding, set_comm_srs.get_P1());
90+
let schnorr = PokDiscreteLogProtocol::init(new_usk.0, blinding, set_comm_srs.get_P1());
9891
Ok(Self {
9992
commitments: rand_cred.commitments.clone(),
10093
signature: rand_cred.signature,

delegatable_credentials/src/msbm/sps_eq_uc_sig.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
88
use ark_std::{
99
cfg_into_iter, cfg_iter,
1010
collections::BTreeSet,
11-
io::Write,
1211
ops::{Add, Mul, Neg},
1312
rand::RngCore,
1413
vec::Vec,
@@ -17,10 +16,11 @@ use ark_std::{
1716
use digest::Digest;
1817

1918
use dock_crypto_utils::serde_utils::ArkObjectBytes;
20-
use schnorr_pok::{error::SchnorrError, impl_proof_of_knowledge_of_discrete_log};
19+
20+
use schnorr_pok::discrete_log::PokDiscreteLog;
2121
use serde::{Deserialize, Serialize};
2222
use serde_with::serde_as;
23-
use zeroize::{Zeroize, ZeroizeOnDrop};
23+
use zeroize::Zeroize;
2424

2525
use crate::{
2626
mercurial_sig::Signature as MercurialSig,
@@ -36,8 +36,6 @@ use crate::{
3636
#[cfg(feature = "parallel")]
3737
use rayon::prelude::*;
3838

39-
impl_proof_of_knowledge_of_discrete_log!(RandCommitmentProtocol, RandCommitmentProof);
40-
4139
#[serde_as]
4240
#[derive(
4341
Clone,
@@ -130,7 +128,7 @@ impl<E: Pairing> Signature<E> {
130128
rng: &mut R,
131129
trapdoor_set_comm_srs: &E::ScalarField,
132130
commitment_to_randomness: Vec<E::G1Affine>,
133-
commitment_to_randomness_proof: Vec<RandCommitmentProof<E::G1Affine>>,
131+
commitment_to_randomness_proof: Vec<PokDiscreteLog<E::G1Affine>>,
134132
challenge: &E::ScalarField,
135133
messages: Vec<Vec<E::ScalarField>>,
136134
user_public_key: &UserPublicKey<E>,

0 commit comments

Comments
 (0)