Skip to content

Commit af79d52

Browse files
committed
nit: simplify test_relations function pointers.
1 parent 9f7a8aa commit af79d52

File tree

1 file changed

+15
-27
lines changed

1 file changed

+15
-27
lines changed

src/tests/test_relations.rs

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn discrete_logarithm<G: PrimeGroup, R: rand::RngCore>(
2929

3030
assert_eq!(X, G::generator() * x);
3131
let witness = vec![x];
32-
let instance: CanonicalLinearRelation<G> = (&relation).try_into().unwrap();
32+
let instance = (&relation).try_into().unwrap();
3333
(instance, witness)
3434
}
3535

@@ -443,34 +443,22 @@ fn test_relations() {
443443
use group::Group;
444444
type G = bls12_381::G1Projective;
445445
type RelationGenerator<G> =
446-
Box<dyn Fn(&mut OsRng) -> (CanonicalLinearRelation<G>, Vec<<G as Group>::Scalar>)>;
446+
&'static dyn Fn(&mut OsRng) -> (CanonicalLinearRelation<G>, Vec<<G as Group>::Scalar>);
447447

448448
let instance_generators: Vec<(&str, RelationGenerator<G>)> = vec![
449-
("dlog", Box::new(discrete_logarithm)),
450-
("shifted_dlog", Box::new(shifted_dlog)),
451-
("dleq", Box::new(dleq)),
452-
("shifted_dleq", Box::new(shifted_dleq)),
453-
("pedersen_commitment", Box::new(pedersen_commitment)),
454-
(
455-
"twisted_pedersen_commitment",
456-
Box::new(twisted_pedersen_commitment),
457-
),
458-
(
459-
"pedersen_commitment_dleq",
460-
Box::new(pedersen_commitment_dleq),
461-
),
462-
("bbs_blind_commitment", Box::new(bbs_blind_commitment)),
463-
(
464-
"weird_linear_combination",
465-
Box::new(weird_linear_combination),
466-
),
467-
("simple_subtractions", Box::new(simple_subtractions)),
468-
("subtractions_with_shift", Box::new(subtractions_with_shift)),
469-
(
470-
"cmz_wallet_spend_relation",
471-
Box::new(cmz_wallet_spend_relation),
472-
),
473-
("nested_affine_relation", Box::new(nested_affine_relation)),
449+
("dlog", &discrete_logarithm),
450+
("shifted_dlog", &shifted_dlog),
451+
("dleq", &dleq),
452+
("shifted_dleq", &shifted_dleq),
453+
("pedersen_commitment", &pedersen_commitment),
454+
("twisted_pedersen_commitment", &twisted_pedersen_commitment),
455+
("pedersen_commitment_dleq", &pedersen_commitment_dleq),
456+
("bbs_blind_commitment", &bbs_blind_commitment),
457+
("weird_linear_combination", &weird_linear_combination),
458+
("simple_subtractions", &simple_subtractions),
459+
("subtractions_with_shift", &subtractions_with_shift),
460+
("cmz_wallet_spend_relation", &cmz_wallet_spend_relation),
461+
("nested_affine_relation", &nested_affine_relation),
474462
];
475463

476464
for (relation_name, relation_sampler) in instance_generators.iter() {

0 commit comments

Comments
 (0)