@@ -8,13 +8,29 @@ use crate::{error::ProofSystemError, setup_params::SetupParams, statement::State
8
8
use bbs_plus:: prelude:: { PublicKeyG2 , SignatureParamsG1 } ;
9
9
use dock_crypto_utils:: serde_utils:: * ;
10
10
11
+ /// Public values like setup params and revealed messages for proving knowledge of BBS+ signature.
12
+ #[ serde_as]
13
+ #[ derive(
14
+ Clone , Debug , PartialEq , Eq , CanonicalSerialize , CanonicalDeserialize , Serialize , Deserialize ,
15
+ ) ]
16
+ #[ serde( bound = "" ) ]
17
+ pub struct PoKBBSSignatureG1Prover < E : Pairing > {
18
+ /// Messages being revealed.
19
+ #[ serde_as( as = "BTreeMap<Same, ArkObjectBytes>" ) ]
20
+ pub revealed_messages : BTreeMap < usize , E :: ScalarField > ,
21
+ /// If the statement was created by passing the signature params directly, then it will not be None
22
+ pub signature_params : Option < SignatureParamsG1 < E > > ,
23
+ /// If the statement was created by passing the index of signature params in `SetupParams`, then it will not be None
24
+ pub signature_params_ref : Option < usize > ,
25
+ }
26
+
11
27
/// Public values like setup params, public key and revealed messages for proving knowledge of BBS+ signature.
12
28
#[ serde_as]
13
29
#[ derive(
14
30
Clone , Debug , PartialEq , Eq , CanonicalSerialize , CanonicalDeserialize , Serialize , Deserialize ,
15
31
) ]
16
32
#[ serde( bound = "" ) ]
17
- pub struct PoKBBSSignatureG1 < E : Pairing > {
33
+ pub struct PoKBBSSignatureG1Verifier < E : Pairing > {
18
34
/// Messages being revealed.
19
35
#[ serde_as( as = "BTreeMap<Same, ArkObjectBytes>" ) ]
20
36
pub revealed_messages : BTreeMap < usize , E :: ScalarField > ,
@@ -29,7 +45,52 @@ pub struct PoKBBSSignatureG1<E: Pairing> {
29
45
}
30
46
31
47
#[ macro_export]
32
- macro_rules! impl_bbs_statement {
48
+ macro_rules! impl_bbs_prover_statement {
49
+ ( $params: ident, $stmt: ident, $setup_param_name: ident) => {
50
+ /// Create a statement by passing the signature parameters directly.
51
+ pub fn new_statement_from_params(
52
+ signature_params: $params<E >,
53
+ revealed_messages: BTreeMap <usize , E :: ScalarField >,
54
+ ) -> Statement <E > {
55
+ Statement :: $stmt( Self {
56
+ revealed_messages,
57
+ signature_params: Some ( signature_params) ,
58
+ signature_params_ref: None ,
59
+ } )
60
+ }
61
+
62
+ /// Create a statement by passing the index of signature parameters in `SetupParams`.
63
+ pub fn new_statement_from_params_ref(
64
+ signature_params_ref: usize ,
65
+ revealed_messages: BTreeMap <usize , E :: ScalarField >,
66
+ ) -> Statement <E > {
67
+ Statement :: $stmt( Self {
68
+ revealed_messages,
69
+ signature_params: None ,
70
+ signature_params_ref: Some ( signature_params_ref) ,
71
+ } )
72
+ }
73
+
74
+ /// Get signature params for the statement index `s_idx` either from `self` or from given `setup_params`.
75
+ pub fn get_params<' a>(
76
+ & ' a self ,
77
+ setup_params: & ' a [ SetupParams <E >] ,
78
+ st_idx: usize ,
79
+ ) -> Result <& ' a $params<E >, ProofSystemError > {
80
+ extract_param!(
81
+ setup_params,
82
+ & self . signature_params,
83
+ self . signature_params_ref,
84
+ $setup_param_name,
85
+ IncompatibleBBSPlusSetupParamAtIndex ,
86
+ st_idx
87
+ )
88
+ }
89
+ } ;
90
+ }
91
+
92
+ #[ macro_export]
93
+ macro_rules! impl_bbs_verifier_statement {
33
94
( $params: ident, $stmt: ident, $setup_param_name: ident) => {
34
95
/// Create a statement by passing the signature parameters and public key directly.
35
96
pub fn new_statement_from_params(
@@ -95,6 +156,18 @@ macro_rules! impl_bbs_statement {
95
156
} ;
96
157
}
97
158
98
- impl < E : Pairing > PoKBBSSignatureG1 < E > {
99
- impl_bbs_statement ! ( SignatureParamsG1 , PoKBBSSignatureG1 , BBSPlusSignatureParams ) ;
159
+ impl < E : Pairing > PoKBBSSignatureG1Prover < E > {
160
+ impl_bbs_prover_statement ! (
161
+ SignatureParamsG1 ,
162
+ PoKBBSSignatureG1Prover ,
163
+ BBSPlusSignatureParams
164
+ ) ;
165
+ }
166
+
167
+ impl < E : Pairing > PoKBBSSignatureG1Verifier < E > {
168
+ impl_bbs_verifier_statement ! (
169
+ SignatureParamsG1 ,
170
+ PoKBBSSignatureG1Verifier ,
171
+ BBSPlusSignatureParams
172
+ ) ;
100
173
}
0 commit comments