Skip to content

Commit f521837

Browse files
committed
BBS signatures
Signed-off-by: lovesh <lovesh.bond@gmail.com>
1 parent e8c344a commit f521837

File tree

17 files changed

+1906
-78
lines changed

17 files changed

+1906
-78
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Library providing privacy enhancing cryptographic primitives.
99
## Primitives
1010

1111
1. [Schnorr proof of knowledge protocol](./schnorr_pok) to prove knowledge of discrete log. [This](https://crypto.stanford.edu/cs355/19sp/lec5.pdf) is a good reference.
12-
2. [BBS+ signature](./bbs_plus) for anonymous credentials. Based on the paper [Anonymous Attestation Using the Strong Diffie Hellman Assumption Revisited](https://eprint.iacr.org/2016/663)
12+
2. [BBS and BBS+ signatures](./bbs_plus) for anonymous credentials. BBS+ is based on the paper [Anonymous Attestation Using the Strong Diffie Hellman Assumption Revisited](https://eprint.iacr.org/2016/663) and BBS is based on the paper [Revisiting BBS Signatures](https://eprint.iacr.org/2023/275).
1313
3. [Dynamic accumulators, both positive and universal](./vb_accumulator). Based on the paper [Dynamic Universal Accumulator with Batch Update over Bilinear Groups](https://eprint.iacr.org/2020/777)
1414
4. [Composite proof system](./proof_system) that combines above primitives for use cases like
1515
- prove knowledge of a BBS+ signature and the corresponding messages
@@ -53,7 +53,7 @@ For running tests faster, run `cargo test --release`
5353

5454
[Criterion](https://github.com/bheisler/criterion.rs) benchmarks [here](./benches)
5555

56-
Some tests also print time consumed by the operations, run `cargo test --release -- --nocapure [test name]`
56+
Some tests also print time consumed by the operations, run `cargo test --release -- --nocapture [test name]`
5757

5858
## WASM wrapper
5959

bbs_plus/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition.workspace = true
55
authors.workspace = true
66
license.workspace = true
77
repository.workspace = true
8-
description = "BBS+ signature and protocol for proof of knowledge of signature"
8+
description = "BBS and BBS+ signatures and protocols for proof of knowledge of signature"
99

1010
[lib]
1111
doctest = false

bbs_plus/README.md

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
1-
# bbs_plus
1+
# BBS and BBS+ signatures
2+
3+
<!-- cargo-rdme start -->
4+
5+
Implements BBS and BBS+.
26

37
BBS+ signature according to the paper: [Anonymous Attestation Using the Strong Diffie Hellman Assumption Revisited](https://eprint.iacr.org/2016/663).
48
Provides
5-
- signature creation and verification in both groups G1 and G2.
9+
- signature creation and verification with signature in group G1 and public key in group G2 and vice-versa.
610
- proof of knowledge of signature and corresponding messages in group G1 as that is more efficient.
711

12+
BBS signature according to the paper: [Revisiting BBS Signatures](https://eprint.iacr.org/2023/275).
13+
Provides
14+
- signature creation and verification with signature in group G1 and public key in group G2.
15+
- proof of knowledge of signature and corresponding messages.
16+
817
### Modules
918

10-
1. Signature parameters and key generation module - [`setup`]
11-
2. Signature module - [`signature`]
12-
3. Proof of knowledge of signature module - [`proof`]
19+
1. BBS and BBS+ signature parameters and key generation module - [`setup`]
20+
2. BBS+ signature module - [`signature`]
21+
3. BBS+ proof of knowledge of signature module - [`proof`]
22+
4. BBS signature module - [`signature_23`]
23+
5. BBS proof of knowledge of signature module - [`proof_23`]
1324

1425
The implementation tries to use the same variable names as the paper and thus violate Rust's naming conventions at places.
1526

16-
[`setup`]: crate::setup
17-
[`signature`]: crate::signature
18-
[`proof`]: crate::proof
27+
[`setup`]: https://docs.rs/bbs_plus/latest/bbs_plus/setup/
28+
[`signature`]: https://docs.rs/bbs_plus/latest/bbs_plus/signature/
29+
[`proof`]: https://docs.rs/bbs_plus/latest/bbs_plus/proof/
30+
[`signature_23`]: https://docs.rs/bbs_plus/latest/bbs_plus/signature_23/
31+
[`proof_23`]: https://docs.rs/bbs_plus/latest/bbs_plus/proof_23/
32+
33+
<!-- cargo-rdme end -->
1934

2035
License: Apache-2.0

bbs_plus/src/lib.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,50 @@
11
#![cfg_attr(not(feature = "std"), no_std)]
22
#![allow(non_snake_case)]
33

4+
//! Implements BBS and BBS+.
5+
//!
46
//! BBS+ signature according to the paper: [Anonymous Attestation Using the Strong Diffie Hellman Assumption Revisited](https://eprint.iacr.org/2016/663).
57
//! Provides
6-
//! - signature creation and verification in both groups G1 and G2.
8+
//! - signature creation and verification with signature in group G1 and public key in group G2 and vice-versa.
79
//! - proof of knowledge of signature and corresponding messages in group G1 as that is more efficient.
810
//!
11+
//! BBS signature according to the paper: [Revisiting BBS Signatures](https://eprint.iacr.org/2023/275).
12+
//! Provides
13+
//! - signature creation and verification with signature in group G1 and public key in group G2.
14+
//! - proof of knowledge of signature and corresponding messages.
15+
//!
916
//! ## Modules
1017
//!
11-
//! 1. Signature parameters and key generation module - [`setup`]
12-
//! 2. Signature module - [`signature`]
13-
//! 3. Proof of knowledge of signature module - [`proof`]
18+
//! 1. BBS and BBS+ signature parameters and key generation module - [`setup`]. The signature params for BBS are slightly
19+
//! different from BBS+ but public key is same.
20+
//! 2. BBS+ signature module - [`signature`]
21+
//! 3. BBS+ proof of knowledge of signature module - [`proof`]
22+
//! 4. BBS signature module - [`signature_23`]
23+
//! 5. BBS proof of knowledge of signature module - [`proof_23`]
1424
//!
1525
//! The implementation tries to use the same variable names as the paper and thus violate Rust's naming conventions at places.
1626
//!
1727
//! [`setup`]: crate::setup
1828
//! [`signature`]: crate::signature
1929
//! [`proof`]: crate::proof
30+
//! [`signature_23`]: crate::signature_23
31+
//! [`proof_23`]: crate::proof_23
2032
2133
pub mod error;
2234
pub mod proof;
35+
pub mod proof_23;
2336
pub mod setup;
2437
pub mod signature;
38+
pub mod signature_23;
2539

2640
pub mod prelude {
2741
pub use crate::{
2842
error::BBSPlusError,
29-
proof::{PoKOfSignatureG1Proof, PoKOfSignatureG1Protocol},
43+
proof::{MessageOrBlinding, PoKOfSignatureG1Proof, PoKOfSignatureG1Protocol},
44+
proof_23::{PoKOfSignature23G1Proof, PoKOfSignature23G1Protocol},
3045
setup::*,
3146
signature::{SignatureG1, SignatureG2},
47+
signature_23::Signature23G1,
3248
};
3349
}
3450

bbs_plus/src/proof.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Proof of knowledge of the signature and corresponding messages as per section 4.5 of the paper
1+
//! Proof of knowledge of BBS+ signature and corresponding messages as per section 4.5 of the BBS+ paper
22
//! # Examples
33
//!
44
//! Creating proof of knowledge of signature and verifying it:
@@ -58,7 +58,7 @@
5858
use crate::{
5959
error::BBSPlusError,
6060
prelude::PreparedPublicKeyG2,
61-
setup::{PreparedSignatureParamsG1, SignatureParamsG1},
61+
setup::{MultiMessageSignatureParams, PreparedSignatureParamsG1, SignatureParamsG1},
6262
signature::SignatureG1,
6363
};
6464
use ark_ec::{pairing::Pairing, AffineRepr, CurveGroup, Group, VariableBaseMSM};
@@ -83,7 +83,7 @@ use serde::{Deserialize, Serialize};
8383
use serde_with::serde_as;
8484
use zeroize::{Zeroize, ZeroizeOnDrop};
8585

86-
/// Proof of knowledge of BBS+ signature in group G1
86+
/// Protocol to prove knowledge of BBS+ signature in group G1.
8787
/// The BBS+ signature proves validity of a set of messages {m_i}, i in I. This stateful protocol proves knowledge of such
8888
/// a signature whilst selectively disclosing only a subset of the messages, {m_i} for i in a disclosed set D. The
8989
/// protocol randomizes the initial BBS+ signature, then conducts 2 Schnorr PoK protocols to prove exponent knowledge
@@ -124,7 +124,7 @@ pub struct PoKOfSignatureG1Protocol<E: Pairing> {
124124
sc_wits_2: Vec<E::ScalarField>,
125125
}
126126

127-
/// Proof of knowledge of the signature in G1. It contains the randomized signature, commitment (Schnorr step 1)
127+
/// Proof of knowledge of BBS+ signature in G1. It contains the randomized signature, commitment (Schnorr step 1)
128128
/// and response (Schnorr step 3) to both Schnorr protocols in `T_` and `sc_resp_`
129129
#[serde_as]
130130
#[derive(
@@ -245,6 +245,7 @@ impl<E: Pairing> PoKOfSignatureG1Protocol<E> {
245245
// Knowledge of all unrevealed messages `m_j` need to be proven in addition to knowledge of `-r3` and `s'`. Thus
246246
// all `m_j`, `-r3` and `s'` are the witnesses, while all `h_j`, `d`, `h_0` and `-g1 + \sum_{i \in D}(h_i*{-m_i})` is the instance.
247247

248+
// Iterator of tuples of form `(h_i, blinding_i, message_i)`
248249
let h_blinding_message = indexed_blindings
249250
.into_iter()
250251
.map(|(idx, blinding)| (params.h[idx], blinding, messages[idx]));

0 commit comments

Comments
 (0)