@@ -98,6 +98,12 @@ def verify(self, challenge: Challenge, response: AgentResponse) -> VerificationR
9898 return VerificationResult .failure ("challenge_type_mismatch" )
9999 if utc_now () > parse_datetime (challenge .expires_at ):
100100 return VerificationResult .failure ("challenge_expired" )
101+ expected_answer = challenge .private_data .get ("expected_answer" )
102+ if not isinstance (expected_answer , str ):
103+ return VerificationResult .failure ("missing_private_verification_data" )
104+ template_id = challenge .private_data .get ("template_id" )
105+ if not isinstance (template_id , str ):
106+ return VerificationResult .failure ("missing_private_verification_data" )
101107 answer = response .payload .get ("answer" )
102108 if not isinstance (answer , str ) or not answer .strip ():
103109 return VerificationResult .failure ("missing_answer" )
@@ -107,15 +113,14 @@ def verify(self, challenge: Challenge, response: AgentResponse) -> VerificationR
107113 normalized_answer = answer .strip ().upper ()
108114 if not _is_hyphen_answer (normalized_answer ):
109115 return VerificationResult .failure ("invalid_answer_format" )
110- expected_answer = self ._expected_answer (challenge )
111116 if normalized_answer != expected_answer :
112117 return VerificationResult .failure (
113118 "answer_mismatch" ,
114119 expected_format = "UPPERCASE-HYPHENATED" ,
115120 )
116121 return VerificationResult .success (
117122 answer = normalized_answer ,
118- template_id = self . _template_id ( challenge ) ,
123+ template_id = template_id ,
119124 difficulty = challenge .data .get ("difficulty" ),
120125 )
121126
@@ -141,21 +146,6 @@ def _template_builders() -> dict[str, TemplateBuilder]:
141146 "vowel_count" : _build_vowel_count ,
142147 }
143148
144- @staticmethod
145- def _expected_answer (challenge : Challenge ) -> str :
146- expected_answer = challenge .private_data .get ("expected_answer" )
147- if not isinstance (expected_answer , str ):
148- raise ValueError ("obfuscated_text_lock challenge is missing private expected_answer" )
149- return expected_answer
150-
151- @staticmethod
152- def _template_id (challenge : Challenge ) -> str :
153- template_id = challenge .private_data .get ("template_id" )
154- if not isinstance (template_id , str ):
155- raise ValueError ("obfuscated_text_lock challenge is missing private template_id" )
156- return template_id
157-
158-
159149def _build_amber_sort (rng : random .Random ) -> tuple [list [str ], str ]:
160150 amber_words = rng .sample (TOKEN_POOL , 3 )
161151 noise_words = rng .sample ([word for word in TOKEN_POOL if word not in amber_words ], 2 )
0 commit comments