@@ -123,6 +123,7 @@ pub struct CompactPkeV2ProofConformanceParams {
123123 accepted_hash_mode : EnumSet < PkeV2HashMode > ,
124124 accepted_proven_zero_bits_encoding : EnumSet < PkeV2ProvenZeroBitsEncoding > ,
125125 accepted_hashed_bound_type : EnumSet < PkeV2HashedBoundType > ,
126+ accepted_hash_k_mode : EnumSet < bool > ,
126127}
127128
128129impl Default for CompactPkeV2ProofConformanceParams {
@@ -152,11 +153,16 @@ impl CompactPkeV2ProofConformanceParams {
152153 accepted_hashed_bound_type. insert ( PkeV2HashedBoundType :: SquaredEuclideanNorm ) ;
153154 accepted_hashed_bound_type. insert ( PkeV2HashedBoundType :: InfiniteNorm ) ;
154155
156+ let mut accepted_hash_k_mode = EnumSet :: new ( ) ;
157+ accepted_hash_k_mode. insert ( true ) ;
158+ accepted_hash_k_mode. insert ( false ) ;
159+
155160 Self {
156161 accepted_compute_load,
157162 accepted_hash_mode,
158163 accepted_proven_zero_bits_encoding,
159164 accepted_hashed_bound_type,
165+ accepted_hash_k_mode,
160166 }
161167 }
162168
@@ -209,6 +215,17 @@ impl CompactPkeV2ProofConformanceParams {
209215 ..self
210216 }
211217 }
218+
219+ /// Reject the proof conformance if k is not hashed
220+ pub fn force_hash_k ( self ) -> Self {
221+ let mut accepted_hash_k_mode = self . accepted_hash_k_mode ;
222+ accepted_hash_k_mode. remove ( false ) ;
223+
224+ Self {
225+ accepted_hash_k_mode,
226+ ..self
227+ }
228+ }
212229}
213230
214231impl ParameterSetConformant for ProofV2 < Curve > {
@@ -227,6 +244,9 @@ impl ParameterSetConformant for ProofV2<Curve> {
227244 && parameter_set
228245 . accepted_hashed_bound_type
229246 . contains ( self . hash_config ( ) . hashed_bound ( ) )
247+ && parameter_set
248+ . accepted_hash_k_mode
249+ . contains ( self . hash_config ( ) . hash_k ( ) )
230250 && self . is_usable ( )
231251 }
232252}
@@ -289,13 +309,22 @@ impl CompactPkeProofConformanceParams {
289309 forbidden_hashed_bound_type : ZkPkeV2HashedBoundType ,
290310 ) -> Self {
291311 match self {
292- // There is no hash mode to configure in PkeV1
312+ // There is no hashed bound to configure in PkeV1
293313 Self :: PkeV1 ( params) => Self :: PkeV1 ( params) ,
294314 Self :: PkeV2 ( params) => {
295315 Self :: PkeV2 ( params. forbid_hashed_bound_type ( forbidden_hashed_bound_type) )
296316 }
297317 }
298318 }
319+
320+ /// Reject the proof conformance if k is not hashed. This has no effect on
321+ /// PkeV1 proofs
322+ pub fn force_hash_k ( self ) -> Self {
323+ match self {
324+ Self :: PkeV1 ( params) => Self :: PkeV1 ( params) ,
325+ Self :: PkeV2 ( params) => Self :: PkeV2 ( params. force_hash_k ( ) ) ,
326+ }
327+ }
299328}
300329
301330impl ParameterSetConformant for CompactPkeProof {
0 commit comments