@@ -6,7 +6,6 @@ use ark_std::{
66 io:: { Read , Write } ,
77 marker:: PhantomData ,
88 ops:: { AddAssign , MulAssign , SubAssign } ,
9- string:: ToString ,
109} ;
1110use rand_core:: RngCore ;
1211
@@ -115,7 +114,7 @@ pub struct BatchLCProof<F: Field, P: Polynomial<F>, PC: PolynomialCommitment<F,
115114/// A polynomial along with information about its degree bound (if any), and the
116115/// maximum number of queries that will be made to it. This latter number determines
117116/// the amount of protection that will be provided to a commitment for this polynomial.
118- #[ derive( Debug , Clone ) ]
117+ #[ derive( Debug , Clone , CanonicalSerialize , CanonicalDeserialize ) ]
119118pub struct LabeledPolynomial < F : Field , P : Polynomial < F > > {
120119 label : PolynomialLabel ,
121120 polynomial : Rc < P > ,
@@ -124,99 +123,6 @@ pub struct LabeledPolynomial<F: Field, P: Polynomial<F>> {
124123 _field : PhantomData < F > ,
125124}
126125
127- impl < F : Field , P : Polynomial < F > > CanonicalSerialize for LabeledPolynomial < F , P > {
128- fn serialize < W : Write > ( & self , mut writer : W ) -> Result < ( ) , SerializationError > {
129- self . label . clone ( ) . into_bytes ( ) . serialize ( & mut writer) ?;
130- self . polynomial . serialize ( & mut writer) ?;
131- self . degree_bound . serialize ( & mut writer) ?;
132- self . hiding_bound . serialize ( & mut writer)
133- }
134-
135- fn serialized_size ( & self ) -> usize {
136- self . label . clone ( ) . into_bytes ( ) . serialized_size ( )
137- + self . polynomial . serialized_size ( )
138- + self . degree_bound . serialized_size ( )
139- + self . hiding_bound . serialized_size ( )
140- }
141-
142- fn serialize_uncompressed < W : Write > ( & self , mut writer : W ) -> Result < ( ) , SerializationError > {
143- self . label
144- . clone ( )
145- . into_bytes ( )
146- . serialize_uncompressed ( & mut writer) ?;
147- self . polynomial . serialize_uncompressed ( & mut writer) ?;
148- self . degree_bound . serialize_uncompressed ( & mut writer) ?;
149- self . hiding_bound . serialize_uncompressed ( & mut writer)
150- }
151-
152- fn serialize_unchecked < W : Write > ( & self , mut writer : W ) -> Result < ( ) , SerializationError > {
153- self . label
154- . clone ( )
155- . into_bytes ( )
156- . serialize_unchecked ( & mut writer) ?;
157- self . polynomial . serialize_unchecked ( & mut writer) ?;
158- self . degree_bound . serialize_unchecked ( & mut writer) ?;
159- self . hiding_bound . serialize_unchecked ( & mut writer)
160- }
161-
162- fn uncompressed_size ( & self ) -> usize {
163- self . label . clone ( ) . into_bytes ( ) . uncompressed_size ( )
164- + self . polynomial . uncompressed_size ( )
165- + self . degree_bound . uncompressed_size ( )
166- + self . hiding_bound . uncompressed_size ( )
167- }
168- }
169-
170- impl < F : Field , P : Polynomial < F > > CanonicalDeserialize for LabeledPolynomial < F , P > {
171- fn deserialize < R : Read > ( mut reader : R ) -> Result < Self , SerializationError > {
172- let label_bytes = Vec :: < u8 > :: deserialize ( & mut reader) ?;
173- let label = String :: from_utf8_lossy ( & label_bytes) ;
174- let polynomial = Rc :: new ( P :: deserialize ( & mut reader) ?) ;
175- let degree_bound = Option :: < usize > :: deserialize ( & mut reader) ?;
176- let hiding_bound = Option :: < usize > :: deserialize ( & mut reader) ?;
177-
178- Ok ( Self {
179- label : label. to_string ( ) ,
180- polynomial,
181- degree_bound,
182- hiding_bound,
183- _field : PhantomData ,
184- } )
185- }
186-
187- fn deserialize_uncompressed < R : Read > ( mut reader : R ) -> Result < Self , SerializationError > {
188- let label_bytes = Vec :: < u8 > :: deserialize_uncompressed ( & mut reader) ?;
189- let label = String :: from_utf8_lossy ( & label_bytes) ;
190- let polynomial = Rc :: new ( P :: deserialize_uncompressed ( & mut reader) ?) ;
191- let degree_bound = Option :: < usize > :: deserialize_uncompressed ( & mut reader) ?;
192- let hiding_bound = Option :: < usize > :: deserialize_uncompressed ( & mut reader) ?;
193-
194- Ok ( Self {
195- label : label. to_string ( ) ,
196- polynomial,
197- degree_bound,
198- hiding_bound,
199- _field : PhantomData ,
200- } )
201- }
202-
203- fn deserialize_unchecked < R : Read > ( mut reader : R ) -> Result < Self , SerializationError > {
204- let label_bytes = Vec :: < u8 > :: deserialize_unchecked ( & mut reader) ?;
205- let label = String :: from_utf8_lossy ( & label_bytes) ;
206- let polynomial = Rc :: new ( P :: deserialize_unchecked ( & mut reader) ?) ;
207- let degree_bound = Option :: < usize > :: deserialize_unchecked ( & mut reader) ?;
208- let hiding_bound = Option :: < usize > :: deserialize_unchecked ( & mut reader) ?;
209-
210- Ok ( Self {
211- label : label. to_string ( ) ,
212- polynomial,
213- degree_bound,
214- hiding_bound,
215- _field : PhantomData ,
216- } )
217- }
218- }
219-
220126impl < ' a , F : Field , P : Polynomial < F > > core:: ops:: Deref for LabeledPolynomial < F , P > {
221127 type Target = P ;
222128
0 commit comments