Skip to content

Commit 4e8ed69

Browse files
committed
Use new protocols for committed point addition and scalar multiplication, reorg schnorr_pok crate and add randomized scalar multiplication check
Signed-off-by: lovesh <lovesh.bond@gmail.com>
1 parent 58ba68b commit 4e8ed69

Some content is hidden

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

62 files changed

+2549
-1273
lines changed

bbs_plus/Cargo.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bbs_plus"
3-
version = "0.23.0"
3+
version = "0.24.0"
44
edition.workspace = true
55
authors.workspace = true
66
license.workspace = true
@@ -23,10 +23,10 @@ itertools.workspace = true
2323
serde.workspace = true
2424
serde_with.workspace = true
2525
zeroize.workspace = true
26-
schnorr_pok = { version = "0.21.0", default-features = false, path = "../schnorr_pok" }
27-
dock_crypto_utils = { version = "0.21.0", default-features = false, path = "../utils" }
28-
oblivious_transfer_protocols = { version = "0.10.0", default-features = false, path = "../oblivious_transfer" }
29-
secret_sharing_and_dkg = { version = "0.14.0", default-features = false, path = "../secret_sharing_and_dkg" }
26+
schnorr_pok = { version = "0.22.0", default-features = false, path = "../schnorr_pok" }
27+
dock_crypto_utils = { version = "0.22.0", default-features = false, path = "../utils" }
28+
oblivious_transfer_protocols = { version = "0.11.0", default-features = false, path = "../oblivious_transfer" }
29+
secret_sharing_and_dkg = { version = "0.15.0", default-features = false, path = "../secret_sharing_and_dkg" }
3030

3131
[dev-dependencies]
3232
blake2.workspace = true

bbs_plus/src/proof.rs

