@@ -313,49 +313,6 @@ impl From<&AuctionResponse> for ProviderSummary {
313313 }
314314}
315315
316- /// Length of the hex-encoded creative trace hash.
317- ///
318- /// 16 hex chars (64 bits of SHA-256) — short enough for a DOM attribute and a
319- /// log field, long enough that collisions across a page's creatives are not a
320- /// practical concern for tracing.
321- const ADM_TRACE_HASH_LEN : usize = 16 ;
322-
323- /// Compute the trace hash for a creative markup string.
324- ///
325- /// The hash is the first [`ADM_TRACE_HASH_LEN`] hex characters of the SHA-256
326- /// of the exact bytes handed to the client. It is a correlation key for
327- /// tracing a winning bid to the creative rendered on the page — server logs,
328- /// the injected bid payload, and DOM markers all carry the same value — not an
329- /// integrity mechanism.
330- ///
331- /// # Examples
332- ///
333- /// ```
334- /// use trusted_server_core::auction::adm_trace_hash;
335- ///
336- /// let hash = adm_trace_hash("<div>example creative</div>");
337- /// assert_eq!(hash.len(), 16);
338- /// ```
339- #[ must_use]
340- pub fn adm_trace_hash ( adm : & str ) -> String {
341- use sha2:: { Digest as _, Sha256 } ;
342-
343- let digest = Sha256 :: digest ( adm. as_bytes ( ) ) ;
344- let mut hex = hex:: encode ( digest) ;
345- hex. truncate ( ADM_TRACE_HASH_LEN ) ;
346- hex
347- }
348-
349- impl Bid {
350- /// Trace hash of this bid's creative markup, when present.
351- ///
352- /// See [`adm_trace_hash`] for the hash definition.
353- #[ must_use]
354- pub fn creative_trace_hash ( & self ) -> Option < String > {
355- self . creative . as_deref ( ) . map ( adm_trace_hash)
356- }
357- }
358-
359316/// `OpenRTB` response metadata for the orchestrator.
360317#[ derive( Debug , Clone , Serialize , Deserialize ) ]
361318pub struct OrchestratorExt {
@@ -451,42 +408,6 @@ mod tests {
451408 }
452409 }
453410
454- #[ test]
455- fn adm_trace_hash_is_sha256_prefix ( ) {
456- // SHA-256("abc") = ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
457- assert_eq ! (
458- adm_trace_hash( "abc" ) ,
459- "ba7816bf8f01cfea" ,
460- "should be the first 16 hex chars of the SHA-256 digest"
461- ) ;
462- }
463-
464- #[ test]
465- fn adm_trace_hash_distinguishes_creatives ( ) {
466- assert_ne ! (
467- adm_trace_hash( "<div>creative a</div>" ) ,
468- adm_trace_hash( "<div>creative b</div>" ) ,
469- "should produce different hashes for different markup"
470- ) ;
471- }
472-
473- #[ test]
474- fn creative_trace_hash_follows_creative_presence ( ) {
475- let mut bid = make_bid ( "kargo" ) ;
476- assert_eq ! (
477- bid. creative_trace_hash( ) ,
478- None ,
479- "should be None without creative markup"
480- ) ;
481-
482- bid. creative = Some ( "<div>example creative</div>" . to_owned ( ) ) ;
483- assert_eq ! (
484- bid. creative_trace_hash( ) ,
485- Some ( adm_trace_hash( "<div>example creative</div>" ) ) ,
486- "should hash the creative markup when present"
487- ) ;
488- }
489-
490411 #[ test]
491412 fn provider_summary_from_successful_response ( ) {
492413 let response = AuctionResponse :: success (
0 commit comments