@@ -5,12 +5,12 @@ use group::prime::PrimeGroup;
55use rand:: rngs:: OsRng ;
66use rand:: RngCore ;
77
8- use ff:: PrimeField ;
98use crate :: fiat_shamir:: Nizk ;
109use crate :: {
1110 codec:: Shake128DuplexSponge , linear_relation:: CanonicalLinearRelation ,
1211 schnorr_protocol:: SchnorrProof ,
1312} ;
13+ use ff:: PrimeField ;
1414
1515use crate :: linear_relation:: { msm_pr, LinearRelation } ;
1616
@@ -235,7 +235,6 @@ pub fn bbs_blind_commitment<G: PrimeGroup, R: RngCore>(
235235 ( instance, witness)
236236}
237237
238-
239238/// LinearMap for the user's specific relation: A * 1 + gen__disj1_x_r * B
240239#[ allow( non_snake_case) ]
241240pub fn weird_linear_combination < G : PrimeGroup , R : RngCore > (
@@ -267,7 +266,6 @@ pub fn weird_linear_combination<G: PrimeGroup, R: RngCore>(
267266 ( instance, witness)
268267}
269268
270-
271269fn simple_subtractions < G : PrimeGroup , R : RngCore > (
272270 mut rng : & mut R ,
273271) -> ( CanonicalLinearRelation < G > , Vec < G :: Scalar > ) {
@@ -278,8 +276,7 @@ fn simple_subtractions<G: PrimeGroup, R: RngCore>(
278276 let mut linear_relation = LinearRelation :: < G > :: new ( ) ;
279277 let x_var = linear_relation. allocate_scalar ( ) ;
280278 let B_var = linear_relation. allocate_element ( ) ;
281- let X_var = linear_relation
282- . allocate_eq ( ( x_var + ( -G :: Scalar :: from_u128 ( 1u128 ) ) ) * B_var ) ;
279+ let X_var = linear_relation. allocate_eq ( ( x_var + ( -G :: Scalar :: from_u128 ( 1u128 ) ) ) * B_var ) ;
283280 linear_relation. set_element ( B_var , B ) ;
284281 linear_relation. set_element ( X_var , X ) ;
285282
@@ -291,16 +288,15 @@ fn simple_subtractions<G: PrimeGroup, R: RngCore>(
291288fn subtractions_with_shift < G : PrimeGroup , R : RngCore > (
292289 mut rng : & mut R ,
293290) -> ( CanonicalLinearRelation < G > , Vec < G :: Scalar > ) {
294-
295291 let B = G :: generator ( ) ;
296292 let x = G :: Scalar :: random ( & mut rng) ;
297293 let X = B * ( x - G :: Scalar :: from ( 2 ) ) ;
298294
299295 let mut linear_relation = LinearRelation :: < G > :: new ( ) ;
300296 let x_var = linear_relation. allocate_scalar ( ) ;
301297 let B_var = linear_relation. allocate_element ( ) ;
302- let X_var = linear_relation
303- . allocate_eq ( ( x_var + ( -G :: Scalar :: from_u128 ( 1u128 ) ) ) * B_var + ( -B_var ) ) ;
298+ let X_var =
299+ linear_relation . allocate_eq ( ( x_var + ( -G :: Scalar :: from_u128 ( 1u128 ) ) ) * B_var + ( -B_var ) ) ;
304300
305301 linear_relation. set_element ( B_var , B ) ;
306302 linear_relation. set_element ( X_var , X ) ;
@@ -309,6 +305,26 @@ fn subtractions_with_shift<G: PrimeGroup, R: RngCore>(
309305 ( instance, witness)
310306}
311307
308+ #[ allow( dead_code) ]
309+ fn without_witness < G : PrimeGroup , R : RngCore > (
310+ mut rng : & mut R ,
311+ ) -> ( CanonicalLinearRelation < G > , Vec < G :: Scalar > ) {
312+ let B = G :: generator ( ) ;
313+ let x = G :: Scalar :: random ( & mut rng) ;
314+ // let X = B * (x + G::Scalar::from(3));
315+
316+ let mut linear_relation = LinearRelation :: < G > :: new ( ) ;
317+ let B_var = linear_relation. allocate_element ( ) ;
318+ // let X_var =
319+ // linear_relation.allocate_eq(B * x + B * G::Scalar::from_u128(3u128));
320+
321+ linear_relation. set_element ( B_var , B ) ;
322+ // linear_relation.set_element(X_var, X);
323+ let instance = ( & linear_relation) . try_into ( ) . unwrap ( ) ;
324+ let witness = vec ! [ x] ;
325+ ( instance, witness)
326+ }
327+
312328/// Generic helper function to test both relation correctness and NIZK functionality
313329#[ test]
314330fn test_common_relations ( ) {
0 commit comments