@@ -73,10 +73,11 @@ use ark_std::{
7373 UniformRand ,
7474} ;
7575use core:: mem;
76+ #[ cfg( feature = "serde" ) ]
77+ use dock_crypto_utils:: serde_utils:: * ;
7678use dock_crypto_utils:: {
7779 misc:: rand,
7880 randomized_pairing_check:: RandomizedPairingChecker ,
79- serde_utils:: * ,
8081 signature:: {
8182 msg_index_map_to_schnorr_response_map, msg_index_to_schnorr_response_index,
8283 schnorr_responses_to_msg_index_map, split_messages_and_blindings, MessageOrBlinding ,
@@ -90,7 +91,9 @@ use schnorr_pok::{
9091 partial:: PartialSchnorrResponse ,
9192 SchnorrCommitment , SchnorrResponse ,
9293} ;
94+ #[ cfg( feature = "serde" ) ]
9395use serde:: { Deserialize , Serialize } ;
96+ #[ cfg( feature = "serde" ) ]
9497use serde_with:: serde_as;
9598use zeroize:: { Zeroize , ZeroizeOnDrop } ;
9699
@@ -103,54 +106,45 @@ use zeroize::{Zeroize, ZeroizeOnDrop};
103106/// pre-challenge (`init`) which is used to create the challenge and post-challenge (`gen_proof`). Thus, several instances of
104107/// the protocol can be used together where the pre-challenge phase of all protocols is used to create a combined challenge
105108/// and then that challenge is used in post-challenge phase of all protocols.
106- #[ serde_as]
109+ #[ cfg_attr ( feature = "serde" , cfg_eval :: cfg_eval , serde_with :: serde_as) ]
107110#[ derive(
108- Clone ,
109- PartialEq ,
110- Eq ,
111- Debug ,
112- Zeroize ,
113- ZeroizeOnDrop ,
114- CanonicalSerialize ,
115- CanonicalDeserialize ,
116- Serialize ,
117- Deserialize ,
111+ Clone , PartialEq , Eq , Debug , CanonicalSerialize , CanonicalDeserialize , Zeroize , ZeroizeOnDrop ,
118112) ]
113+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
119114pub struct PoKOfSignatureG1Protocol < E : Pairing > {
120115 #[ zeroize( skip) ]
121- #[ serde_as( as = "ArkObjectBytes" ) ]
116+ #[ cfg_attr ( feature = "serde" , serde_as( as = "ArkObjectBytes" ) ) ]
122117 pub A_prime : E :: G1Affine ,
123118 #[ zeroize( skip) ]
124- #[ serde_as( as = "ArkObjectBytes" ) ]
119+ #[ cfg_attr ( feature = "serde" , serde_as( as = "ArkObjectBytes" ) ) ]
125120 pub A_bar : E :: G1Affine ,
126121 #[ zeroize( skip) ]
127- #[ serde_as( as = "ArkObjectBytes" ) ]
122+ #[ cfg_attr ( feature = "serde" , serde_as( as = "ArkObjectBytes" ) ) ]
128123 pub d : E :: G1Affine ,
129124 /// For proving relation `A_bar - d = A_prime * -e + h_0 * r2`
130125 pub sc_comm_1 : PokPedersenCommitmentProtocol < E :: G1Affine > ,
131126 /// 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)`
132127 pub sc_comm_2 : SchnorrCommitment < E :: G1Affine > ,
133- #[ serde_as( as = "Vec<ArkObjectBytes>" ) ]
128+ #[ cfg_attr ( feature = "serde" , serde_as( as = "Vec<ArkObjectBytes>" ) ) ]
134129 sc_wits_2 : Vec < E :: ScalarField > ,
135130}
136131
137132/// Proof of knowledge of BBS+ signature in G1. It contains the randomized signature, commitment (Schnorr step 1)
138133/// and response (Schnorr step 3) to both Schnorr protocols in `T_` and `sc_resp_`
139- #[ serde_as]
140- #[ derive(
141- Clone , PartialEq , Eq , Debug , CanonicalSerialize , CanonicalDeserialize , Serialize , Deserialize ,
142- ) ]
134+ #[ cfg_attr( feature = "serde" , cfg_eval:: cfg_eval, serde_with:: serde_as) ]
135+ #[ derive( Clone , PartialEq , Eq , Debug , CanonicalSerialize , CanonicalDeserialize ) ]
136+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
143137pub struct PoKOfSignatureG1Proof < E : Pairing > {
144- #[ serde_as( as = "ArkObjectBytes" ) ]
138+ #[ cfg_attr ( feature = "serde" , serde_as( as = "ArkObjectBytes" ) ) ]
145139 pub A_prime : E :: G1Affine ,
146- #[ serde_as( as = "ArkObjectBytes" ) ]
140+ #[ cfg_attr ( feature = "serde" , serde_as( as = "ArkObjectBytes" ) ) ]
147141 pub A_bar : E :: G1Affine ,
148- #[ serde_as( as = "ArkObjectBytes" ) ]
142+ #[ cfg_attr ( feature = "serde" , serde_as( as = "ArkObjectBytes" ) ) ]
149143 pub d : E :: G1Affine ,
150144 /// Proof of relation `A_bar - d = A_prime * -e + h_0 * r2`
151145 pub sc_resp_1 : PokPedersenCommitment < E :: G1Affine > ,
152146 /// 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`
153- #[ serde_as( as = "ArkObjectBytes" ) ]
147+ #[ cfg_attr ( feature = "serde" , serde_as( as = "ArkObjectBytes" ) ) ]
154148 pub T2 : E :: G1Affine ,
155149 /// The following could be achieved by using Either<SchnorrResponse, PartialSchnorrResponse> but serialization
156150 /// for Either is not supported out of the box and had to be implemented
0 commit comments