Skip to content

Commit a285dd1

Browse files
committed
Threshold weak-BB signature and threshold issuance in SyRA
Signed-off-by: lovesh <lovesh.bond@gmail.com>
1 parent 1659b73 commit a285dd1

File tree

28 files changed

+1304
-80
lines changed

28 files changed

+1304
-80
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Library providing privacy enhancing cryptographic primitives.
3030
11. [Short group signatures](./short_group_sig/). BB signature and weak-BB signature and their proofs of knowledge based on the papers [Short Signatures Without Random Oracles](https://eprint.iacr.org/2004/171) and [Scalable Revocation Scheme for Anonymous Credentials Based on n-times Unlinkable Proofs](http://library.usc.edu.ph/ACM/SIGSAC%202017/wpes/p123.pdf).
3131
12. [Keyed-Verification Anonymous Credentials (KVAC)](./kvac). Implements Keyed-Verification Anonymous Credentials (KVAC) schemes.
3232
13. [SyRA](./syra). Implements sybil resilient signatures to be used for generating pseudonyms for low-entropy credential attributes.
33-
14. [Verifiable encryption](./verifiable_encryption) using [this paper Verifiable Encryption from MPC-in-the-Head](https://eprint.iacr.org/2021/1704.pdf).
33+
14. [Verifiable encryption](./verifiable_encryption) using the paper [Verifiable Encryption from MPC-in-the-Head](https://eprint.iacr.org/2021/1704.pdf).
3434

3535
## Composite proof system
3636

bbs_plus/src/threshold/utils.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,7 @@ pub fn compute_R_and_u<G: AffineRepr>(
4646
phase2: &Phase2Output<G::ScalarField>,
4747
) -> (G, G::ScalarField) {
4848
let R = base.mul(r).into_affine();
49-
let mut u = *masked_r * (*e + masked_signing_key_share);
50-
for (_, (a, b)) in &phase2.0.z_A {
51-
u += a[index_in_output as usize];
52-
u += b[index_in_output as usize];
53-
}
54-
for (_, (a, b)) in &phase2.0.z_B {
55-
u += a[index_in_output as usize];
56-
u += b[index_in_output as usize];
57-
}
49+
let u =
50+
*masked_r * (*e + masked_signing_key_share) + phase2.0.compute_u(index_in_output as usize);
5851
(R, u)
5952
}

oblivious_transfer/src/cointoss.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub struct Commitments(pub Vec<Vec<u8>>);
2525
pub struct Party<F: PrimeField, const SALT_SIZE: usize> {
2626
pub id: ParticipantId,
2727
pub protocol_id: Vec<u8>,
28+
/// Stores shares and salts created by itself to be sent to other parties
2829
pub own_shares_and_salts: Vec<(F, [u8; SALT_SIZE])>,
2930
// Following isn't allowed in stable Rust
3031
// pub own_shares_and_salts: Vec<(F, [u8; 2*SECURITY_PARAM])>,

oblivious_transfer/src/ot_based_multiplication/batch_mul_multi_party.rs

+17
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ pub struct ParticipantOutput<F: PrimeField> {
6666
impl<F: PrimeField, const KAPPA: u16, const STATISTICAL_SECURITY_PARAMETER: u16>
6767
Participant<F, KAPPA, STATISTICAL_SECURITY_PARAMETER>
6868
{
69+
/// The returned map contains the messages that need to be sent to the parties with corresponding
70+
/// key in the map
6971
pub fn init<R: RngCore>(
7072
rng: &mut R,
7173
id: ParticipantId,
@@ -214,6 +216,21 @@ impl<F: PrimeField, const KAPPA: u16, const STATISTICAL_SECURITY_PARAMETER: u16>
214216
}
215217
}
216218

219+
impl<F: PrimeField> ParticipantOutput<F> {
220+
pub fn compute_u(&self, idx: usize) -> F {
221+
let mut u = F::zero();
222+
for (_, (a, b)) in &self.z_A {
223+
u += a[idx];
224+
u += b[idx];
225+
}
226+
for (_, (a, b)) in &self.z_B {
227+
u += a[idx];
228+
u += b[idx];
229+
}
230+
u
231+
}
232+
}
233+
217234
#[cfg(test)]
218235
pub mod tests {
219236
use super::*;

oblivious_transfer/src/zero_sharing.rs

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ impl<F: PrimeField, const SALT_SIZE: usize> Party<F, SALT_SIZE> {
3333
/// of 0s whose shares are generated, eg, if `batch_size` is 3, then `a_1, a_2, ..., a_n`,
3434
/// `b_1, b_2, ..., b_n` and `c_1, c_2, ..., c_n` are generated such that `\sum_{i}(a_{i}) = 0`,
3535
/// `\sum_{i}(b_{i}) = 0` and `\sum_{i}(c_{i}) = 0`.
36+
/// The returned map contains the commitments to be sent to the party with id as the corresponding
37+
/// key of the map.
3638
pub fn init<R: RngCore>(
3739
rng: &mut R,
3840
id: ParticipantId,

proof_system/README.md

+21-14
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ and used by the prover and verifier during proof creation and verification respe
2626

2727
A common requirement is to prove equality of certain [`Witness`]s of certain [`Statement`]s. This
2828
is done by using the [`EqualWitnesses`] meta-statement. For each set of [`Witness`]s (from the same or different [`Statement`]s)
29-
that need to proven equal, a [`EqualWitnesses`] is created which is a set of witness references [`WitnessRef`].
29+
that need to proved equal, a [`EqualWitnesses`] is created which is a set of witness references [`WitnessRef`].
3030
Each [`WitnessRef`] contains the [`Statement`] index and the [`Witness`] index in that [`Statement`] and
3131
thus uniquely identifies any [`Witness`] across [`Statement`]s. The [`EqualWitnesses`] meta-statement is also
3232
used to prove predicates over signed messages in zero knowledge, when doing a range-proof over a
3333
signed message (using BBS+), the [`EqualWitnesses`] will refer [`Witness`]s from `Statement::PoKBBSSignatureG1`
34-
statement and `Statement::BoundCheckLegoGroth16` statement. Following are some illustrations of [`EqualWitnesses`]
34+
statement and `Statement::BoundCheckLegoGroth16` statement. Following are some illustrations of [`EqualWitnesses`].
35+
Technically, this is achieved through Chaum-Pedersen discrete log equality protocol.
3536

3637
```text
3738
┌────────────────────────────┐ ┌──────────────────────────────┐ ┌────────────────────────────┐
@@ -53,7 +54,7 @@ statement and `Statement::BoundCheckLegoGroth16` statement. Following are some i
5354
└─────────────────────────────┘ └────────────────────────────┘
5455
```
5556

56-
```
57+
```rust
5758
For proving certain messages from 3 BBS+ signatures are equal. Here there 2 sets of equalities,
5859
1. message A3 from 1st signature, B2 from 2nd signature and C1 from 3rd signature
5960
2. message B4 from 2nd signature and C5 from 3rd signature
@@ -80,8 +81,7 @@ statement and `Statement::BoundCheckLegoGroth16` statement. Following are some i
8081
│ A3 and B1 are equal │ │ A5 and C1 are equal │
8182
└─────────────────────────────┘ └────────────────────────────┘
8283
```
83-
84-
```
84+
```rust
8585
For proving certain messages from a BBS+ signature satisfy 2 predicates,
8686
1) message A3 satisfies bounds specified in statement 2
8787
2) message A5 has been verifiably encrypted as per statement 3.
@@ -102,12 +102,14 @@ protocols. Each of these protocols are variants of the enum [`SubProtocol`]. [`S
102102
call other [`SubProtocol`]s, eg [`SaverProtocol`] invokes several [`SchnorrProtocol`]s
103103

104104
Currently supports
105-
- proof of knowledge of a BBS or BBS+ signature and signed messages
106-
- proof of knowledge of multiple BBS or BBS+ signature and equality of certain messages
105+
- proof of knowledge of a BBS or BBS+ or PS signature and signed messages
106+
- proof of knowledge of multiple BBS or BBS+ or PS signature and equality of certain messages
107+
- proof of knowledge of multiple BBS or BBS+ or PS signature and inequality of certain messages with public values
107108
- proof of knowledge of accumulator membership and non-membership
108109
- proof of knowledge of Pedersen commitment opening.
109-
- proof of knowledge of BBS or BBS+ signature(s) and that certain message(s) satisfy given bounds (range proof)
110-
- verifiable encryption of messages in a BBS or BBS+ signature
110+
- proof of knowledge of BBS or BBS+ or PS signature(s) and that certain message(s) satisfy given bounds (range proof)
111+
- verifiable encryption of messages in a BBS or BBS+ or PS signature using zk-SNARK based protocol SAVER or
112+
MPCitH based TZ-21
111113
- proof of knowledge of BBS or BBS+ signature(s) and that certain message(s) satisfy given R1CS. The R1CS is generated
112114
from [Circom](https://github.com/iden3/circom) and the proof system used is [LegoGroth16](https://github.com/lovesh/legogro16).
113115
LegoGroth16 is similar to Groth16 but in addition to the zero knowledge proof, it provides a Pedersen
@@ -118,6 +120,8 @@ See following tests for examples:
118120

119121
- test `pok_of_3_bbs_plus_sig_and_message_equality` proves knowledge of 3 BBS+ signatures and also that certain
120122
messages are equal among them without revealing them.
123+
- test `pok_of_bbs_plus_sig_and_inequality_with_public_value` proves knowledge of a BBS+ signature and also that
124+
certain message is not equal to a public value without revealing the message
121125
- test `pok_of_bbs_plus_sig_and_accumulator` proves knowledge of a BBS+ signature and also that certain messages
122126
are present and absent in the 2 accumulators respectively.
123127
- test `pok_of_knowledge_in_pedersen_commitment_and_bbs_plus_sig` proves knowledge of a BBS+ signature and opening
@@ -126,26 +130,29 @@ See following tests for examples:
126130
a Pedersen commitment.
127131
- test `verifier_local_linkability` shows how a verifier can link separate proofs from a prover (with prover's
128132
permission) and assign a unique identifier to the prover without learning any message from the BBS+ signature.
129-
Also this identifier cannot be linked across different verifiers (intentional by the prover).
133+
Also, this identifier cannot be linked across different verifiers (intentional by the prover).
130134
- test `pok_of_bbs_plus_sig_and_bounded_message` shows proving knowledge of a BBS+ signature and that a specific
131135
message satisfies some upper and lower bounds i.e. min <= signed message <= max. This is a range proof.
132-
- test `pok_of_bbs_plus_sig_and_verifiable_encryption` shows how to verifiably encrypt a message signed with BBS+ such
133-
that the verifier cannot decrypt it but still ensure that it is encrypted correctly for the specified decryptor.
136+
- test `pok_of_bbs_plus_sig_and_verifiable_encryption_using_saver` shows how to verifiably encrypt a message signed with BBS+ and
137+
using SAVER protocol such that the verifier cannot decrypt it but still ensure that it is encrypted correctly for the specified decryptor.
138+
- test `pok_of_bbs_plus_sig_and_verifiable_encryption_using_tz21` shows how to verifiably encrypt a message signed with BBS+ and
139+
using TZ21 protocol such that the verifier cannot decrypt it but still ensure that it is encrypted correctly for the specified decryptor.
134140
- test `pok_of_bbs_plus_sig_with_reusing_setup_params` shows proving knowledge of several BBS+ signatures
135141
using [`SetupParams`]s. Here the same signers are used in multiple signatures thus their public params
136142
can be put as a variant of enum [`SetupParams`]. Similarly test
137143
`pok_of_knowledge_in_pedersen_commitment_and_equality_with_commitment_key_reuse` shows use of [`SetupParams`]
138-
when the same commitment key is reused in several commitments and test `pok_of_bbs_plus_sig_and_verifiable_encryption_of_many_messages`
144+
when the same commitment key is reused in several commitments and test `pok_of_bbs_plus_sig_and_verifiable_encryption_of_many_messages_using_saver`
139145
shows use of [`SetupParams`] when several messages are used in verifiable encryption for the same decryptor.
140146
- For R1CS/Circom, see various tests like using less than, not-equals comparison operators on messages signed with BBS+, proving
141147
that the preimage of an MiMC hash is the message signed with BBS+, sum of certain signed messages (from same or different signatures)
142148
is bounded by a given value, etc [here](tests/r1cs). The Circom compiler output and circuits are [here](tests/r1cs/circom).
143149
The circuits were compiled and tested for BLS12-381 curve.
144150

145-
*Note*: This design is largely inspired from my work at Hyperledger Ursa.
151+
*Note*: This design is inspired from my work at Hyperledger Ursa.
146152

147153
*Note*: The design is tentative and will likely change as more protocols are integrated.
148154

155+
149156
[`Statement`]: https://docs.rs/proof_system/latest/proof_system/statement/enum.Statement.html
150157
[`MetaStatement`]: https://docs.rs/proof_system/latest/proof_system/meta_statement/enum.MetaStatement.html
151158
[`EqualWitnesses`]: https://docs.rs/proof_system/latest/proof_system/meta_statement/struct.EqualWitnesses.html

proof_system/src/lib.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@
2424
//!
2525
//! A common requirement is to prove equality of certain [`Witness`]s of certain [`Statement`]s. This
2626
//! is done by using the [`EqualWitnesses`] meta-statement. For each set of [`Witness`]s (from the same or different [`Statement`]s)
27-
//! that need to proven equal, a [`EqualWitnesses`] is created which is a set of witness references [`WitnessRef`].
27+
//! that need to proved equal, a [`EqualWitnesses`] is created which is a set of witness references [`WitnessRef`].
2828
//! Each [`WitnessRef`] contains the [`Statement`] index and the [`Witness`] index in that [`Statement`] and
2929
//! thus uniquely identifies any [`Witness`] across [`Statement`]s. The [`EqualWitnesses`] meta-statement is also
3030
//! used to prove predicates over signed messages in zero knowledge, when doing a range-proof over a
3131
//! signed message (using BBS+), the [`EqualWitnesses`] will refer [`Witness`]s from `Statement::PoKBBSSignatureG1`
32-
//! statement and `Statement::BoundCheckLegoGroth16` statement. Following are some illustrations of [`EqualWitnesses`]
32+
//! statement and `Statement::BoundCheckLegoGroth16` statement. Following are some illustrations of [`EqualWitnesses`].
33+
//! Technically, this is achieved through Chaum-Pedersen discrete log equality protocol.
3334
//!
3435
//! ```text
3536
//! ┌────────────────────────────┐ ┌──────────────────────────────┐ ┌────────────────────────────┐
@@ -101,7 +102,8 @@
101102
//! - proof of knowledge of accumulator membership and non-membership
102103
//! - proof of knowledge of Pedersen commitment opening.
103104
//! - proof of knowledge of BBS or BBS+ or PS signature(s) and that certain message(s) satisfy given bounds (range proof)
104-
//! - verifiable encryption of messages in a BBS or BBS+ or PS signature
105+
//! - verifiable encryption of messages in a BBS or BBS+ or PS signature using zk-SNARK based protocol SAVER or
106+
//! MPCitH based TZ-21
105107
//! - proof of knowledge of BBS or BBS+ signature(s) and that certain message(s) satisfy given R1CS. The R1CS is generated
106108
//! from [Circom](https://github.com/iden3/circom) and the proof system used is [LegoGroth16](https://github.com/lovesh/legogro16).
107109
//! LegoGroth16 is similar to Groth16 but in addition to the zero knowledge proof, it provides a Pedersen
@@ -122,16 +124,18 @@
122124
//! a Pedersen commitment.
123125
//! - test `verifier_local_linkability` shows how a verifier can link separate proofs from a prover (with prover's
124126
//! permission) and assign a unique identifier to the prover without learning any message from the BBS+ signature.
125-
//! Also this identifier cannot be linked across different verifiers (intentional by the prover).
127+
//! Also, this identifier cannot be linked across different verifiers (intentional by the prover).
126128
//! - test `pok_of_bbs_plus_sig_and_bounded_message` shows proving knowledge of a BBS+ signature and that a specific
127129
//! message satisfies some upper and lower bounds i.e. min <= signed message <= max. This is a range proof.
128-
//! - test `pok_of_bbs_plus_sig_and_verifiable_encryption` shows how to verifiably encrypt a message signed with BBS+ such
129-
//! that the verifier cannot decrypt it but still ensure that it is encrypted correctly for the specified decryptor.
130+
//! - test `pok_of_bbs_plus_sig_and_verifiable_encryption_using_saver` shows how to verifiably encrypt a message signed with BBS+ and
131+
//! using SAVER protocol such that the verifier cannot decrypt it but still ensure that it is encrypted correctly for the specified decryptor.
132+
//! - test `pok_of_bbs_plus_sig_and_verifiable_encryption_using_tz21` shows how to verifiably encrypt a message signed with BBS+ and
133+
//! using TZ21 protocol such that the verifier cannot decrypt it but still ensure that it is encrypted correctly for the specified decryptor.
130134
//! - test `pok_of_bbs_plus_sig_with_reusing_setup_params` shows proving knowledge of several BBS+ signatures
131135
//! using [`SetupParams`]s. Here the same signers are used in multiple signatures thus their public params
132136
//! can be put as a variant of enum [`SetupParams`]. Similarly test
133137
//! `pok_of_knowledge_in_pedersen_commitment_and_equality_with_commitment_key_reuse` shows use of [`SetupParams`]
134-
//! when the same commitment key is reused in several commitments and test `pok_of_bbs_plus_sig_and_verifiable_encryption_of_many_messages`
138+
//! when the same commitment key is reused in several commitments and test `pok_of_bbs_plus_sig_and_verifiable_encryption_of_many_messages_using_saver`
135139
//! shows use of [`SetupParams`] when several messages are used in verifiable encryption for the same decryptor.
136140
//! - For R1CS/Circom, see various tests like using less than, not-equals comparison operators on messages signed with BBS+, proving
137141
//! that the preimage of an MiMC hash is the message signed with BBS+, sum of certain signed messages (from same or different signatures)
File renamed without changes.

schnorr_pok/src/partial.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use dock_crypto_utils::{expect_equality, serde_utils::ArkObjectBytes};
1717
use serde::{Deserialize, Serialize};
1818
use serde_with::{serde_as, Same};
1919

20-
/// Response during step 3 of the Schnorr protocol to prove knowledge of 1 or more discrete logs
20+
/// Response during step 3 of the Schnorr protocol to prove knowledge of 1 or more discrete logs.
2121
/// This is called partial because it does not contain the responses for all the witnesses. This is
2222
/// used when more than one Schnorr protocol is used and some witnesses are to be proved equal among them.
2323
/// Also useful in case of a single Schnorr protocol if some witnesses are to be proved equal.

short_group_sig/Cargo.toml

+5-2
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@ serde_with.workspace = true
2121
zeroize.workspace = true
2222
dock_crypto_utils = { version = "0.20.0", default-features = false, path = "../utils" }
2323
schnorr_pok = { version = "0.20.0", default-features = false, path = "../schnorr_pok" }
24+
oblivious_transfer_protocols = { version = "0.9.0", default-features = false, path = "../oblivious_transfer" }
25+
secret_sharing_and_dkg = { version = "0.13.0", default-features = false, path = "../secret_sharing_and_dkg" }
2426

2527
[dev-dependencies]
2628
blake2.workspace = true
2729
ark-bls12-381.workspace = true
2830
serde_json = "1.0"
2931
rmp-serde = "1.0"
32+
test_utils = { path = "../test_utils" }
3033

3134
[features]
3235
default = [ "parallel" ]
33-
std = [ "ark-ff/std", "ark-ec/std", "ark-poly/std", "ark-std/std", "ark-serialize/std", "dock_crypto_utils/std", "schnorr_pok/std", "serde/std"]
36+
std = [ "ark-ff/std", "ark-ec/std", "ark-poly/std", "ark-std/std", "ark-serialize/std", "dock_crypto_utils/std", "schnorr_pok/std", "serde/std", "oblivious_transfer_protocols/std", "secret_sharing_and_dkg/std"]
3437
print-trace = [ "ark-std/print-trace", "dock_crypto_utils/print-trace" ]
35-
parallel = [ "std", "ark-ff/parallel", "ark-ec/parallel", "ark-poly/parallel", "ark-std/parallel", "rayon", "dock_crypto_utils/parallel", "schnorr_pok/parallel" ]
38+
parallel = [ "std", "ark-ff/parallel", "ark-ec/parallel", "ark-poly/parallel", "ark-std/parallel", "rayon", "dock_crypto_utils/parallel", "schnorr_pok/parallel", "oblivious_transfer_protocols/parallel", "secret_sharing_and_dkg/parallel" ]

short_group_sig/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
3. An optimized implementation of proof of knowledge of weak-BB signature taken from the paper [Scalable Revocation Scheme for Anonymous Credentials Based on n-times Unlinkable Proofs](http://library.usc.edu.ph/ACM/SIGSAC%202017/wpes/p123.pdf). This does not require the prover to do pairings
88
4. Similar to weak-BB, proof of knowledge of BB signature that does not require the prover to do pairings.
99
5. A keyed-verification protocol for proving knowledge of weak-BB signature. Here the verifier is assumed to have the secret key and the protocol does not require pairings.
10+
6. Threshold issuance protocol for weak-BB signatures
1011

1112
<!-- cargo-rdme end -->

0 commit comments

Comments
 (0)