@@ -14,19 +14,21 @@ pub trait SNARKForR1CS<F: Field>: SNARK<R1CS<F>> {
14
14
15
15
/// Generate inputs for the SNARK indexer from [`cs`].
16
16
/// These inputs consist of the constraint matrices.
17
- fn indexer_inputs < CG : ConstraintGenerator < F > > ( cs : & CG ) -> ConstraintMatrices < F > ;
17
+ fn indexer_inputs < CG : ConstraintGenerator < F > > (
18
+ cs : & CG ,
19
+ ) -> Result < ConstraintMatrices < F > , Self :: Error > ;
18
20
19
21
/// Generate inputs for the SNARK prover from [`cs`].
20
22
/// These inputs consist of the instance and witness. Additionally,
21
23
/// if `Self::PROVING_REQUIRES_MATRICES == true`, then this method returns
22
24
/// `Some(index)` as well.
23
25
fn prover_inputs < WG : WitnessGenerator < F > > (
24
26
cs : & WG ,
25
- ) -> ( Option < ConstraintMatrices < F > > , Instance < F > , Witness < F > ) ;
27
+ ) -> Result < ( Option < ConstraintMatrices < F > > , Instance < F > , Witness < F > ) , Self :: Error > ;
26
28
27
29
/// Generate inputs for the SNARK verifier from [`cs`].
28
30
/// This input consists of the instance.
29
- fn verifier_inputs < IG : InstanceGenerator < F > > ( cs : & IG ) -> Instance < F > ;
31
+ fn verifier_inputs < IG : InstanceGenerator < F > > ( cs : & IG ) -> Result < Instance < F > , Self :: Error > ;
30
32
31
33
/// Indexes the public parameters according to the circuit `circuit`, and
32
34
/// outputs circuit-specific proving and verification keys.
@@ -37,7 +39,7 @@ pub trait SNARKForR1CS<F: Field>: SNARK<R1CS<F>> {
37
39
where
38
40
Self : CircuitSpecificSetupSNARK < R1CS < F > > ,
39
41
{
40
- let index = Self :: indexer_inputs ( c) ;
42
+ let index = Self :: indexer_inputs ( c) ? ;
41
43
Self :: circuit_specific_setup ( & index, rng)
42
44
}
43
45
@@ -52,7 +54,7 @@ pub trait SNARKForR1CS<F: Field>: SNARK<R1CS<F>> {
52
54
where
53
55
Self : UniversalSetupSNARK < R1CS < F > > ,
54
56
{
55
- let index = Self :: indexer_inputs ( c) ;
57
+ let index = Self :: indexer_inputs ( c) . map_err ( IndexingError :: Other ) ? ;
56
58
Self :: index ( pp, & index)
57
59
}
58
60
@@ -62,7 +64,7 @@ pub trait SNARKForR1CS<F: Field>: SNARK<R1CS<F>> {
62
64
c : & WG ,
63
65
rng : & mut Rng ,
64
66
) -> Result < Self :: Proof , Self :: Error > {
65
- let ( index, instance, witness) = Self :: prover_inputs ( c) ;
67
+ let ( index, instance, witness) = Self :: prover_inputs ( c) ? ;
66
68
Self :: prove ( pk, & index, & instance, & witness, rng)
67
69
}
68
70
@@ -73,7 +75,7 @@ pub trait SNARKForR1CS<F: Field>: SNARK<R1CS<F>> {
73
75
c : & IG ,
74
76
proof : & Self :: Proof ,
75
77
) -> Result < bool , Self :: Error > {
76
- let instance = Self :: verifier_inputs ( c) ;
78
+ let instance = Self :: verifier_inputs ( c) ? ;
77
79
Self :: verify ( vk, & instance, proof)
78
80
}
79
81
@@ -84,7 +86,7 @@ pub trait SNARKForR1CS<F: Field>: SNARK<R1CS<F>> {
84
86
c : & IG ,
85
87
proof : & Self :: Proof ,
86
88
) -> Result < bool , Self :: Error > {
87
- let instance = Self :: verifier_inputs ( c) ;
89
+ let instance = Self :: verifier_inputs ( c) ? ;
88
90
Self :: verify_with_processed_vk ( pvk, & instance, proof)
89
91
}
90
92
}
0 commit comments