v136 · miscellaneous
Protected audience: text conversion helpers
Protected Audience bidding and scoring scripts that interface with WebAssembly need to efficiently convert string-typed data to (and from) byte arrays (e.g. to pass strings into and out of WebAssembly via the “memory” ArrayBuffer). This provides two standalone functions, protectedAudience.encodeUtf8, and protectedAudience.decodeUtf8 to perform these tasks ab
concepts
-
PA Text Helpers
Protected Audience worklets get TextEncoder/TextDecoder. Less ceremony for moving strings across the trusted-server boundary.
-
WASM bid round-trip
The bidding-script use case: encode a keyword, copy into a wasm module's memory, hash, copy back, decode. The loop these helpers were designed to streamline.
-
Encoder Playground
Type a string, see the UTF-8 byte buffer with a per-byte hex view, then decode back with utf-8 / utf-16le / ascii (fatal). 256-byte trusted-signal budget meter included.
-
Byte Budget Planner
Add key-value trusted-signal pairs, watch the cumulative byte total fill a 256-byte budget bar, see which signals would overflow, and inspect the WASM-ready hex layout — using
TextEncoderto mirror exactly whatprotectedAudience.encodeUtf8()produces in a bidding worklet.
why it shipped
Protected Audience bidding and scoring scripts that interface with WebAssembly need to efficiently convert string-typed data to (and from) byte arrays (e.g. to pass strings into and out of WebAssembly via the “memory” ArrayBuffer). This provides two standalone functions, protectedAudience.encodeUtf8, and protectedAudience.decodeUtf8 to perform these tasks ab