@@ -104,10 +104,7 @@ mod instance_validation {
104104 relation. set_element ( var_g, G :: generator ( ) ) ;
105105 relation. set_element ( var_h, G :: generator ( ) * Scalar :: from ( 2 ) ) ;
106106 relation. set_element ( var_img_1, G :: generator ( ) * Scalar :: from ( 3 ) ) ;
107-
108- // Try to convert - should fail due to inconsistency
109- let result = CanonicalLinearRelation :: try_from ( & relation) ;
110- assert ! ( result. is_err( ) ) ;
107+ assert ! ( relation. canonical( ) . is_err( ) ) ;
111108 }
112109
113110 #[ test]
@@ -140,17 +137,15 @@ mod instance_validation {
140137 let C_var = linear_relation. allocate_eq ( B_var ) ;
141138 linear_relation. set_element ( B_var , B ) ;
142139 linear_relation. set_element ( C_var , C ) ;
143- let result = CanonicalLinearRelation :: try_from ( & linear_relation) ;
144- assert ! ( result. is_err( ) ) ;
140+ assert ! ( linear_relation. canonical( ) . is_err( ) ) ;
145141
146142 // The following relation is valid and should pass.
147143 let mut linear_relation = LinearRelation :: < G > :: new ( ) ;
148144 let B_var = linear_relation. allocate_element ( ) ;
149145 let C_var = linear_relation. allocate_eq ( B_var ) ;
150146 linear_relation. set_element ( B_var , B ) ;
151147 linear_relation. set_element ( C_var , B ) ;
152- let result = CanonicalLinearRelation :: try_from ( & linear_relation) ;
153- assert ! ( result. is_ok( ) ) ;
148+ assert ! ( linear_relation. canonical( ) . is_ok( ) ) ;
154149
155150 // The following relation is invalid and should trigger a fail.
156151 // X != B * pub_scalar + A * 3
@@ -162,9 +157,7 @@ mod instance_validation {
162157 linear_relation. set_element ( B_var , B ) ;
163158 linear_relation. set_element ( A_var , A ) ;
164159 linear_relation. set_element ( X_var , X ) ;
165-
166- let result = CanonicalLinearRelation :: try_from ( & linear_relation) ;
167- assert ! ( result. is_err( ) ) ;
160+ assert ! ( linear_relation. canonical( ) . is_err( ) ) ;
168161
169162 // The following relation is valid and should pass.
170163 // C = B * pub_scalar + A * 3
@@ -176,9 +169,7 @@ mod instance_validation {
176169 linear_relation. set_element ( B_var , B ) ;
177170 linear_relation. set_element ( A_var , A ) ;
178171 linear_relation. set_element ( C_var , C ) ;
179-
180- let result = CanonicalLinearRelation :: try_from ( & linear_relation) ;
181- assert ! ( result. is_ok( ) ) ;
172+ assert ! ( linear_relation. canonical( ) . is_ok( ) ) ;
182173
183174 // The following relation is for
184175 // X = B * x + B * pub_scalar + A * 3
@@ -194,9 +185,7 @@ mod instance_validation {
194185 linear_relation. set_element ( B_var , B ) ;
195186 linear_relation. set_element ( A_var , A ) ;
196187 linear_relation. set_element ( X_var , X ) ;
197-
198- let result = CanonicalLinearRelation :: try_from ( & linear_relation) ;
199- assert ! ( result. is_ok( ) ) ;
188+ assert ! ( linear_relation. canonical( ) . is_ok( ) ) ;
200189 }
201190}
202191
@@ -208,13 +197,13 @@ mod proof_validation {
208197 use crate :: linear_relation:: { CanonicalLinearRelation , LinearRelation } ;
209198 use bls12_381:: { G1Projective as G , Scalar } ;
210199 use ff:: Field ;
211- use rand:: { thread_rng , RngCore } ;
200+ use rand:: RngCore ;
212201
213202 type TestNizk = Nizk < CanonicalLinearRelation < G > , KeccakByteSchnorrCodec < G > > ;
214203
215204 /// Helper function to create a simple discrete log proof
216205 fn create_valid_proof ( ) -> ( Vec < u8 > , TestNizk ) {
217- let mut rng = thread_rng ( ) ;
206+ let mut rng = rand :: thread_rng ( ) ;
218207
219208 // Create a simple discrete log relation
220209 let mut relation = LinearRelation :: < G > :: new ( ) ;
@@ -227,8 +216,7 @@ mod proof_validation {
227216 relation. set_elements ( [ ( var_g, G :: generator ( ) ) , ( var_x_g, x_g) ] ) ;
228217 relation. append_equation ( var_x_g, var_x * var_g) ;
229218
230- let canonical = CanonicalLinearRelation :: try_from ( & relation) . unwrap ( ) ;
231- let nizk = TestNizk :: new ( b"test_session" , canonical) ;
219+ let nizk = TestNizk :: new ( b"test_session" , relation. canonical ( ) . unwrap ( ) ) ;
232220
233221 let witness = vec ! [ x] ;
234222 let proof = nizk. prove_batchable ( & witness, & mut rng) . unwrap ( ) ;
@@ -279,7 +267,7 @@ mod proof_validation {
279267 let original_len = proof. len ( ) ;
280268
281269 // Append random bytes
282- let mut rng = thread_rng ( ) ;
270+ let mut rng = rand :: thread_rng ( ) ;
283271 let mut extra_bytes = vec ! [ 0u8 ; size] ;
284272 rng. fill_bytes ( & mut extra_bytes) ;
285273 proof. extend_from_slice ( & extra_bytes) ;
@@ -307,7 +295,7 @@ mod proof_validation {
307295
308296 for & size in & prepend_sizes {
309297 // Create new proof with prepended bytes
310- let mut rng = thread_rng ( ) ;
298+ let mut rng = rand :: thread_rng ( ) ;
311299 let mut prepended_proof = vec ! [ 0u8 ; size] ;
312300 rng. fill_bytes ( & mut prepended_proof) ;
313301 prepended_proof. extend_from_slice ( & proof) ;
@@ -361,7 +349,7 @@ mod proof_validation {
361349 let proof_len = valid_proof. len ( ) ;
362350
363351 // Test with completely random bytes of the same length
364- let mut rng = thread_rng ( ) ;
352+ let mut rng = rand :: thread_rng ( ) ;
365353 let mut random_proof = vec ! [ 0u8 ; proof_len] ;
366354 rng. fill_bytes ( & mut random_proof) ;
367355
@@ -376,7 +364,7 @@ mod proof_validation {
376364 fn test_or_relation ( ) {
377365 // This test reproduces the issue from sigma_compiler's simple_or test
378366 // where an OR relation fails verification when using the wrong branch
379- let mut rng = thread_rng ( ) ;
367+ let mut rng = rand :: thread_rng ( ) ;
380368
381369 // Create generators
382370 // For this test, we'll use two different multiples of the generator
0 commit comments