@@ -68,14 +68,19 @@ where
6868 /// - The prover state (random nonces and witness) used to compute the response.
6969 ///
7070 /// # Errors
71- /// -[`Error::ProofSizeMismatch `] if the witness vector length is incorrect.
71+ /// -[`Error::InvalidInstanceWitnessPair `] if the witness vector length is incorrect.
7272 fn prover_commit (
7373 & self ,
7474 witness : & Self :: Witness ,
7575 mut rng : & mut ( impl RngCore + CryptoRng ) ,
7676 ) -> Result < ( Self :: Commitment , Self :: ProverState ) , Error > {
7777 if witness. len ( ) != self . witness_length ( ) {
78- return Err ( Error :: ProofSizeMismatch ) ;
78+ return Err ( Error :: InvalidInstanceWitnessPair ) ;
79+ }
80+
81+ // If the relation being proven is trivial, refuse to prove the statement.
82+ if self . 0 . image ( ) ?. iter ( ) . all ( |& x| x == G :: identity ( ) ) {
83+ return Err ( Error :: InvalidInstanceWitnessPair )
7984 }
8085
8186 let nonces: Vec < G :: Scalar > = ( 0 ..self . witness_length ( ) )
96101 /// - A vector of scalars forming the prover's response.
97102 ///
98103 /// # Errors
99- /// - Returns [`Error::ProofSizeMismatch `] if the prover state vectors have incorrect lengths.
104+ /// - Returns [`Error::InvalidInstanceWitnessPair `] if the prover state vectors have incorrect lengths.
100105 fn prover_response (
101106 & self ,
102107 prover_state : Self :: ProverState ,
@@ -105,7 +110,7 @@ where
105110 let ( nonces, witness) = prover_state;
106111
107112 if nonces. len ( ) != self . witness_length ( ) || witness. len ( ) != self . witness_length ( ) {
108- return Err ( Error :: ProofSizeMismatch ) ;
113+ return Err ( Error :: InvalidInstanceWitnessPair ) ;
109114 }
110115
111116 let responses = nonces
@@ -125,20 +130,20 @@ where
125130 /// # Returns
126131 /// - `Ok(())` if the proof is valid.
127132 /// - `Err(Error::VerificationFailure)` if the proof is invalid.
128- /// - `Err(Error::ProofSizeMismatch )` if the lengths of commitment or response do not match the expected counts.
133+ /// - `Err(Error::InvalidInstanceWitnessPair )` if the lengths of commitment or response do not match the expected counts.
129134 ///
130135 /// # Errors
131136 /// -[`Error::VerificationFailure`] if the computed relation
132137 /// does not hold for the provided challenge and response, indicating proof invalidity.
133- /// -[`Error::ProofSizeMismatch `] if the commitment or response length is incorrect.
138+ /// -[`Error::InvalidInstanceWitnessPair `] if the commitment or response length is incorrect.
134139 fn verifier (
135140 & self ,
136141 commitment : & Self :: Commitment ,
137142 challenge : & Self :: Challenge ,
138143 response : & Self :: Response ,
139144 ) -> Result < ( ) , Error > {
140145 if commitment. len ( ) != self . commitment_length ( ) || response. len ( ) != self . witness_length ( ) {
141- return Err ( Error :: ProofSizeMismatch ) ;
146+ return Err ( Error :: InvalidInstanceWitnessPair ) ;
142147 }
143148
144149 let lhs = self . 0 . linear_map . evaluate ( response) ?;
@@ -307,14 +312,14 @@ where
307312 /// - A vector of group elements representing the simulated commitment (one per linear constraint).
308313 ///
309314 /// # Errors
310- /// - [`Error::ProofSizeMismatch `] if the response length does not match the expected number of scalars.
315+ /// - [`Error::InvalidInstanceWitnessPair `] if the response length does not match the expected number of scalars.
311316 fn simulate_commitment (
312317 & self ,
313318 challenge : & Self :: Challenge ,
314319 response : & Self :: Response ,
315320 ) -> Result < Self :: Commitment , Error > {
316321 if response. len ( ) != self . witness_length ( ) {
317- return Err ( Error :: ProofSizeMismatch ) ;
322+ return Err ( Error :: InvalidInstanceWitnessPair ) ;
318323 }
319324
320325 let response_image = self . 0 . linear_map . evaluate ( response) ?;
0 commit comments