+25-9
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ use dock_crypto_utils::{
8585
};
8686
use itertools::multiunzip;
8787
use schnorr_pok::{
88-
discrete_log::{PokTwoDiscreteLogs, PokTwoDiscreteLogsProtocol},
88+
discrete_log::{PokPedersenCommitment, PokPedersenCommitmentProtocol},
8989
error::SchnorrError,
9090
partial::PartialSchnorrResponse,
9191
SchnorrCommitment, SchnorrResponse,
@@ -127,7 +127,7 @@ pub struct PoKOfSignatureG1Protocol<E: Pairing> {
127127
#[serde_as(as = "ArkObjectBytes")]
128128
pub d: E::G1Affine,
129129
/// For proving relation `A_bar - d = A_prime * -e + h_0 * r2`
130-
pub sc_comm_1: PokTwoDiscreteLogsProtocol<E::G1Affine>,
130+
pub sc_comm_1: PokPedersenCommitmentProtocol<E::G1Affine>,
131131
/// For proving relation `g1 + \sum_{i in D}(h_i*m_i)` = `d*r3 + {h_0}*{-s'} + sum_{j notin D}(h_j*m_j)`
132132
pub sc_comm_2: SchnorrCommitment<E::G1Affine>,
133133
#[serde_as(as = "Vec<ArkObjectBytes>")]
@@ -148,7 +148,7 @@ pub struct PoKOfSignatureG1Proof<E: Pairing> {
148148
#[serde_as(as = "ArkObjectBytes")]
149149
pub d: E::G1Affine,
150150
/// Proof of relation `A_bar - d = A_prime * -e + h_0 * r2`
151-
pub sc_resp_1: PokTwoDiscreteLogs<E::G1Affine>,
151+
pub sc_resp_1: PokPedersenCommitment<E::G1Affine>,
152152
/// Proof of relation `g1 + h1*m1 + h2*m2 +.... + h_i*m_i` = `d*r3 + {h_0}*{-s'} + h1*{-m1} + h2*{-m2} + .... + h_j*{-m_j}` for all disclosed messages `m_i` and for all undisclosed messages `m_j`
153153
#[serde_as(as = "ArkObjectBytes")]
154154
pub T2: E::G1Affine,
@@ -214,7 +214,7 @@ impl<E: Pairing> PoKOfSignatureG1Protocol<E> {
214214
let A_prime_affine = A_prime.into_affine();
215215

216216
// Commit to randomness with `h_0` and `A'`, i.e. `bases_1[0]*randomness_1[0] + bases_1[1]*randomness_1[1]`
217-
let sc_comm_1 = PokTwoDiscreteLogsProtocol::init(
217+
let sc_comm_1 = PokPedersenCommitmentProtocol::init(
218218
-signature.e,
219219
E::ScalarField::rand(rng),
220220
&A_prime_affine,
@@ -689,31 +689,37 @@ mod tests {
689689
// Protocol can be serialized
690690
test_serialization!($protocol<Bls12_381>, pok);
691691

692+
let start = Instant::now();
692693
let mut chal_bytes_prover = vec![];
694+
keypair
695+
.public_key
696+
.serialize_compressed(&mut chal_bytes_prover)
697+
.unwrap();
693698
pok.challenge_contribution(&revealed_msgs, &params, &mut chal_bytes_prover)
694699
.unwrap();
695700
let challenge_prover =
696701
compute_random_oracle_challenge::<Fr, Blake2b512>(&chal_bytes_prover);
697702

698-
let start = Instant::now();
699703
let proof = pok.gen_proof(&challenge_prover).unwrap();
700704
proof_create_duration += start.elapsed();
701705

702706
let public_key = &keypair.public_key;
703707
assert!(params.is_valid());
704708
assert!(public_key.is_valid());
705709

710+
let start = Instant::now();
706711
let mut chal_bytes_verifier = vec![];
712+
keypair
713+
.public_key
714+
.serialize_compressed(&mut chal_bytes_verifier)
715+
.unwrap();
707716
proof
708717
.challenge_contribution(&revealed_msgs, &params, &mut chal_bytes_verifier)
709718
.unwrap();
710719
let challenge_verifier =
711720
compute_random_oracle_challenge::<Fr, Blake2b512>(&chal_bytes_verifier);
712721

713722
assert_eq!(chal_bytes_prover, chal_bytes_verifier);
714-
715-
let mut proof_verif_duration = Duration::default();
716-
let start = Instant::now();
717723
proof
718724
.verify(
719725
&revealed_msgs,
@@ -722,7 +728,7 @@ mod tests {
722728
params.clone(),
723729
)
724730
.unwrap();
725-
proof_verif_duration += start.elapsed();
731+
let proof_verif_duration = start.elapsed();
726732

727733
// Proof can be serialized
728734
test_serialization!($proof<Bls12_381>, proof);
@@ -876,6 +882,9 @@ mod tests {
876882

877883

878884
let mut chal_bytes_prover = vec![];
885+
keypair_1.public_key.serialize_compressed(&mut chal_bytes_prover).unwrap();
886+
keypair_2.public_key.serialize_compressed(&mut chal_bytes_prover).unwrap();
887+
keypair_3.public_key.serialize_compressed(&mut chal_bytes_prover).unwrap();
879888
pok_1
880889
.challenge_contribution(&revealed_msgs_1, &params_1, &mut chal_bytes_prover)
881890
.unwrap();
@@ -894,6 +903,9 @@ mod tests {
894903

895904
// The verifier generates the challenge on its own.
896905
let mut chal_bytes_verifier = vec![];
906+
keypair_1.public_key.serialize_compressed(&mut chal_bytes_verifier).unwrap();
907+
keypair_2.public_key.serialize_compressed(&mut chal_bytes_verifier).unwrap();
908+
keypair_3.public_key.serialize_compressed(&mut chal_bytes_verifier).unwrap();
897909
proof_1
898910
.challenge_contribution(&revealed_msgs_1, &params_1, &mut chal_bytes_verifier)
899911
.unwrap();
@@ -984,6 +996,9 @@ mod tests {
984996
let mut chal_bytes_prover = vec![];
985997
let mut poks = vec![];
986998
let mut proofs = vec![];
999+
1000+
keypair.public_key.serialize_compressed(&mut chal_bytes_prover).unwrap();
1001+
9871002
for i in 0..sig_count {
9881003
msgs.push(
9891004
(0..message_count)
@@ -1014,6 +1029,7 @@ mod tests {
10141029
}
10151030

10161031
let mut chal_bytes_verifier = vec![];
1032+
keypair.public_key.serialize_compressed(&mut chal_bytes_verifier).unwrap();
10171033

10181034
for proof in &proofs {
10191035
proof

bbs_plus/src/proof_23_cdl.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use dock_crypto_utils::{
4545
};
4646
use itertools::multiunzip;
4747
use schnorr_pok::{
48-
discrete_log::{PokTwoDiscreteLogs, PokTwoDiscreteLogsProtocol},
48+
discrete_log::{PokPedersenCommitment, PokPedersenCommitmentProtocol},
4949
error::SchnorrError,
5050
partial::PartialSchnorrResponse,
5151
SchnorrCommitment, SchnorrResponse,
@@ -79,7 +79,7 @@ pub struct PoKOfSignature23G1Protocol<E: Pairing> {
7979
#[serde_as(as = "ArkObjectBytes")]
8080
pub d: E::G1Affine,
8181
/// For proving relation `B_bar = d * r1 + A_bar * -e`
82-
pub sc_comm_1: PokTwoDiscreteLogsProtocol<E::G1Affine>,
82+
pub sc_comm_1: PokPedersenCommitmentProtocol<E::G1Affine>,
8383
/// For proving relation `g1 + \sum_{i in D}(h_i*m_i)` = `d*r3 + sum_{j notin D}(h_j*m_j)`
8484
pub sc_comm_2: SchnorrCommitment<E::G1Affine>,
8585
#[serde_as(as = "Vec<ArkObjectBytes>")]
@@ -100,7 +100,7 @@ pub struct PoKOfSignature23G1Proof<E: Pairing> {
100100
#[serde_as(as = "ArkObjectBytes")]
101101
pub d: E::G1Affine,
102102
/// Proof of relation `B_bar = d * r3 + A_bar * -e`
103-
pub sc_resp_1: PokTwoDiscreteLogs<E::G1Affine>,
103+
pub sc_resp_1: PokPedersenCommitment<E::G1Affine>,
104104
/// Proof of relation `g1 + h1*m1 + h2*m2 +.... + h_i*m_i` = `d*r3 + h1*{-m1} + h2*{-m2} + .... + h_j*{-m_j}` for all disclosed messages `m_i` and for all undisclosed messages `m_j`
105105
#[serde_as(as = "ArkObjectBytes")]
106106
pub T2: E::G1Affine,
@@ -162,7 +162,7 @@ impl<E: Pairing> PoKOfSignature23G1Protocol<E> {
162162
// of `(e, r1)`, and the second of `(r2, {m_j}_{j \notin D})`. The secret knowledge items are
163163
// referred to as witnesses, and the public items as instances.
164164

165-
let sc_comm_1 = PokTwoDiscreteLogsProtocol::init(
165+
let sc_comm_1 = PokPedersenCommitmentProtocol::init(
166166
-signature.e,
167167
E::ScalarField::rand(rng),
168168
&A_bar_affine,

bulletproofs_plus_plus/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bulletproofs_plus_plus"
3-
version = "0.7.0"
3+
version = "0.8.0"
44
edition.workspace = true
55
authors.workspace = true
66
license.workspace = true
@@ -18,7 +18,7 @@ serde.workspace = true
1818
serde_with.workspace = true
1919
zeroize.workspace = true
2020
rayon = { workspace = true, optional = true }
21-
dock_crypto_utils = { version = "0.21.0", default-features = false, path = "../utils" }
21+
dock_crypto_utils = { version = "0.22.0", default-features = false, path = "../utils" }
2222

2323
[dev-dependencies]
2424
blake2.workspace = true

coconut/Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "coconut-crypto"
3-
version = "0.12.0"
3+
version = "0.13.0"
44
edition.workspace = true
55
authors.workspace = true
66
license.workspace = true
@@ -22,9 +22,9 @@ itertools.workspace = true
2222
zeroize.workspace = true
2323
serde_with.workspace = true
2424
rayon = { workspace = true, optional = true }
25-
utils = { package = "dock_crypto_utils", version = "0.21.0", default-features = false, path = "../utils" }
26-
schnorr_pok = { version = "0.21.0", default-features = false, path = "../schnorr_pok" }
27-
secret_sharing_and_dkg = { version = "0.14.0", default-features = false, path = "../secret_sharing_and_dkg" }
25+
utils = { package = "dock_crypto_utils", version = "0.22.0", default-features = false, path = "../utils" }
26+
schnorr_pok = { version = "0.22.0", default-features = false, path = "../schnorr_pok" }
27+
secret_sharing_and_dkg = { version = "0.15.0", default-features = false, path = "../secret_sharing_and_dkg" }
2828

2929
[dev-dependencies]
3030
blake2.workspace = true

coconut/src/proof/messages_pok/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ use ark_ec::pairing::Pairing;
66

77
use ark_serialize::*;
88
use ark_std::{cfg_iter, rand::RngCore};
9+
use schnorr_pok::{error::SchnorrError, SchnorrChallengeContributor};
910
use serde::{Deserialize, Serialize};
11+
use utils::join;
1012

1113
#[cfg(feature = "parallel")]
1214
use rayon::prelude::*;
13-
use schnorr_pok::{error::SchnorrError, SchnorrChallengeContributor};
14-
use utils::join;
1515

1616
use super::UnpackedBlindedMessages;
1717
use crate::{
@@ -205,7 +205,7 @@ mod tests {
205205
One,
206206
};
207207
use blake2::Blake2b512;
208-
use schnorr_pok::compute_random_oracle_challenge;
208+
use schnorr_pok::pok_generalized_pedersen::compute_random_oracle_challenge;
209209

210210
use crate::{
211211
helpers::{rand, IndexIsOutOfBounds},

coconut/src/proof/signature_pok/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,10 @@ mod tests {
154154
#[cfg(feature = "parallel")]
155155
use rayon::prelude::*;
156156

157-
use schnorr_pok::{compute_random_oracle_challenge, error::SchnorrError};
158-
159157
use crate::{proof::MessageUnpackingError, setup::test_setup, CommitMessage, Signature};
158+
use schnorr_pok::{
159+
error::SchnorrError, pok_generalized_pedersen::compute_random_oracle_challenge,
160+
};
160161

161162
use super::SignaturePoKGenerator;
162163

coconut/src/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use blake2::Blake2b512;
1414

1515
type G1 = <Bls12_381 as Pairing>::G1;
1616

17-
use schnorr_pok::compute_random_oracle_challenge;
17+
use schnorr_pok::pok_generalized_pedersen::compute_random_oracle_challenge;
1818

1919
use crate::{
2020
setup::test_setup, BlindSignature, CommitMessage, CommitmentOrMessage, MessagesPoKGenerator,

compressed_sigma/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "compressed_sigma"
3-
version = "0.0.11"
3+
version = "0.0.12"
44
edition.workspace = true
55
authors.workspace = true
66
license.workspace = true
@@ -15,7 +15,7 @@ ark-std.workspace = true
1515
ark-poly.workspace = true
1616
rayon = {workspace = true, optional = true}
1717
digest.workspace = true
18-
dock_crypto_utils = { version = "0.21.0", default-features = false, path = "../utils" }
18+
dock_crypto_utils = { version = "0.22.0", default-features = false, path = "../utils" }
1919

2020
[dev-dependencies]
2121
blake2.workspace = true

delegatable_credentials/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "delegatable_credentials"
3-
version = "0.10.0"
3+
version = "0.11.0"
44
edition.workspace = true
55
authors.workspace = true
66
license.workspace = true
@@ -20,8 +20,8 @@ serde.workspace = true
2020
serde_with.workspace = true
2121
zeroize.workspace = true
2222
num-bigint = { version = "0.4.0", default-features = false }
23-
schnorr_pok = { version = "0.21.0", default-features = false, path = "../schnorr_pok" }
24-
dock_crypto_utils = { version = "0.21.0", default-features = false, path = "../utils" }
23+
schnorr_pok = { version = "0.22.0", default-features = false, path = "../schnorr_pok" }
24+
dock_crypto_utils = { version = "0.22.0", default-features = false, path = "../utils" }
2525

2626
[dependencies.num-integer]
2727
version = "0.1.42"

equality_across_groups/Cargo.toml

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ edition.workspace = true
55
authors.workspace = true
66
license.workspace = true
77
repository.workspace = true
8-
description = "Protocols for proving equality of committed values across groups"
8+
description = "Protocols for proving equality of committed values across groups and correctness of elliptic curve point addition and scalar multiplication"
99

1010
[dependencies]
1111
ark-serialize.workspace = true
1212
ark-ff.workspace = true
1313
ark-ec.workspace = true
1414
ark-std.workspace = true
15+
ark-secp256r1.workspace = true
16+
zeroize.workspace = true
1517
rayon = {workspace = true, optional = true}
1618
crypto-bigint = { version = "0.6.0-rc.6", default-features = false, features = ["zeroize", "alloc", "rand_core"] }
17-
ark-secp256r1.workspace = true
18-
bulletproofs_plus_plus = { version = "0.7.0", default-features = false, path = "../bulletproofs_plus_plus" }
19-
dock_crypto_utils = { version = "0.21.0", default-features = false, path = "../utils" }
20-
schnorr_pok = { default-features = false, path = "../schnorr_pok" }
21-
kvac = { version = "0.6.0", default-features = false, path = "../kvac" }
19+
bulletproofs_plus_plus = { version = "0.8.0", default-features = false, path = "../bulletproofs_plus_plus" }
20+
dock_crypto_utils = { version = "0.22.0", default-features = false, path = "../utils" }
21+
schnorr_pok = { version = "0.22.0", default-features = false, path = "../schnorr_pok" }
22+
kvac = { version = "0.7.0", default-features = false, path = "../kvac" }
2223

2324
[dev-dependencies]
24-
rand = "0.8"
2525
blake2.workspace = true
2626
ark-bls12-381.workspace = true
2727
rand_core = { version = "0.6", default-features = false }

equality_across_groups/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Protocols for proving equality of committed values across groups.
44

55
- Implements the sigma protocol for proving that two values committed in different groups are equal. As described in Figure 1 and its
66
extension in section 5 of the paper [Proofs of discrete logarithm equality across groups](https://eprint.iacr.org/2022/1593). Check the [module](./src/eq_across_groups.rs) for more docs
7-
- Implements the protocol to prove elliptic curve point addition and scalar multiplication from the paper [ZKAttest Ring and Group Signatures for Existing ECDSA Keys](https://eprint.iacr.org/2021/1183). Check the [point addition module](./src/ec/sw_point_addition.rs) and [scalar multiplication module](./src/ec/sw_scalar_mult.rs) for more docs
8-
- Use the above protocols to prove knowledge of a committed ECDSA public key on Tom-256 curve. Check the [module](./src/pok_ecdsa_pubkey.rs) for more docs
7+
- Implements the protocol to prove elliptic curve point addition and scalar multiplication from the paper [CDLS: Proving Knowledge of Committed Discrete Logarithms with Soundness](https://eprint.iacr.org/2023/1595). Check the [point addition module](./src/ec/sw_point_addition.rs) and [scalar multiplication module](./src/ec/sw_scalar_mult.rs) for more docs
8+
- Use the above protocols to prove knowledge of a committed ECDSA public key on Tom-256 curve as described in the paper [ZKAttest Ring and Group Signatures for Existing ECDSA Keys](https://eprint.iacr.org/2021/1183). Check the [module](./src/pok_ecdsa_pubkey.rs) for more docs
99
- Use the above protocols to prove knowledge of a committed ECDSA public key on BLS12-381 curve. Check the test `pok_ecdsa_pubkey_committed_in_bls12_381_commitment` in [module](./src/pok_ecdsa_pubkey.rs).
1010

1111
**CREDIT**

0 commit comments

Comments
 (0)